Exemplo n.º 1
0
 protected void createAttributeChoices(JPanel panel) {
   panel.add(new JLabel("Fill"));
   fFillColor = createColorChoice(FigureAttributeConstant.FILL_COLOR);
   panel.add(fFillColor);
   panel.add(new JLabel("Text"));
   fTextColor = createColorChoice(FigureAttributeConstant.TEXT_COLOR);
   panel.add(fTextColor);
   panel.add(new JLabel("Pen"));
   fFrameColor = createColorChoice(FigureAttributeConstant.FRAME_COLOR);
   panel.add(fFrameColor);
   panel.add(new JLabel("Arrow"));
   CommandChoice choice = new CommandChoice();
   fArrowChoice = choice;
   FigureAttributeConstant arrowMode = FigureAttributeConstant.ARROW_MODE;
   choice.addItem(
       new ChangeAttributeCommand(
           "none", arrowMode, new Integer(PolyLineFigure.ARROW_TIP_NONE), this));
   choice.addItem(
       new ChangeAttributeCommand(
           "at Start", arrowMode, new Integer(PolyLineFigure.ARROW_TIP_START), this));
   choice.addItem(
       new ChangeAttributeCommand(
           "at End", arrowMode, new Integer(PolyLineFigure.ARROW_TIP_END), this));
   choice.addItem(
       new ChangeAttributeCommand(
           "at Both", arrowMode, new Integer(PolyLineFigure.ARROW_TIP_BOTH), this));
   panel.add(fArrowChoice);
   panel.add(new JLabel("Font"));
   fFontChoice = createFontChoice();
   panel.add(fFontChoice);
 }
Exemplo n.º 2
0
  /** Creates a new view. */
  public NetView() {
    initComponents();

    scrollPane.setLayout(new PlacardScrollPaneLayout());
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));

    setEditor(new DefaultDrawingEditor());
    undo = new UndoRedoManager();
    view.setDrawing(createDrawing());
    view.getDrawing().addUndoableEditListener(undo);
    initActions();
    undo.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            setHasUnsavedChanges(undo.hasSignificantEdits());
          }
        });

    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");

    JPanel placardPanel = new JPanel(new BorderLayout());
    javax.swing.AbstractButton pButton;
    pButton = ButtonFactory.createZoomButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    placardPanel.add(pButton, BorderLayout.WEST);
    toggleGridButton = pButton = ButtonFactory.createToggleGridButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    labels.configureToolBarButton(pButton, "view.toggleGrid.placard");
    placardPanel.add(pButton, BorderLayout.EAST);
    scrollPane.add(placardPanel, JScrollPane.LOWER_LEFT_CORNER);

    toggleGridButton.setSelected(preferences.getBoolean("view.gridVisible", false));
    view.setScaleFactor(preferences.getDouble("view.scaleFactor", 1d));

    view.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if ("scaleFactor".equals(name)) {
              preferences.putDouble("view.scaleFactor", (Double) evt.getNewValue());
              firePropertyChange("scaleFactor", evt.getOldValue(), evt.getNewValue());
            }
          }
        });
  }
Exemplo n.º 3
0
 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());
   }
   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();
           }
         }
       });
 }
Exemplo n.º 4
0
 protected void createTools(JPanel palette) {
   Tool tool = createSelectionTool();
   fDefaultToolButton = createToolButton(IMAGES + "SEL", "Selection Tool", tool);
   palette.add(fDefaultToolButton);
 }