Пример #1
0
 public void createArc() {
   List<Point> points = drawingPane.getDrawObjectsAsGeoPoints();
   ApplicationContainer<?> appCont = digitizerModule.getApplicationContainer();
   if (points.size() >= 3) {
     try {
       Curve curve =
           GeometryUtils.calcCircleCoordinates(
               points.get(0).getPosition(),
               getRadius(),
               getNoOfVertices(),
               points.get(1).getPosition(),
               points.get(2).getPosition(),
               points.get(1).getCoordinateSystem());
       MapModel mapModel = appCont.getMapModel(null);
       Layer layer = mapModel.getLayersSelectedForAction(MapModel.SELECTION_EDITING).get(0);
       FeatureAdapter featureAdapter = (FeatureAdapter) layer.getDataAccess().get(0);
       FeatureType ft = featureAdapter.getSchema();
       Feature feat = featureAdapter.getDefaultFeature(ft.getName());
       feat = feat.cloneDeep();
       QualifiedName geomProperty = ft.getGeometryProperties()[0].getName();
       feat.getProperties(geomProperty)[0].setValue(curve);
       Command cmd = new InsertFeatureCommand(featureAdapter, feat);
       appCont.getCommandProcessor().executeSychronously(cmd, true);
     } catch (Exception ex) {
       LOG.logError(ex);
       DialogFactory.openErrorDialog(
           appCont.getViewPlatform(),
           DrawArcDialog.this,
           Messages.getMessage(getLocale(), "$MD11628"),
           Messages.getMessage(getLocale(), "$MD11629"),
           ex);
     }
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.deegree.igeo.modules.remotecontrol.RequestHandler#perform(java.util.Map,
   * org.deegree.igeo.ApplicationContainer)
   */
  public String perform(Map<String, String> paramater, ApplicationContainer<?> appContainer)
      throws ModuleException {
    String tmp = paramater.get("OBJECTIDS");
    if (tmp == null || tmp.length() == 0) {
      throw new ModuleException(Messages.get("$DG10091"));
    }
    List<String> objIds = StringTools.toList(tmp, ",;", true);
    tmp = paramater.get("LAYER");
    if (tmp == null) {
      throw new ModuleException(Messages.get("$DG10092"));
    }

    MapModel mapModel = appContainer.getMapModel(null);
    LocalMapModelVisitor mv = new LocalMapModelVisitor(tmp);
    try {
      mapModel.walkLayerTree(mv);
    } catch (Exception e) {
      LOG.logError(e.getMessage(), e);
      throw new ModuleException(e.getMessage());
    }

    Layer layer = mv.getResult();
    if (layer == null) {
      throw new ModuleException(Messages.get("$DG10093", tmp));
    }
    layer.setVisible(true);

    // first select features in layer
    List<Identifier> ids = new ArrayList<Identifier>();
    for (String id : objIds) {
      ids.add(new Identifier(id));
    }
    SelectFeatureCommand cmd = new SelectFeatureCommand(layer, ids, false);
    try {
      appContainer.getCommandProcessor().executeSychronously(cmd, true);
    } catch (Exception e) {
      LOG.logError(e.getMessage(), e);
      throw new ModuleException(e.getMessage());
    }

    // get selected features as FeatureCollection and so their common bounding box
    FeatureCollection fc = layer.getSelectedFeatures();
    if (fc.size() == 0) {
      throw new ModuleException(Messages.get("$DG10094", paramater.get("OBJECTIDS")));
    }
    Envelope env = null;
    try {
      env = fc.getBoundedBy();
      if (env.getWidth() < 0.0001) {
        // feature collection just contains one point; set fix bbox width/height
        // 25 map units
        env = env.getBuffer(25);
      }
    } catch (GeometryException e) {
      LOG.logError(e.getMessage(), e);
      throw new ModuleException(e.getMessage());
    }

    // zoom to common bounding box of selected features
    ZoomCommand zcmd = new ZoomCommand(mapModel);
    zcmd.setZoomBox(
        env,
        mapModel.getTargetDevice().getPixelWidth(),
        mapModel.getTargetDevice().getPixelHeight());
    if ("TRUE".equalsIgnoreCase(paramater.get("sync"))) {
      try {
        appContainer.getCommandProcessor().executeSychronously(zcmd, true);
      } catch (Exception e) {
        LOG.logError(e.getMessage(), e);
        throw new ModuleException(e.getMessage());
      }
    } else {
      appContainer.getCommandProcessor().executeASychronously(zcmd);
    }

    return "feature selected";
  }
Пример #3
0
 public String getInvalidMessage(String text) {
   return Messages.getMessage(Locale.getDefault(), "$MD10745", text);
 }
Пример #4
0
 public String getInvalidMessage(String text) {
   return Messages.getMessage(
       Locale.getDefault(), "$MD10766", text, dateFormatter.toLocalizedPattern());
 }
Пример #5
0
  private void initGUI() {
    try {
      {
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] {0.0, 0.1};
        thisLayout.rowHeights = new int[] {267, 7};
        thisLayout.columnWeights = new double[] {0.0, 0.1, 0.1};
        thisLayout.columnWidths = new int[] {154, 7, 7};
        getContentPane().setLayout(thisLayout);
        {
          pnButtons = new JPanel();
          FlowLayout pnButtonsLayout = new FlowLayout();
          pnButtonsLayout.setAlignment(FlowLayout.LEFT);
          pnButtons.setLayout(pnButtonsLayout);
          getContentPane()
              .add(
                  pnButtons,
                  new GridBagConstraints(
                      0,
                      1,
                      2,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 0),
                      0,
                      0));
          {
            btOK =
                new JButton(
                    Messages.getMessage(getLocale(), "$MD11617"),
                    IconRegistry.getIcon("accept.png"));
            pnButtons.add(btOK);
            btOK.addActionListener(
                new ActionListener() {

                  public void actionPerformed(ActionEvent e) {
                    createArc();
                    drawingPane.getDrawObjectsAsGeoPoints().clear();
                    digitizerModule.getMapModule().update();
                  }
                });
          }
          {
            btCancel =
                new JButton(
                    Messages.getMessage(getLocale(), "$MD11618"),
                    IconRegistry.getIcon("cancel.png"));
            pnButtons.add(btCancel);
            btCancel.addActionListener(
                new ActionListener() {

                  public void actionPerformed(ActionEvent e) {
                    dispose();
                  }
                });
          }
        }
        {
          pnHelp = new JPanel();
          FlowLayout pnHelpLayout = new FlowLayout();
          pnHelpLayout.setAlignment(FlowLayout.RIGHT);
          pnHelp.setLayout(pnHelpLayout);
          getContentPane()
              .add(
                  pnHelp,
                  new GridBagConstraints(
                      2,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 0),
                      0,
                      0));
          {
            btHelp =
                new JButton(
                    Messages.getMessage(getLocale(), "$MD11619"), IconRegistry.getIcon("help.png"));
            pnHelp.add(btHelp);
          }
        }
        {
          pnDescription = new JPanel();
          BorderLayout pnDescriptionLayout = new BorderLayout();
          pnDescription.setLayout(pnDescriptionLayout);
          getContentPane()
              .add(
                  pnDescription,
                  new GridBagConstraints(
                      0,
                      0,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 0),
                      0,
                      0));
          pnDescription.setBorder(
              BorderFactory.createTitledBorder(Messages.getMessage(getLocale(), "$MD11620")));
          {
            tpDescription = new JTextPane();
            pnDescription.add(tpDescription, BorderLayout.CENTER);
            tpDescription.setBackground(pnDescription.getBackground());
            tpDescription.setEditable(false);
            tpDescription.setContentType("text/html");
            tpDescription.setText(Messages.getMessage(getLocale(), "$MD11621"));
          }
        }
        {
          pnControl = new JPanel();
          GridBagLayout pnControlLayout = new GridBagLayout();
          getContentPane()
              .add(
                  pnControl,
                  new GridBagConstraints(
                      1,
                      0,
                      2,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 0),
                      0,
                      0));
          pnControl.setBorder(
              BorderFactory.createTitledBorder(Messages.getMessage(getLocale(), "$MD11622")));
          pnControlLayout.rowWeights = new double[] {0.0, 0.0, 0.1};
          pnControlLayout.rowHeights = new int[] {63, 109, 20};
          pnControlLayout.columnWeights = new double[] {0.1};
          pnControlLayout.columnWidths = new int[] {7};
          pnControl.setLayout(pnControlLayout);
          {
            pnArc = new JPanel();
            GridBagLayout pnArcLayout = new GridBagLayout();
            pnControl.add(
                pnArc,
                new GridBagConstraints(
                    0,
                    0,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0),
                    0,
                    0));
            pnArc.setBorder(
                BorderFactory.createTitledBorder(Messages.getMessage(getLocale(), "$MD11623")));
            pnArcLayout.rowWeights = new double[] {0.1};
            pnArcLayout.rowHeights = new int[] {7};
            pnArcLayout.columnWeights = new double[] {0.1};
            pnArcLayout.columnWidths = new int[] {7};
            pnArc.setLayout(pnArcLayout);
            {
              spArc = new JSpinner(new SpinnerNumberModel(0, -181, 181, 0.5));
              pnArc.add(
                  spArc,
                  new GridBagConstraints(
                      0,
                      0,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.HORIZONTAL,
                      new Insets(0, 9, 0, 9),
                      0,
                      0));
              spArc.addChangeListener(
                  new ChangeListener() {

                    public void stateChanged(ChangeEvent e) {
                      applyArc();
                    }
                  });
            }
          }
          {
            pnRadius = new JPanel();
            GridBagLayout pnRadiusLayout = new GridBagLayout();
            pnControl.add(
                pnRadius,
                new GridBagConstraints(
                    0,
                    1,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0),
                    0,
                    0));
            pnRadius.setBorder(
                BorderFactory.createTitledBorder(Messages.getMessage(getLocale(), "$MD11624")));
            pnRadiusLayout.rowWeights = new double[] {0.0, 0.1};
            pnRadiusLayout.rowHeights = new int[] {43, 20};
            pnRadiusLayout.columnWeights = new double[] {0.1};
            pnRadiusLayout.columnWidths = new int[] {7};
            pnRadius.setLayout(pnRadiusLayout);
            {
              spArcRadius = new JSpinner(new SpinnerNumberModel(1d, 0.0001, 999999999, 0.5));
              pnRadius.add(
                  spArcRadius,
                  new GridBagConstraints(
                      0,
                      0,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.HORIZONTAL,
                      new Insets(0, 9, 0, 9),
                      0,
                      0));
              spArcRadius.addChangeListener(
                  new ChangeListener() {

                    public void stateChanged(ChangeEvent e) {
                      applyRadius();
                    }
                  });
            }
            {
              pnUOM = new JPanel();
              FlowLayout pnUOMLayout = new FlowLayout();
              pnUOMLayout.setAlignment(FlowLayout.LEFT);
              pnUOMLayout.setHgap(9);
              pnUOMLayout.setVgap(10);
              pnUOM.setLayout(pnUOMLayout);
              pnRadius.add(
                  pnUOM,
                  new GridBagConstraints(
                      0,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 0),
                      0,
                      0));
              {
                lbUOM = new JLabel(Messages.getMessage(getLocale(), "$MD11625"));
                pnUOM.add(lbUOM);
                lbUOM.setPreferredSize(new Dimension(102, 16));
              }
              {
                String tmp = Messages.getMessage(getLocale(), "$MD11626");
                cbUOM = new JComboBox(new DefaultComboBoxModel(tmp.split(",")));
                pnUOM.add(cbUOM);
                cbUOM.setPreferredSize(new Dimension(136, 22));
              }
            }
          }
          {
            pnRotation = new JPanel();
            GridBagLayout pnRotationLayout = new GridBagLayout();
            pnControl.add(
                pnRotation,
                new GridBagConstraints(
                    0,
                    2,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(
                        0, 0,
                        0, 0),
                    0,
                    0));
            pnRotation.setBorder(
                BorderFactory.createTitledBorder(Messages.getMessage(getLocale(), "$MD11627")));
            pnRotationLayout.rowWeights = new double[] {0.1};
            pnRotationLayout.rowHeights = new int[] {7};
            pnRotationLayout.columnWeights = new double[] {0.1};
            pnRotationLayout.columnWidths = new int[] {7};
            pnRotation.setLayout(pnRotationLayout);
            {
              spNoOfVertices = new JSpinner(new SpinnerNumberModel(10, 5, 1000, 1));
              pnRotation.add(
                  spNoOfVertices,
                  new GridBagConstraints(
                      0,
                      0,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.HORIZONTAL,
                      new Insets(0, 9, 0, 9),
                      0,
                      0));
            }
          }
        }
      }
      this.setSize(457, 339);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }