コード例 #1
0
  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
          }
        });
  }
コード例 #2
0
 /** Called when the user presses Next on this panel */
 public void exitingToRight() throws Exception {
   mapParameterEditor.fillParameter(referenciaCatastral);
 }