Ejemplo n.º 1
0
  private void setupAttributes() {
    Color frameColor = (Color) AttributeFigure.getDefaultAttribute("FrameColor");
    Color fillColor = (Color) AttributeFigure.getDefaultAttribute("FillColor");
    Color textColor = (Color) AttributeFigure.getDefaultAttribute("TextColor");
    Integer arrowMode = (Integer) AttributeFigure.getDefaultAttribute("ArrowMode");
    String fontName = (String) AttributeFigure.getDefaultAttribute("FontName");

    FigureEnumeration k = view().selectionElements();
    while (k.hasMoreElements()) {
      Figure f = k.nextFigure();
      frameColor = (Color) f.getAttribute("FrameColor");
      fillColor = (Color) f.getAttribute("FillColor");
      textColor = (Color) f.getAttribute("TextColor");
      arrowMode = (Integer) f.getAttribute("ArrowMode");
      fontName = (String) f.getAttribute("FontName");
    }

    fFrameColor.setSelectedIndex(ColorMap.colorIndex(frameColor));
    fFillColor.setSelectedIndex(ColorMap.colorIndex(fillColor));
    // fTextColor.select(ColorMap.colorIndex(textColor));
    if (arrowMode != null) {
      fArrowChoice.setSelectedIndex(arrowMode.intValue());
    }
    if (fontName != null) {
      fFontChoice.setSelectedItem(fontName);
    }
  }
Ejemplo n.º 2
0
  /**
   * Creates the buttons shown in the buttons panel. Override to add additional buttons.
   *
   * @param panel the buttons panel.
   */
  protected void createButtons(JPanel panel) {
    panel.add(new Filler(24, 20));

    JComboBox drawingChoice = new JComboBox();
    drawingChoice.addItem(fgUntitled);

    String param = getParameter("DRAWINGS");
    if (param == null) {
      param = "";
    }
    StringTokenizer st = new StringTokenizer(param);
    while (st.hasMoreTokens()) {
      drawingChoice.addItem(st.nextToken());
    }
    // offer choice only if more than one
    if (drawingChoice.getItemCount() > 1) {
      panel.add(drawingChoice);
    } else {
      panel.add(new JLabel(fgUntitled));
    }

    drawingChoice.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              loadDrawing((String) e.getItem());
            }
          }
        });

    panel.add(new Filler(6, 20));

    JButton button;
    button = new CommandButton(new DeleteCommand("Delete", this));
    panel.add(button);

    button = new CommandButton(new DuplicateCommand("Duplicate", this));
    panel.add(button);

    button = new CommandButton(new GroupCommand("Group", this));
    panel.add(button);

    button = new CommandButton(new UngroupCommand("Ungroup", this));
    panel.add(button);

    button = new JButton("Help");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            showHelp();
          }
        });
    panel.add(button);

    fUpdateButton = new JButton("Simple Update");
    fUpdateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (fSimpleUpdate) {
              setBufferedDisplayUpdate();
            } else {
              setSimpleDisplayUpdate();
            }
          }
        });
  }