View Javadoc

1   /*
2    * @(#) EditMenuActions.java 25-jul-2004 Copyright (c) 2003 Delft University of
3    * Technology Jaffalaan 5, 2628 BX Delft, the Netherlands All rights reserved.
4    * This software is proprietary information of Delft University of Technology
5    * The code is published under the General Public License
6    */
7   package nl.tudelft.simulation.dsol.gui.editor2D.actions;
8   
9   import java.awt.event.ActionEvent;
10  import java.awt.event.ActionListener;
11  
12  import nl.tudelft.simulation.dsol.gui.editor2D.EditMenu;
13  import nl.tudelft.simulation.dsol.gui.editor2D.Editor2DPanel;
14  
15  /***
16   * EditMenuActions.java <br>
17   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
18   * University of Technology </a>, the Netherlands. <br>
19   * See for project information <a
20   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
21   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
22   * License (GPL) </a>, no warranty <br>
23   * 
24   * @version 1.0 <br>
25   * @author <a href="http://www.tbm.tudelft.nl/webstaf/royc/index.htm">Roy Chin
26   *         </a>
27   */
28  public class EditMenuActions implements ActionListener
29  {
30  
31  	/*** tHe source object */
32  	private EditMenu source = null;
33  
34  	/*** The editalbe animation panel */
35  	private Editor2DPanel panel = null;
36  
37  	/***
38  	 * Constructor
39  	 * 
40  	 * @param source The source object
41  	 * @param panel The Editor2DPanel
42  	 */
43  	public EditMenuActions(final EditMenu source, final Editor2DPanel panel)
44  	{
45  		super();
46  		this.source = source;
47  		this.panel = panel;
48  	}
49  
50  	/***
51  	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
52  	 */
53  	public void actionPerformed(final ActionEvent event)
54  	{
55  		Object src = event.getSource();
56  		if (src.equals(this.source.getMoveItem()))
57  		{
58  			panel.setSelectedEditMode(Editor2DPanel.EDIT_MODE_MOVE);
59  		} else if (src.equals(this.source.getRotateItem()))
60  		{
61  			panel.setSelectedEditMode(Editor2DPanel.EDIT_MODE_ROTATE);
62  		} else if (src.equals(this.source.getAddPointItem()))
63  		{
64  			EditorUtilities.addPointToEditable(
65  			        panel.getSelectedEditableRenderable(),
66  			        this.panel);
67  		}
68  	}
69  
70  }