1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.gui.editor2D;
11
12 import javax.swing.ButtonGroup;
13 import javax.swing.JMenu;
14 import javax.swing.JMenuItem;
15 import javax.swing.JRadioButtonMenuItem;
16 import javax.swing.JSeparator;
17
18 import nl.tudelft.simulation.dsol.gui.editor2D.actions.EditMenuActions;
19
20
21 /***
22 * EditMenu.java <br>
23 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24 * University of Technology </a>, the Netherlands. <br>
25 * See for project information <a
26 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
27 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28 * License (GPL) </a>, no warranty <br>
29 *
30 * @version 1.0 <br>
31 * @author <a href="http://www.tbm.tudelft.nl/webstaf/royc/index.htm">Roy Chin
32 * </a>
33 */
34 public class EditMenu extends JMenu
35 {
36 /*** the editor2d panel */
37 private Editor2DPanel panel = null;
38
39 /*** move the obejct option */
40 private JRadioButtonMenuItem moveItem = null;
41
42 /*** rotate the object option */
43 private JRadioButtonMenuItem rotateItem = null;
44
45 /*** add point option */
46 private JMenuItem addPointItem = null;
47
48 /*** actions */
49 private EditMenuActions actions = null;
50
51 /***
52 * Constructor
53 *
54 * @param text The title of this menu
55 * @param panel The Editor2DPanel
56 */
57 public EditMenu(final String text, final Editor2DPanel panel)
58 {
59 super();
60 this.setText(text);
61 this.actions = new EditMenuActions(this, panel);
62 this.panel = panel;
63 this.initialize();
64 }
65
66 /***
67 * Initialize menu
68 */
69 private void initialize()
70 {
71
72 this.moveItem = new JRadioButtonMenuItem("Move");
73 this.moveItem.addActionListener(this.actions);
74 this.moveItem.setSelected(true);
75 panel.setSelectedEditMode(Editor2DPanel.EDIT_MODE_MOVE);
76
77
78 this.rotateItem = new JRadioButtonMenuItem("Rotate");
79 this.rotateItem.addActionListener(this.actions);
80
81
82 this.addPointItem = new JMenuItem("Add point");
83 this.addPointItem.addActionListener(this.actions);
84
85
86 ButtonGroup group = new ButtonGroup();
87 group.add(this.moveItem);
88 group.add(this.rotateItem);
89 this.add(this.moveItem);
90 this.add(this.rotateItem);
91 this.add(new JSeparator());
92 this.add(this.addPointItem);
93 }
94
95 /***
96 * @return Returns the moveItem.
97 */
98 public JRadioButtonMenuItem getMoveItem()
99 {
100 return this.moveItem;
101 }
102
103 /***
104 * @return Returns the rotateItem.
105 */
106 public JRadioButtonMenuItem getRotateItem()
107 {
108 return this.rotateItem;
109 }
110
111 /***
112 * @return Returns the addPointItem.
113 */
114 public JMenuItem getAddPointItem()
115 {
116 return this.addPointItem;
117 }
118 }