View Javadoc

1   /*
2    * @(#) EditMenu.java 25-jul-2004
3    * 
4    * Copyright (c) 2002-2005 Delft University of Technology Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the Lesser General Public License
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   * EditMenu.java <br>
22   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
23   * University of Technology </a>, the Netherlands. <br>
24   * See for project information <a
25   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
26   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
27   * General Public License (LGPL) </a>, no warranty.
28   * 
29   * @version $Revision$ $Date$
30   * @author <a href="http://www.tbm.tudelft.nl/webstaf/royc/index.htm">Roy Chin
31   *         </a>
32   */
33  public class EditMenu extends JMenu
34  {
35  	/*** the editor2d panel */
36  	private Editor2DPanel panel = null;
37  
38  	/*** move the obejct option */
39  	private JRadioButtonMenuItem moveItem = null;
40  
41  	/*** rotate the object option */
42  	private JRadioButtonMenuItem rotateItem = null;
43  
44  	/*** add point option */
45  	private JMenuItem addPointItem = null;
46  
47  	/*** actions */
48  	private EditMenuActions actions = null;
49  
50  	/***
51  	 * Constructor
52  	 * 
53  	 * @param text The title of this menu
54  	 * @param panel The Editor2DPanel
55  	 */
56  	public EditMenu(final String text, final Editor2DPanel panel)
57  	{
58  		super();
59  		this.setText(text);
60  		this.actions = new EditMenuActions(this, panel);
61  		this.panel = panel;
62  		this.initialize();
63  	}
64  
65  	/***
66  	 * Initialize menu
67  	 */
68  	private void initialize()
69  	{
70  		// Move
71  		this.moveItem = new JRadioButtonMenuItem("Move");
72  		this.moveItem.addActionListener(this.actions);
73  		this.moveItem.setSelected(true);
74  		this.panel.setSelectedEditMode(Editor2DPanel.EDIT_MODE_MOVE);
75  
76  		// Rotate
77  		this.rotateItem = new JRadioButtonMenuItem("Rotate");
78  		this.rotateItem.addActionListener(this.actions);
79  
80  		// Add point
81  		this.addPointItem = new JMenuItem("Add point");
82  		this.addPointItem.addActionListener(this.actions);
83  
84  		// Construct menu
85  		ButtonGroup group = new ButtonGroup();
86  		group.add(this.moveItem);
87  		group.add(this.rotateItem);
88  		this.add(this.moveItem);
89  		this.add(this.rotateItem);
90  		this.add(new JSeparator());
91  		this.add(this.addPointItem);
92  	}
93  
94  	/***
95  	 * @return Returns the moveItem.
96  	 */
97  	public JRadioButtonMenuItem getMoveItem()
98  	{
99  		return this.moveItem;
100 	}
101 
102 	/***
103 	 * @return Returns the rotateItem.
104 	 */
105 	public JRadioButtonMenuItem getRotateItem()
106 	{
107 		return this.rotateItem;
108 	}
109 
110 	/***
111 	 * @return Returns the addPointItem.
112 	 */
113 	public JMenuItem getAddPointItem()
114 	{
115 		return this.addPointItem;
116 	}
117 }