View Javadoc

1   /*
2    * @(#) NavigationToolbarActions.java 20-jul-2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.gui.editor2D.actions;
11  
12  import java.awt.event.ActionEvent;
13  import java.awt.event.ActionListener;
14  
15  import nl.tudelft.simulation.dsol.gui.animation2D.GridPanel;
16  import nl.tudelft.simulation.dsol.gui.editor2D.NavigationToolbar;
17  
18  
19  /***
20   * NavigationToolbarActions.java <br>
21   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
22   * University of Technology </a>, the Netherlands. <br>
23   * See for project information <a
24   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
25   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
26   * License (GPL) </a>, no warranty <br>
27   * 
28   * @version 1.0 <br>
29   * @author <a href="http://www.tbm.tudelft.nl/webstaf/royc/index.htm">Roy Chin
30   *         </a>
31   */
32  public class NavigationToolbarActions implements ActionListener
33  {
34  
35  	/*** Parent of actions */
36  	private NavigationToolbar source = null;
37  
38  	/*** target of the gridpanel */
39  	private GridPanel target = null;
40  
41  	/***
42  	 * Constructor
43  	 * 
44  	 * @param source Source panel
45  	 * @param target Target grid panel
46  	 */
47  	public NavigationToolbarActions(final NavigationToolbar source,
48  			final GridPanel target)
49  	{
50  		super();
51  		this.source = source;
52  		this.target = target;
53  	}
54  
55  	/***
56  	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
57  	 */
58  	public void actionPerformed(final ActionEvent event)
59  	{
60  		Object src = event.getSource();
61  
62  		if (src.equals(this.source.getPanLeft()))
63  		{
64  			this.target.pan(GridPanel.LEFT, 0.01);
65  		} else if (src.equals(this.source.getPanRight()))
66  		{
67  			this.target.pan(GridPanel.RIGHT, 0.01);
68  		} else if (src.equals(this.source.getPanUp()))
69  		{
70  			this.target.pan(GridPanel.UP, 0.01);
71  		} else if (src.equals(this.source.getPanDown()))
72  		{
73  			this.target.pan(GridPanel.DOWN, 0.01);
74  		} else if (src.equals(this.source.getZoomIn()))
75  		{
76  			this.target.zoom(GridPanel.IN, 0.95);
77  		} else if (src.equals(this.source.getZoomOut()))
78  		{
79  			this.target.zoom(GridPanel.OUT, 0.95);
80  		} else if (src.equals(this.source.getHome()))
81  		{
82  			this.target.home();
83  		} else if (src.equals(this.source.getTroggleGrid()))
84  		{
85  			this.target.showGrid(!this.target.isShowGrid());
86  		}
87  	}
88  
89  }