コード例 #1
0
ファイル: DTEDLayer.java プロジェクト: jrecursive/passage
  /** Creates the interface palette. */
  public java.awt.Component getGUI() {

    if (paletteBox == null) {
      if (Debug.debugging("dted")) Debug.output("DTEDLayer: creating DTED Palette.");

      paletteBox = Box.createVerticalBox();
      Box subbox1 = Box.createHorizontalBox();
      Box subbox2 = Box.createVerticalBox();
      Box subbox3 = Box.createHorizontalBox();

      // palette = new JPanel();
      // palette.setLayout(new GridLayout(0, 1));

      // The DTED Level selector
      JPanel levelPanel = PaletteHelper.createPaletteJPanel("DTED Level");
      ButtonGroup levels = new ButtonGroup();

      ActionListener al =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (cache != null) {
                String ac = e.getActionCommand();
                int newLevel;
                if (ac.equalsIgnoreCase(level2Command)) newLevel = DTEDFrameSubframe.LEVEL_2;
                else if (ac.equalsIgnoreCase(level1Command)) newLevel = DTEDFrameSubframe.LEVEL_1;
                else newLevel = DTEDFrameSubframe.LEVEL_0;
                DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
                dfsi.dtedLevel = newLevel;
                // cache.setSubframeInfo(dfsi);
              }
            }
          };

      JRadioButton level0 = new JRadioButton("Level 0");
      level0.addActionListener(al);
      level0.setActionCommand(level0Command);
      JRadioButton level1 = new JRadioButton("Level 1");
      level1.addActionListener(al);
      level1.setActionCommand(level1Command);
      JRadioButton level2 = new JRadioButton("Level 2");
      level2.addActionListener(al);
      level2.setActionCommand(level2Command);

      levels.add(level0);
      levels.add(level1);
      levels.add(level2);

      switch (dtedLevel) {
        case 2:
          level2.setSelected(true);
          break;
        case 1:
          level1.setSelected(true);
          break;
        case 0:
        default:
          level0.setSelected(true);
      }

      levelPanel.add(level0);
      levelPanel.add(level1);
      levelPanel.add(level2);

      // The DTED view selector
      JPanel viewPanel = PaletteHelper.createPaletteJPanel("View Type");
      String[] viewStrings = {
        "None", "Shading", "Elevation Shading", "Elevation Bands (Meters)", "Elevation Bands (Feet)"
      };

      JComboBox viewList = new JComboBox(viewStrings);
      viewList.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              JComboBox jcb = (JComboBox) e.getSource();
              int newView = jcb.getSelectedIndex();
              switch (newView) {
                case 0:
                  viewType = DTEDFrameSubframe.NOSHADING;
                  break;
                case 1:
                  viewType = DTEDFrameSubframe.SLOPESHADING;
                  break;
                case 2:
                  viewType = DTEDFrameSubframe.COLOREDSHADING;
                  break;
                case 3:
                  viewType = DTEDFrameSubframe.METERSHADING;
                  break;
                case 4:
                  viewType = DTEDFrameSubframe.FEETSHADING;
                  break;
                default:
                  viewType = DTEDFrameSubframe.NOSHADING;
              }
              if (cache != null) {
                DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
                dfsi.viewType = viewType;
                // cache.setSubframeInfo(dfsi);
              }
            }
          });
      int selectedView;
      switch (viewType) {
        case 0:
        case 1:
          selectedView = viewType;
          break;
        case 2:
        case 3:
          selectedView = viewType + 1;
          break;
        case 4:
          // This puts the layer in testing mode, and the menu
          // changes.
          String[] viewStrings2 = {
            "None",
            "Shading",
            "Elevation Bands (Meters)",
            "Elevation Bands (Feet)",
            "Subframe Testing",
            "Elevation Shading"
          };
          viewList = new JComboBox(viewStrings2);
          viewList.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  JComboBox jcb = (JComboBox) e.getSource();
                  int newView = jcb.getSelectedIndex();
                  if (cache != null) {
                    DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
                    dfsi.viewType = newView;
                    // cache.setSubframeInfo(dfsi);
                  }
                }
              });
          selectedView = viewType;
          break;
        case 5:
          selectedView = 2; // DTEDFrameSubframe.COLOREDSHADING
          break;
        default:
          selectedView = DTEDFrameSubframe.NOSHADING;
      }

      viewList.setSelectedIndex(selectedView);
      viewPanel.add(viewList);

      // The DTED Contrast Adjuster
      JPanel contrastPanel = PaletteHelper.createPaletteJPanel("Contrast Adjustment");
      JSlider contrastSlide =
          new JSlider(JSlider.HORIZONTAL, 1 /* min */, 5 /* max */, slopeAdjust /* initial */);
      java.util.Hashtable<Integer, JLabel> dict = new java.util.Hashtable<Integer, JLabel>();
      dict.put(new Integer(1), new JLabel("min"));
      dict.put(new Integer(5), new JLabel("max"));
      contrastSlide.setLabelTable(dict);
      contrastSlide.setPaintLabels(true);
      contrastSlide.setMajorTickSpacing(1);
      contrastSlide.setPaintTicks(true);
      contrastSlide.setSnapToTicks(true);
      contrastSlide.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent ce) {
              JSlider slider = (JSlider) ce.getSource();
              if (slider.getValueIsAdjusting()) {
                fireRequestInfoLine(getName() + " - Contrast Slider value = " + slider.getValue());
                slopeAdjust = slider.getValue();
                if (cache != null) {
                  DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
                  dfsi.slopeAdjust = slopeAdjust;
                  // cache.setSubframeInfo(dfsi);
                }
              }
            }
          });
      contrastPanel.add(contrastSlide);

      // The DTED Band Height Adjuster
      JPanel bandPanel = PaletteHelper.createPaletteJPanel("Band Elevation Spacing");
      JSlider bandSlide =
          new JSlider(JSlider.HORIZONTAL, 0 /* min */, 1000 /* max */, bandHeight /* initial */);
      bandSlide.setLabelTable(bandSlide.createStandardLabels(250));
      bandSlide.setPaintLabels(true);
      bandSlide.setMajorTickSpacing(250);
      bandSlide.setMinorTickSpacing(50);
      bandSlide.setPaintTicks(true);
      bandSlide.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent ce) {
              JSlider slider = (JSlider) ce.getSource();
              if (slider.getValueIsAdjusting()) {
                fireRequestInfoLine(getName() + " - Band Slider value = " + slider.getValue());
                bandHeight = slider.getValue();
                if (cache != null) {
                  DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
                  dfsi.bandHeight = bandHeight;
                  // cache.setSubframeInfo(dfsi);
                }
              }
            }
          });

      bandPanel.add(bandSlide);

      JButton redraw = new JButton("Redraw DTED Layer");
      redraw.setActionCommand(RedrawCmd);
      redraw.addActionListener(this);

      subbox1.add(levelPanel);
      subbox1.add(viewPanel);
      paletteBox.add(subbox1);
      subbox2.add(contrastPanel);
      subbox2.add(bandPanel);
      paletteBox.add(subbox2);
      subbox3.add(redraw);
      paletteBox.add(subbox3);
    }

    return paletteBox;
  }
コード例 #2
0
  public JComponent getPolyGUI(
      boolean includeEnclose,
      boolean includeExt,
      boolean includeAdd,
      boolean includeDelete,
      int orientation,
      JComponent buttonBox) {

    if (buttonBox == null) {
      buttonBox = new GridBagToolBar();
      ((GridBagToolBar) buttonBox).setOrientation(orientation);
    }

    buttonBox.add(PaletteHelper.getToolBarFill(orientation));

    URL url;
    ImageIcon imageIcon;
    if (polygonButton == null) {
      url = getImageURL("enclosepoly.gif");
      imageIcon = new ImageIcon(url);
      polygonButton = new JToggleButton(imageIcon);
      polygonButton.setToolTipText(
          i18n.get(
              EditableOMPoly.class,
              "polygonButton.tooltip",
              "Automatically link first and last nodes"));

      polygonButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (getStateMachine().getState() instanceof GraphicSelectedState) {
                enclose(((JToggleButton) e.getSource()).isSelected());
              } else {
                setEnclosed(((JToggleButton) e.getSource()).isSelected());
              }
              updateCurrentState(null);
            }
          });
    }

    polygonButton.setSelected(isEnclosed());

    if (includeEnclose) {
      buttonBox.add(polygonButton);
    }

    if (extButton == null) {
      url = getImageURL("addpoint.gif");
      imageIcon = new ImageIcon(url);
      extButton = new JButton(imageIcon);
      extButton.setToolTipText(
          i18n.get(EditableOMPoly.class, "extButton.tooltip", "Add a point to the polygon"));
      extButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              // If an enclosed poly is having nodes added to it, we need
              // to
              // remove the connection, but make a note to reconnect after
              // editing.
              if (isEnclosed()) {
                enclose(false);
                setEnclosed(true);
              }
              ((PolyStateMachine) stateMachine).setAddPoint();
              enablePolygonEditButtons(false);
            }
          });
    }

    extButton.setEnabled(false);
    if (includeExt) {
      buttonBox.add(extButton);
    }

    if (addButton == null) {
      url = getImageURL("addnode.gif");
      imageIcon = new ImageIcon(url);
      addButton = new JButton(imageIcon);
      addButton.setToolTipText(
          i18n.get(EditableOMPoly.class, "addButton.tooltip", "Add a node to the polygon"));
      addButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              ((PolyStateMachine) stateMachine).setAddNode();
              enablePolygonEditButtons(false);
            }
          });
    }

    addButton.setEnabled(false);
    if (includeAdd) {
      buttonBox.add(addButton);
    }

    if (deleteButton == null) {
      url = getImageURL("deletepoint.gif");
      imageIcon = new ImageIcon(url);
      deleteButton = new JButton(imageIcon);
      deleteButton.setToolTipText(
          i18n.get(EditableOMPoly.class, "deleteButton.tooltip", "Delete a node from the polygon"));
      deleteButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              ((PolyStateMachine) stateMachine).setDeleteNode();
              enablePolygonEditButtons(false);
            }
          });
    }

    deleteButton.setEnabled(false);
    if (includeDelete) {
      buttonBox.add(deleteButton);
    }

    return buttonBox;
  }