/** Creates the attribute choices. Override to add additional choices. */ protected void createAttributeChoices(JPanel panel) { panel.add(new JLabel("Fill")); fFillColor = createColorChoice("FillColor"); panel.add(fFillColor); panel.add(new JLabel("Text")); fTextColor = createColorChoice("TextColor"); panel.add(fTextColor); panel.add(new JLabel("Pen")); fFrameColor = createColorChoice("FrameColor"); panel.add(fFrameColor); panel.add(new JLabel("Arrow")); CommandChoice choice = new CommandChoice(); fArrowChoice = choice; 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); }
/** Opens a new window with a drawing view. */ protected void open(DrawingView newDrawingView) { getVersionControlStrategy().assertCompatibleVersion(); setUndoManager(new UndoManager()); fIconkit = new Iconkit(this); getContentPane().setLayout(new BorderLayout()); // status line must be created before a tool is set fStatusLine = createStatusLine(); getContentPane().add(fStatusLine, BorderLayout.SOUTH); // create dummy tool until the default tool is activated during toolDone() setTool(new NullTool(this), ""); setView(newDrawingView); JComponent contents = createContents(view()); contents.setAlignmentX(LEFT_ALIGNMENT); JToolBar tools = createToolPalette(); createTools(tools); JPanel activePanel = new JPanel(); activePanel.setAlignmentX(LEFT_ALIGNMENT); activePanel.setAlignmentY(TOP_ALIGNMENT); activePanel.setLayout(new BorderLayout()); activePanel.add(tools, BorderLayout.NORTH); activePanel.add(contents, BorderLayout.CENTER); getContentPane().add(activePanel, BorderLayout.CENTER); JMenuBar mb = new JMenuBar(); createMenus(mb); setJMenuBar(mb); Dimension d = defaultSize(); if (d.width > mb.getPreferredSize().width) { setSize(d.width, d.height); } else { setSize(mb.getPreferredSize().width, d.height); } addListeners(); setVisible(true); fStorageFormatManager = createStorageFormatManager(); toolDone(); }
/** * Creates the tools. By default only the selection tool is added. Override this method to add * additional tools. Call the inherited method to include the selection tool. * * @param palette the palette where the tools are added. */ protected void createTools(JPanel palette) { Tool tool = createSelectionTool(); fDefaultToolButton = createToolButton(IMAGES + "SEL", "Selection Tool", tool); palette.add(fDefaultToolButton); }
/** * 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(); } } }); }