Beispiel #1
0
  public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) {
    for (int i = 0; i < XY.length; i++) {
      int[] screenCoord = draw.project(XY[i]);

      if ((screenCoord[0] + note_precision > screenCoordTest[0])
          && (screenCoord[0] - note_precision < screenCoordTest[0])
          && (screenCoord[1] + note_precision > screenCoordTest[1])
          && (screenCoord[1] - note_precision < screenCoordTest[1])) {
        // System.out.println("fid of selected point: " + pointId[i]);
        List features = layer.getFeatureCollectionWrapper().getFeatures();
        Feature selFeature = null;
        for (Iterator iter = features.iterator(); iter.hasNext(); ) {
          Feature f = (Feature) iter.next();
          if (pointId[i] == f.getID()) {
            selFeature = f;
          }
        }
        // context.getLayerViewPanel().getSelectionManager().clear();
        // context.getLayerViewPanel().getSelectionManager().getFeatureSelection().selectItems(layer, selFeature);
        Collection clickedFeatures = new ArrayList();
        clickedFeatures.add(selFeature);
        try {
          zoomToSelectedItemsPlugIn.flash(
              FeatureUtil.toGeometries(clickedFeatures), context.getLayerViewPanel());
        } catch (Throwable t) {
          context.getWorkbenchContext().getErrorHandler().handleThrowable(t);
        }

        // -- [sstein] modified to print FID as label
        //   but this results with problems in AbstractDrawer.drawCoordinate()
        //   since it will try to set the axes using the FID as well.
        /*
        double[] vals;
        if (pointId !=null){
            vals = new double[3];
            vals[0] = XY[i][0];
            vals[1] = XY[i][1];
            vals[2] = pointId[i];
        }
        else{
          vals = XY[i];
        }
        return vals;
        */
        return XY[i];
      }
    }
    return null;
  }
Beispiel #2
0
  public void plot(AbstractDrawer draw, Color c) {
    if (!visible) return;

    int cor = 0;
    for (int j = 0; j < z.length; j++) {
      if (j < z.length / 2) {
        color = new Color(0, j * (255 / (z.length / 2)), 255);
        cor = j;
      } else {
        color = new Color(255, cor * (255 / (z.length / 2)), 0);
        cor = (cor == 0) ? cor : cor - 1;
      }

      Cone _cone = new Cone(k, color);
      double h = height - j * 0.1;
      double r = ratio * (h / height); // semelhança de triangulos

      for (int i = 0; i < k + 1; i++) {
        _cone.setCone(i, r * Math.cos(i * theta), r * Math.sin(i * theta), z[j]);
      }
      listCone.add(j, _cone);
    }
    // Para saber se a visão do gráfico é superior, basta saber se screenCoord[1] <= 333. Do
    // contrário, estamos vendo o gráfico por baixo.
    int[] screenCoord = draw.project(new double[] {-1, -1, -1});

    if (screenCoord[1] <= 333) {
      for (int i = 1; i < listCone.size(); i++) {
        for (int j = 1; j < k + 1; j++) {
          draw.setColor(listCone.get(i).getColor());
          draw.fillPolygon(
              1.0f,
              new double[] {
                listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i - 1).getX(j - 1),
                listCone.get(i - 1).getY(j - 1),
                listCone.get(i - 1).getZ(j - 1)
              },
              new double[] {
                listCone.get(i - 1).getX(j),
                listCone.get(i - 1).getY(j),
                listCone.get(i - 1).getZ(j - 1)
              });

          draw.setColor(new Color(0, 0, 0));
          draw.drawPolygon(
              new double[] {
                listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i - 1).getX(j - 1),
                listCone.get(i - 1).getY(j - 1),
                listCone.get(i - 1).getZ(j - 1)
              },
              new double[] {
                listCone.get(i - 1).getX(j),
                listCone.get(i - 1).getY(j),
                listCone.get(i - 1).getZ(j - 1)
              });
        }
      }

    } else {
      for (int i = listCone.size() - 1; i > 0; i--) {
        for (int j = 1; j < k + 1; j++) {
          draw.setColor(listCone.get(i).getColor());
          draw.fillPolygon(
              1.0f,
              new double[] {
                listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i - 1).getX(j - 1),
                listCone.get(i - 1).getY(j - 1),
                listCone.get(i - 1).getZ(j - 1)
              },
              new double[] {
                listCone.get(i - 1).getX(j),
                listCone.get(i - 1).getY(j),
                listCone.get(i - 1).getZ(j - 1)
              });

          draw.setColor(new Color(0, 0, 0));
          draw.drawPolygon(
              new double[] {
                listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j)
              },
              new double[] {
                listCone.get(i - 1).getX(j - 1),
                listCone.get(i - 1).getY(j - 1),
                listCone.get(i - 1).getZ(j - 1)
              },
              new double[] {
                listCone.get(i - 1).getX(j),
                listCone.get(i - 1).getY(j),
                listCone.get(i - 1).getZ(j - 1)
              });
        }
      }
    }
    listCone.clear();
  }