Пример #1
0
 public void layerRemoved(LayerCollectionEvent e) {
   VectorialLayerEdited vle = (VectorialLayerEdited) getActiveLayerEdited();
   if (vle != null && vle.getLayer().isActive()) {
     // FLayers layers=getMapControl().getMapContext().getLayers();
     // if (layers.getLayersCount()>0)
     //	layers.getLayer(0).setActive(true);
     try {
       vle.clearSelection();
     } catch (DataException e1) {
       NotificationManager.addError(e1);
     }
     editedLayers.remove(vle);
     getMapControl().setTool("zoomIn");
     FLyrVect lv = (FLyrVect) vle.getLayer();
     if (e.getAffectedLayer().equals(lv)) {
       IWindow window = PluginServices.getMDIManager().getActiveWindow();
       if (window instanceof View) {
         View view = (View) window;
         view.hideConsole();
         view.validate();
         view.repaint();
       }
     }
   }
   PluginServices.getMainFrame().enableControls();
 }
Пример #2
0
  public void editionChanged(LayerEvent e) {
    Logger.global.info(e.toString());
    ILayerEdited lyrEdit = getLayerEdited(e.getSource());

    // Si no está en la lista, comprobamos que está en edición
    // y lo añadimos
    if ((lyrEdit == null) && e.getSource().isEditing()) {
      lyrEdit = FactoryLayerEdited.createLayerEdited(e.getSource());
      editedLayers.add(lyrEdit);
      if (getMapControl() != null) {
        getMapControl().setTool("cadtooladapter");
        CADExtension.setCADTool("_selection", true);
      }
      PluginServices.getMainFrame().setSelectedTool("_selection");
      // idActiveLayer = editedLayers.size() - 1;
      ile = getLayerEdited(e.getSource());
      System.out.println("NUEVA CAPA EN EDICION: " + lyrEdit.getLayer().getName());
      // activationChanged(e);

      // Ponemos el resto de temas desactivados
      if (mapCtrl != null) mapCtrl.getMapContext().getLayers().setActive(false);
      // y activamos el nuevo.
      e.getSource().setActive(true);

      if (e.getSource() instanceof FLyrVect) {
        FLyrVect fLyrVect = (FLyrVect) e.getSource();
        ((VectorialLayerEdited) lyrEdit)
            .setEditionChangeManager(new EditionChangeManager(fLyrVect));

        //				VectorialEditableAdapter vea =
        //					(VectorialEditableAdapter)fLyrVect.getSource();
        //				vea.addEditionListener(new EditionChangeManager(fLyrVect));
      }
    } else {
      for (int i = 0; i < editedLayers.size(); i++) {
        VectorialLayerEdited vle = (VectorialLayerEdited) editedLayers.get(i);
        if (vle.equals(lyrEdit)) {
          editedLayers.remove(i);
          ile = null;
          // idActiveLayer=-1;
          return;
        }
      }
    }
  }
Пример #3
0
  public void activationChanged(LayerEvent e) {
    if (e.getSource().isActive()) {
      ile = getLayerEdited(e.getSource());
    }
    //		IWindow window=PluginServices.getMDIManager().getActiveWindow();
    //		if (window instanceof View){
    //			View view=(View)window;
    //			if (e.getSource().isEditing()){
    //				view.showConsole();
    //			}else{
    //				view.hideConsole();
    //			}
    //		}

    if (ile == null || ile.getLayer().equals(e.getSource())) {

      if (ile != null && !ile.getLayer().isActive()) {
        VectorialLayerEdited lastVLE = (VectorialLayerEdited) ile;
        lastVLE.activationLost(e);
      }
      if (e.getSource() instanceof FLyrVect) {
        VectorialLayerEdited vle = null;
        vle = (VectorialLayerEdited) getLayerEdited(e.getSource());
        // for (int i = 0; i < editedLayers.size(); i++) {
        // vle = (VectorialLayerEdited) editedLayers.get(i);
        // if (vle.getLayer().equals(e.getSource())) {
        // idActiveLayer = i;
        ile = vle;
        if (getMapControl() != null && vle != null && vle.getLayer().isActive()) {
          getMapControl().setTool("cadtooladapter");
          vle.activationGained(e);
          return;
        }
      }
      // }
      // idActiveLayer=-1;
      // ile=null;
      if (getMapControl() != null) {
        getMapControl().setTool("zoomIn");
        PluginServices.getMainFrame().setSelectedTool("ZOOM_IN");
      }
    }
  }
Пример #4
0
  /**
   * Método para dibujar lo necesario para el estado en el que nos encontremos.
   *
   * @param g Graphics sobre el que dibujar.
   * @param selectedGeometries BitSet con las geometrías seleccionadas.
   * @param x parámetro x del punto que se pase para dibujar.
   * @param y parámetro x del punto que se pase para dibujar.
   */
  public void drawOperation(Graphics g, double x, double y) {
    SplineCADToolState actualState = _fsm.getState();
    String status = actualState.getName();
    if (status.equals("Spline.NextPoint") || status.equals("Spline.FirstPoint")) {
      //        	ArrayList points=new ArrayList();
      Point2D[] points = new Point2D[list.size() + 1];
      Point2D[] auxPoints = (Point2D[]) list.toArray(new Point2D[0]);
      for (int i = 0; i < auxPoints.length; i++) {
        points[i] = (Point2D) auxPoints[i].clone();
      }

      //        	points.addAll(list);
      points[points.length - 1] = new Point2D.Double(x, y);
      Geometry spline = createSpline(points);
      ViewPort vp = getCadToolAdapter().getMapControl().getViewPort();
      DrawOperationContext doc = new DrawOperationContext();
      doc.setGraphics((Graphics2D) g);
      doc.setViewPort(vp);
      doc.setSymbol(DefaultCADTool.selectionSymbol);
      try {
        spline.invokeOperation(Draw.CODE, doc);
      } catch (GeometryOperationNotSupportedException e) {
        e.printStackTrace();
      } catch (GeometryOperationException e) {
        e.printStackTrace();
      }

      //        	spline.draw((Graphics2D)g,vp,DefaultCADTool.selectionSymbol);
    }
    VectorialLayerEdited vle = getVLE();
    if (!vle.getLayer().isVisible()) return;
    try {
      Image imgSel = vle.getSelectionImage();
      if (imgSel != null) g.drawImage(imgSel, 0, 0, null);
      Image imgHand = vle.getHandlersImage();
      if (imgHand != null) g.drawImage(imgHand, 0, 0, null);
    } catch (Exception e) {
    }
  }
Пример #5
0
 /** @see com.iver.andami.plugins.IExtension#isEnabled() */
 public boolean isEnabled() {
   DisposableIterator iterator = null;
   try {
     if (EditionUtilities.getEditionStatus()
         == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
       view = (View) PluginServices.getMDIManager().getActiveWindow();
       mapControl = view.getMapControl();
       EditionManager em = CADExtension.getEditionManager();
       if (em.getActiveLayerEdited() == null) {
         return false;
       }
       VectorialLayerEdited vle = (VectorialLayerEdited) em.getActiveLayerEdited();
       //				FLyrVect lv=(FLyrVect)vle.getLayer();
       if (((FeatureSelection) vle.getFeatureStore().getSelection()).getSize() < 1) {
         return false;
       }
       //				ArrayList selectedRows=vle.getSelectedRow();
       //				if (selectedRows.size()<1) {
       //					return false;
       //				}
       iterator = ((FeatureSelection) vle.getFeatureStore().getSelection()).iterator();
       if (iterator.hasNext()) {
         Feature feature = (Feature) iterator.next();
         if (feature.getDefaultGeometry() != null
             && exploit.isApplicable((feature.getDefaultGeometry()).getType())) {
           return true;
         }
       }
     }
   } catch (DataException e) {
     NotificationManager.addError(e.getMessage(), e);
   } finally {
     if (iterator != null) {
       iterator.dispose();
     }
   }
   return false;
 }