/** * Creates toolbars for the application. This class always returns an empty list. Subclasses may * return other values. */ @Override public List<JToolBar> createToolBars(Application a, @Nullable View pr) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); DrawView p = (DrawView) pr; DrawingEditor editor; if (p == null) { editor = getSharedEditor(); } else { editor = p.getEditor(); } LinkedList<JToolBar> list = new LinkedList<JToolBar>(); JToolBar tb; tb = new JToolBar(); addCreationButtonsTo(tb, editor); tb.setName(labels.getString("window.drawToolBar.title")); list.add(tb); tb = new JToolBar(); ButtonFactory.addAttributesButtonsTo(tb, editor); tb.setName(labels.getString("window.attributesToolBar.title")); list.add(tb); tb = new JToolBar(); ButtonFactory.addAlignmentButtonsTo(tb, editor); tb.setName(labels.getString("window.alignmentToolBar.title")); list.add(tb); return list; }
/** Creates new instance. */ public ODGDrawingPanel() { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); initComponents(); undoManager = new UndoRedoManager(); editor = new DefaultDrawingEditor(); editor.add(view); addCreationButtonsTo(creationToolbar, editor); ButtonFactory.addAttributesButtonsTo(attributesToolbar, editor); JPopupButton pb = new JPopupButton(); pb.setItemFont(UIManager.getFont("MenuItem.font")); labels.configureToolBarButton(pb, "actions"); pb.add(new DuplicateAction()); pb.addSeparator(); pb.add(new GroupAction(editor)); pb.add(new UngroupAction(editor)); pb.addSeparator(); pb.add(new BringToFrontAction(editor)); pb.add(new SendToBackAction(editor)); pb.addSeparator(); pb.add(new CutAction()); pb.add(new CopyAction()); pb.add(new PasteAction()); pb.add(new SelectAllAction()); pb.add(new SelectSameAction(editor)); pb.addSeparator(); pb.add(undoManager.getUndoAction()); pb.add(undoManager.getRedoAction()); // FIXME - We need a toggle grid action // pb.addSeparator(); // pb.add(new ToggleGridAction(editor)); JMenu m = new JMenu(labels.getString("view.zoomFactor.text")); JRadioButtonMenuItem rbmi; ButtonGroup group = new ButtonGroup(); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.1, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.25, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.5, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.75, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.0, null))); rbmi.setSelected(true); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.25, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.5, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 2, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 3, null))); group.add(rbmi); m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 4, null))); group.add(rbmi); pb.add(m); pb.setFocusable(false); creationToolbar.addSeparator(); creationToolbar.add(pb); DefaultDrawing drawing = new DefaultDrawing(); view.setDrawing(drawing); drawing.addUndoableEditListener(undoManager); }