List of usage examples for java.awt.geom Line2D intersects
public boolean intersects(Rectangle2D r)
From source file:simulador.controle.GeradorGraficos.java
private Map<Float, Float> obterValoresCelulasRadial(Point pontoInicial, Point pontoFinal) { if (DEBUG) {//www .ja v a2s . c om System.out.println("GeradorGraficos.obterValoresCelulasRadial"); } // System.out.println("pontoInicial: ("+pontoInicial.x+", "+pontoInicial.y+")"); // System.out.println("pontoFinal: ("+pontoFinal.x+", "+pontoFinal.y+")"); float distanciaMaxPixels = (float) new Point(0, 0) .distance(new Point(painelDesign.getImagem().getWidth(), painelDesign.getImagem().getHeight())); float distanciaMaxMetros = (float) new Point2D.Float(0, 0) .distance(new Point2D.Float(ambiente.getLargura(), ambiente.getComprimento())); Map<Float, Float> valoresCelulasRadial = new HashMap(); Line2D radial = new Line2D.Float(pontoInicial, pontoFinal); Rectangle boxRadial = radial.getBounds(); int[] celRadialIncial = painelDesign.buscarCelula(new Point(boxRadial.x, boxRadial.y)); int[] celRadialFinal = painelDesign .buscarCelula(new Point((int) boxRadial.getMaxX(), (int) boxRadial.getMaxY())); // System.out.println("celRadialInicial["+celRadialIncial[0]+"]["+celRadialIncial[1]+"]"); // System.out.println("celRadialFinal["+celRadialFinal[0]+"]["+celRadialFinal[1]+"]"); int linIncialRadial = celRadialIncial[0]; int colIncialRadial = celRadialIncial[1]; int linFinalRadial = celRadialFinal[0]; int colFinalRadial = celRadialFinal[1]; int[] coordCelPontoInicial = painelDesign.buscarCelula(pontoInicial); PainelDesign.Celula celPontoInicial = painelDesign.getMatrizCelulas().get(coordCelPontoInicial[0]) .get(coordCelPontoInicial[1]); for (int i = linIncialRadial; i <= linFinalRadial; i++) { for (int j = colIncialRadial; j <= colFinalRadial; j++) { PainelDesign.Celula cel = painelDesign.getMatrizCelulas().get(i).get(j); //System.out.println("cel["+i+"]["+j+"] interceptada ?"); if (radial.intersects(cel)) { float distanciaPontosPixels = (float) new Point(celPontoInicial.x, celPontoInicial.y) .distance(new Point(cel.x, cel.y)); float distanciaPontosMetros = (float) ControladorDesign .converterCoordenadas(distanciaPontosPixels, distanciaMaxPixels, distanciaMaxMetros); //System.out.println("sim"); // System.out.println("potencia: "+cel.obterValor("potencia")); // System.out.println("distancia: "+distanciaPontosMetros); //cel.setCorFundoRGB(Color.BLUE.getRGB()); valoresCelulasRadial.put(distanciaPontosMetros, //cel.obterValor("distancia"), cel.obterValor("potencia")); } } } return valoresCelulasRadial; }