示例#1
0
 /** Creates the color choice for the given attribute. */
 protected JComboBox createColorChoice(String attribute) {
   CommandChoice choice = new CommandChoice();
   for (int i = 0; i < ColorMap.size(); i++)
     choice.addItem(
         new ChangeAttributeCommand(ColorMap.name(i), attribute, ColorMap.color(i), this));
   return choice;
 }
示例#2
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);
    }
  }
 /** Creates the color menu. */
 protected JMenu createColorMenu(String title, String attribute) {
   CommandMenu menu = new CommandMenu(title);
   for (int i = 0; i < ColorMap.size(); i++)
     menu.add(
         new UndoableCommand(
             new ChangeAttributeCommand(ColorMap.name(i), attribute, ColorMap.color(i), this)));
   return menu;
 }