Example #1
0
 public void initialize(PlugInContext context) throws Exception {
   FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());
   featureInstaller.addMainMenuItem(
       this,
       new String[] {MenuNames.TOOLS, MenuNames.TOOLS_ANALYSIS},
       new JMenuItem(this.getName() + "..."),
       createEnableCheck(context.getWorkbenchContext()));
 }
    public ViewAttributesFrame(final Layer layer, final PlugInContext context) {
      this.layerManager = context.getLayerManager();
      addInternalFrameListener(
          new InternalFrameAdapter() {
            public void internalFrameClosed(InternalFrameEvent e) {
              // Assume that there are no other views on the model [Jon
              // Aquino]
              attributeTab.getModel().dispose();
            }
          });
      setResizable(true);
      setClosable(true);
      setMaximizable(true);
      setIconifiable(true);
      getContentPane().setLayout(new BorderLayout());
      attributeTab =
          new OneLayerAttributeTab(
                  context.getWorkbenchContext(),
                  ((TaskFrameProxy) context.getActiveInternalFrame()).getTaskFrame(),
                  this)
              .setLayer(layer);
      addInternalFrameListener(
          new InternalFrameAdapter() {
            public void internalFrameOpened(InternalFrameEvent e) {
              attributeTab.getToolBar().updateEnabledState();
            }
          });
      getContentPane().add(attributeTab, BorderLayout.CENTER);
      setSize(500, 300);
      updateTitle(attributeTab.getLayer());
      context
          .getLayerManager()
          .addLayerListener(
              new LayerListener() {
                public void layerChanged(LayerEvent e) {
                  if (attributeTab.getLayer() != null) {
                    updateTitle(attributeTab.getLayer());
                  }
                  // Layer REMOVE [mmichaud 2012-01-05]
                  if (e.getType() == LayerEventType.REMOVED) {
                    if (e.getLayerable() == attributeTab.getLayer()) {
                      attributeTab.getModel().dispose();
                      context.getLayerManager().removeLayerListener(this);
                      context.getWorkbenchFrame().removeInternalFrame(ViewAttributesFrame.this);
                      dispose();
                    }
                  }
                }

                public void categoryChanged(CategoryEvent e) {}

                public void featuresChanged(FeatureEvent e) {}
              });
      Assert.isTrue(
          !(this instanceof CloneableInternalFrame),
          I18N.get("ui.plugin.ViewAttributesPlugIn.there-can-be-no-other-views-on-the-InfoModels"));
    }
Example #3
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;
  }