예제 #1
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   dlg.panelMain.mark.setObject(Obj.UNKOBJ);
   dlg.panelMain.mark.setCategory(Cat.NOCAT);
   dlg.panelMain.mark.setTopmark(Top.NOTOP);
   if (mooringButton.isSelected()) {
     dlg.panelMain.mark.setObject(Obj.MORFAC);
     categoryBox.setVisible(false);
     mooringBox.setVisible(true);
     pillarButton.setEnabled(false);
     sparButton.setEnabled(false);
     beaconButton.setEnabled(false);
     towerButton.setEnabled(false);
     stakeButton.setEnabled(false);
     cairnButton.setEnabled(false);
     mooringButton.setBorderPainted(true);
   } else {
     mooringBox.setVisible(false);
     categoryBox.setVisible(true);
     pillarButton.setEnabled(true);
     sparButton.setEnabled(true);
     beaconButton.setEnabled(true);
     towerButton.setEnabled(true);
     stakeButton.setEnabled(true);
     cairnButton.setEnabled(true);
     mooringButton.setBorderPainted(false);
   }
   syncPanel();
 }
예제 #2
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   dlg.panelMain.mark.clrMark();
   if (noticeButton.isSelected()) {
     dlg.panelMain.mark.setObject(Obj.NOTMRK);
     noticeButton.setBorderPainted(true);
   } else {
     dlg.panelMain.mark.setObject(Obj.UNKOBJ);
     noticeButton.setBorderPainted(false);
   }
   dlg.panelMain.syncPanel();
 }
예제 #3
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   if (topmarkButton.isSelected()) {
     dlg.panelMain.mark.setTopmark(Top.X_SHAPE);
     dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     dlg.panelMain.mark.setTopColour(Col.YELLOW);
     topmarkButton.setBorderPainted(true);
   } else {
     dlg.panelMain.mark.setTopmark(Top.NOTOP);
     dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     dlg.panelMain.mark.setTopColour(Col.UNKCOL);
     topmarkButton.setBorderPainted(false);
   }
   dlg.panelMain.panelTop.syncPanel();
 }
예제 #4
0
 public void syncPanel() {
   if (SeaMark.EntMAP.get(dlg.panelMain.mark.getObject()) == Ent.MOORING) {
     mooringButton.setBorderPainted(true);
     categoryBox.setVisible(false);
     mooringBox.setVisible(true);
     pillarButton.setEnabled(false);
     sparButton.setEnabled(false);
     beaconButton.setEnabled(false);
     towerButton.setEnabled(false);
     stakeButton.setEnabled(false);
     cairnButton.setEnabled(false);
     noticeButton.setEnabled(false);
     topmarkButton.setVisible(false);
     for (Cat cat : moorings.keySet()) {
       int item = moorings.get(cat);
       if (dlg.panelMain.mark.getCategory() == cat) mooringBox.setSelectedIndex(item);
     }
   } else {
     mooringButton.setBorderPainted(false);
     mooringBox.setVisible(false);
     categoryBox.setVisible(true);
     pillarButton.setEnabled(true);
     sparButton.setEnabled(true);
     beaconButton.setEnabled(true);
     towerButton.setEnabled(true);
     stakeButton.setEnabled(true);
     cairnButton.setEnabled(true);
     noticeButton.setEnabled(true);
     topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     topmarkButton.setVisible(dlg.panelMain.mark.testValid());
     for (Cat cat : categories.keySet()) {
       int item = categories.get(cat);
       if (dlg.panelMain.mark.getCategory() == cat) categoryBox.setSelectedIndex(item);
     }
   }
   for (Shp shp : shapes.keySet()) {
     JRadioButton button = shapes.get(shp);
     if (dlg.panelMain.mark.getShape() == shp) {
       button.setBorderPainted(true);
     } else button.setBorderPainted(false);
   }
   noticeButton.setBorderPainted(false);
   dlg.panelMain.mark.testValid();
 }
  private void configure() {
    fRotation = LEFT;

    fButtonDelegate =
        new JToggleButton() {
          public String getText() {
            return null;
          }

          public boolean isEnabled() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isEnabled();
            }
            return super.isEnabled();
          }

          public boolean isSelected() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isSelected();
            }
            return super.isSelected();
          }

          public boolean isFocusPainted() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isFocusPainted();
            }
            return super.isFocusPainted();
          }

          public boolean isContentAreaFilled() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isContentAreaFilled();
            }
            return super.isContentAreaFilled();
          }

          public boolean isBorderPainted() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isBorderPainted();
            }
            return super.isBorderPainted();
          }

          public Border getBorder() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getBorder();
            }
            return super.getBorder();
          }

          public boolean isOpaque() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isOpaque();
            }
            return super.isOpaque();
          }

          public Color getBackground() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getBackground();
            }
            return super.getBackground();
          }

          public Icon getIcon() {
            return null;
          }

          public Icon getPressedIcon() {
            return null;
          }

          public Icon getSelectedIcon() {
            return null;
          }

          public Icon getRolloverIcon() {
            return null;
          }

          public Icon getRolloverSelectedIcon() {
            return null;
          }

          public Icon getDisabledIcon() {
            return null;
          }
        };

    fLabelDelegate =
        new JLabel() {
          public String getText() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getText();
            }
            return super.getText();
          }

          public Color getForeground() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getForeground();
            }
            return super.getForeground();
          }

          public boolean isEnabled() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.isEnabled();
            }
            return super.isEnabled();
          }

          public int getIconTextGap() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getIconTextGap();
            }
            return super.getIconTextGap();
          }

          public int getVerticalAlignment() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getVerticalAlignment();
            }
            return super.getVerticalAlignment();
          }

          public int getVerticalTextPosition() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getVerticalTextPosition();
            }
            return super.getVerticalTextPosition();
          }

          public int getHorizontalAlignment() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getHorizontalAlignment();
            }
            return super.getHorizontalAlignment();
          }

          public int getHorizontalTextPosition() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getHorizontalTextPosition();
            }
            return super.getHorizontalTextPosition();
          }

          public Border getBorder() {
            return null;
          }

          public int getMnemonic() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getMnemonic();
            }
            return -1;
          }

          public int getDisplayedMnemonicIndex() {
            if (JVerticalToggleButton.this != null) {
              return JVerticalToggleButton.this.getDisplayedMnemonicIndex();
            }
            return super.getDisplayedMnemonicIndex();
          }

          private Insets insets = new Insets(0, 0, 0, 0);

          public Insets getInsets() {
            if (JVerticalToggleButton.this != null) {
              return super.getInsets();
            }

            Border b = JVerticalToggleButton.this.getBorder();

            Insets minsets = JVerticalToggleButton.this.getMargin();

            insets.left = minsets.left;
            insets.top = minsets.top;
            insets.right = minsets.right;
            insets.bottom = minsets.bottom;

            if (b != null) {
              Insets binsets = b.getBorderInsets(JVerticalToggleButton.this);
              insets.left += binsets.left;
              insets.top += binsets.top;
              insets.right += binsets.right;
              insets.bottom += binsets.bottom;
            }

            return insets;
          }

          public Icon getIcon() {
            if (JVerticalToggleButton.this != null) {
              return super.getIcon();
            }

            ButtonModel model = JVerticalToggleButton.this.getModel();
            Icon subIcon = null;

            if (!model.isEnabled()) {
              if (model.isSelected()) {
                subIcon = getDisabledSelectedIcon();
              } else {
                subIcon = getDisabledIcon();
              }
            } else if (model.isPressed() && model.isArmed()) {
              subIcon = getPressedIcon();
            } else if (isRolloverEnabled() && model.isRollover()) {
              if (model.isSelected()) {
                subIcon = getRolloverSelectedIcon();
              } else {
                subIcon = getRolloverIcon();
              }
            } else if (model.isSelected()) {
              subIcon = getSelectedIcon();
            }

            if (subIcon == null) subIcon = JVerticalToggleButton.this.getIcon();

            return subIcon;
          }

          public Icon getDisabledIcon() {
            return JVerticalToggleButton.this.getDisabledIcon();
          }
        };

    fLabelDelegate.setOpaque(false);

    // we paint our own border
    fButtonDelegate.setBorderPainted(false);
    fButtonDelegate.setModel(getModel());

    fRenderer = new CellRendererPane();
    fRenderer.add(fButtonDelegate);
    fRenderer.add(fLabelDelegate);

    fPreferredSize = new Dimension();
    fMinimumSize = new Dimension();
    fMaximumSize = new Dimension();

    Action action = getAction();
    if (action != null) {
      fButtonDelegate.setAction(action);
    }
  }