Пример #1
0
  protected boolean refreshFeatureSelection(String layerName, String id) {

    try {
      if (id == null || geopistaEditor == null) return false;
      this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      geopistaEditor.getSelectionManager().clear();
      GeopistaLayer geopistaLayer =
          (GeopistaLayer) geopistaEditor.getLayerManager().getLayer(layerName);
      Collection collection = searchByAttribute(geopistaLayer, 0, id);
      Iterator it = collection.iterator();
      if (it.hasNext()) {
        Feature feature = (Feature) it.next();
        geopistaEditor.select(geopistaLayer, feature);
      }
      geopistaEditor.zoomToSelected();
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      return true;
    } catch (Exception ex) {
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
      return false;
    }
  }
Пример #2
0
  private void addFixedPlugins() {

    try {
      GeopistaEditor editor = inventarioInternalFrame.getJPanelMap().getGeopistaEditor();
      WorkbenchToolBar newToolBar =
          editor.addToolbar(aplicacion.getString("MunicipalitiesPlugIn.category"));

      /*String pluginName="com.geopista.ui.plugin.MunicipalitiesPlugIn";
      PlugIn cargandoPlugin = (PlugIn) (Class.forName(pluginName)).newInstance();

      ((com.geopista.ui.plugin.MunicipalitiesPlugIn)cargandoPlugin).initialize(
      		new PlugInContext(editor.getContext(),
      							editor.getTask(),
      							editor ,
      							editor.getLayerNamePanel(),
      							editor.getLayerViewPanel()),newToolBar);
      */
      /*newToolBar.addCursorTool("Zoom In/Out", (CursorTool)(Class.forName("com.vividsolutions.jump.workbench.ui.zoom.ZoomTool")).newInstance() );
      for (int i=1;i<10;i++){
      	newToolBar.addCursorTool("Zoom In/Out"+i, (CursorTool)(Class.forName("com.vividsolutions.jump.workbench.ui.zoom.ZoomTool")).newInstance() );
      }*/

      editor.addPlugIn("com.geopista.ui.plugin.MunicipalitiesPlugIn");
      ((JPanel) editor.getToolBar().getParent()).setLayout(new GridLayout(2, 1));
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 protected void enteredPanelFromLeft(Map dataMap) {
   try {
     if (!mapLoaded) {
       geopistaEditor.loadMap(appContext.getString("url.mapa.catastro"));
       GeopistaLayer layerParcelas =
           (GeopistaLayer) geopistaEditor.getLayerManager().getLayer("parcelas");
       layerParcelas.setActiva(true);
       mapLoaded = true;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #4
0
  protected String refreshListSelection(String layerName) {
    try {

      Collection collection = geopistaEditor.getSelection();
      if (collection.iterator().hasNext()) {
        GeopistaFeature feature = (GeopistaFeature) collection.iterator().next();
        if (feature == null) {
          logger.error("feature: " + feature);
          return null;
        }

        if (layerName != null && feature.getLayer() != null) {
          if (!layerName.equals(feature.getLayer().getName())) return null;
        }
        // String id = checkNull(feature.getAttribute(0));
        String id = checkNull(feature.getSystemId());
        logger.info("id: -" + id + "-");
        return id;
      }
    } catch (Exception ex) {

      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
      return null;
    }
    return null;
  }
 public boolean isInputValid() {
   Collection lista = null;
   lista =
       geopistaEditor
           .getLayerViewPanel()
           .getSelectionManager()
           .getFeaturesWithSelectedItems(geopistaEditor.getLayerManager().getLayer("parcelas"));
   if (lista.size() == 1) {
     if (reportWizard.acceso()) {
       return true;
     } else {
       return false;
     }
   } else {
     return false;
   }
 }
Пример #6
0
  public boolean refreshBusquedaSelection(JInternalFrame frame, GeopistaEditor geopistaEditor) {

    try {

      frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      geopistaEditor.getSelectionManager().clear();

      GeopistaLayer geopistaLayer =
          (GeopistaLayer) geopistaEditor.getLayerManager().getLayer(layerBusqueda);

      Enumeration enumerationElement = valoresBusqueda.keys();

      while (enumerationElement.hasMoreElements()) {
        String referenciaCatastral = (String) enumerationElement.nextElement();
        // El numero 1 identifica el id numero de policia
        Collection collection = searchByAttribute(geopistaLayer, 1, referenciaCatastral);
        Iterator it = collection.iterator();
        if (it.hasNext()) {
          Feature feature = (Feature) it.next();
          geopistaEditor.select(geopistaLayer, feature);
        }
      }

      geopistaEditor.zoomToSelected();
      frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      return true;
    } catch (Exception ex) {

      frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
      return false;
    }
  }
  protected void initForm() throws Exception {
    BorderLayout borderLayout = new BorderLayout();
    pnlGeneral.setLayout(borderLayout);

    JPanel panelTitle = new JPanel();
    FlowLayout flowLayoutTitle = new FlowLayout();
    flowLayoutTitle.setAlignment(FlowLayout.LEFT);
    panelTitle.setLayout(flowLayoutTitle);
    pnlGeneral.add(panelTitle, BorderLayout.NORTH);

    lblSeleccioneParcela = new JLabel();
    Font fontSeleccioneParcela = lblSeleccioneParcela.getFont();
    fontSeleccioneParcela =
        fontSeleccioneParcela.deriveFont(fontSeleccioneParcela.getStyle() ^ Font.BOLD);
    lblSeleccioneParcela.setFont(fontSeleccioneParcela);
    panelTitle.add(lblSeleccioneParcela);
    String text = appContext.getI18nString("informes.wizard.seleccionparcela.seleccioneparcela");
    if (mapParameterEditor.getParameter().getDescription() != null
        && mapParameterEditor.getParameter().getDescription().length() > 0) {
      text += " " + mapParameterEditor.getParameter().getDescription();
    } else {
      text += " " + mapParameterEditor.getParameter().getName();
    }
    lblSeleccioneParcela.setText(text);

    geopistaEditor = new GeopistaEditor(appContext.getString("fichero.vacio"));
    geopistaEditor.showLayerName(false);
    geopistaEditor.addCursorTool(
        "Zoom In/Out", "com.vividsolutions.jump.workbench.ui.zoom.ZoomTool");
    geopistaEditor.addCursorTool("Pan", "com.vividsolutions.jump.workbench.ui.zoom.PanTool");
    geopistaEditor.addCursorTool(
        "Select tool", "com.geopista.ui.cursortool.GeopistaSelectFeaturesTool");
    pnlGeneral.add(geopistaEditor, BorderLayout.CENTER);

    JPanel panelInfoParcela = new JPanel();
    GridLayout gridLayoutInfoParcela = new GridLayout(2, 1);
    panelInfoParcela.setLayout(gridLayoutInfoParcela);
    pnlGeneral.add(panelInfoParcela, BorderLayout.SOUTH);

    GridBagLayout pnlRusticoGridBagLayout = new GridBagLayout();
    pnlRustico.setBorder(
        BorderFactory.createTitledBorder(appContext.getI18nString("parcelas.rustica")));
    pnlRustico.setLayout(pnlRusticoGridBagLayout);
    panelInfoParcela.add(pnlRustico);

    Insets insets = new Insets(0, 5, 5, 0);
    GridBagConstraints gridBagConstraints;
    lblParcelaRustico.setText(appContext.getI18nString("informe.patrimonio.inventario.parcela"));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = insets;
    pnlRustico.add(lblParcelaRustico, gridBagConstraints);

    txtParcelaRustico.setBounds(new Rectangle(360, 15, 185, 20));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 3.0;
    gridBagConstraints.insets = insets;
    pnlRustico.add(txtParcelaRustico, gridBagConstraints);

    lblPoligonoRustico.setText(appContext.getI18nString("texto.poligono"));
    lblPoligonoRustico.setBounds(new Rectangle(10, 15, 65, 20));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = insets;
    pnlRustico.add(lblPoligonoRustico, gridBagConstraints);

    txtPoligonoRustico.setHorizontalAlignment(JTextField.RIGHT);
    txtPoligonoRustico.setText("");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 3.0;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagConstraints.insets = insets;
    pnlRustico.add(txtPoligonoRustico, gridBagConstraints);

    GridBagLayout pnlUrbanoGridBagLayout = new GridBagLayout();
    pnlUrbano.setBorder(
        BorderFactory.createTitledBorder(appContext.getI18nString("parcelas.urabana")));
    pnlUrbano.setLayout(pnlUrbanoGridBagLayout);
    panelInfoParcela.add(pnlUrbano);

    lblParcelaUrbano.setText(appContext.getI18nString("informe.patrimonio.inventario.parcela"));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = insets;
    pnlUrbano.add(lblParcelaUrbano, gridBagConstraints);

    txtParcelaUrbano.setHorizontalAlignment(JTextField.RIGHT);
    txtParcelaUrbano.setText("");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 3.0;
    gridBagConstraints.insets = insets;
    pnlUrbano.add(txtParcelaUrbano, gridBagConstraints);

    lblPoligonoUrbano.setText(appContext.getI18nString("texto.manzana"));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = insets;
    pnlUrbano.add(lblPoligonoUrbano, gridBagConstraints);

    txtPoligonoUrbano.setHorizontalAlignment(JTextField.RIGHT);
    txtPoligonoUrbano.setText("");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 3.0;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagConstraints.insets = insets;
    pnlUrbano.add(txtPoligonoUrbano, gridBagConstraints);

    geopistaEditor.addGeopistaListener(
        new GeopistaListener() {

          public void selectionChanged(IAbstractSelection abtractSelection) {

            // Capturamos la parcela y la manzana del gml
            try {
              ArrayList featuresCollection =
                  (ArrayList)
                      abtractSelection.getFeaturesWithSelectedItems(
                          geopistaEditor.getLayerManager().getLayer("parcelas"));
              Iterator featuresCollectionIter = featuresCollection.iterator();
              if (!featuresCollectionIter.hasNext()) return;
              Feature actualFeature = (Feature) featuresCollectionIter.next();

              // Tabla ambitos_gestion:
              geopistaEditor.zoomTo(actualFeature);
              getWizardContext().inputChanged();

              // Recuperar el valor del tipo y colocarlo en su parcela corresondiente
              referenciaCatastral = actualFeature.getString(2); // La Referencia Catastral				
              String codigoParcela = actualFeature.getString(5);
              String codigoPoligono = actualFeature.getString(6);
              String idVia = actualFeature.getString(7);

              if (!idVia.equals("") && (!codigoPoligono.equals("") || !codigoParcela.equals(""))) {
                txtPoligonoUrbano.setText(referenciaCatastral.substring(0, 5));
                txtParcelaUrbano.setText(referenciaCatastral.substring(5, 7));
                txtParcelaRustico.setText("");
                txtPoligonoRustico.setText("");
              } else if (!codigoPoligono.equals("") || !codigoParcela.equals("")) {
                txtPoligonoUrbano.setText("");
                txtParcelaUrbano.setText("");
                txtParcelaRustico.setText(codigoParcela);
                txtPoligonoRustico.setText(codigoPoligono);
              } else if (!idVia.equals("")) {
                txtPoligonoUrbano.setText(referenciaCatastral.substring(0, 5));
                txtParcelaUrbano.setText(referenciaCatastral.substring(5, 7));
                txtParcelaRustico.setText("");
                txtPoligonoRustico.setText("");
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }

          public void featureAdded(FeatureEvent e) {
            // No hacer nada
          }

          public void featureRemoved(FeatureEvent e) {
            // No hacer nada
          }

          public void featureModified(FeatureEvent e) {
            // No hacer nada
          }

          public void featureActioned(IAbstractSelection abtractSelection) {
            // No hacer nada
          }
        });
  }