View Javadoc

    1   /*
    2    * @(#) NavigationToolbarActions.java 20-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.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   * NavigationToolbarActions.java <br>
    20   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
    21   * University of Technology </a>, the Netherlands. <br>
    22   * See for project information <a
    23   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
    24   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
    25   * General Public License (LGPL) </a>, no warranty.
    26   *
    27   * @version $Revision$ $Date$
    28   * @author <a href="http://www.tbm.tudelft.nl/webstaf/royc/index.htm">Roy Chin
    29   *         </a>
    30   */
    31  public class NavigationToolbarActions implements ActionListener
    32  {
    33
    34  	/*** Parent of actions */
    35  	private NavigationToolbar source = null;
    36
    37  	/*** target of the gridpanel */
    38  	private GridPanel target = null;
    39
    40  	/***
    41  	 * Constructor
    42  	 *
    43  	 * @param source Source panel
    44  	 * @param target Target grid panel
    45  	 */
    46  	public NavigationToolbarActions(final NavigationToolbar source,
    47  			final GridPanel target)
    48  	{
    49  		super();
    50  		this.source = source;
    51  		this.target = target;
    52  	}
    53
    54  	/***
    55  	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
    56  	 */
    57  	public void actionPerformed(final ActionEvent event)
    58  	{
    59  		Object src = event.getSource();
    60
    61  		if (src.equals(this.source.getPanLeft()))
    62  		{
    63  			this.target.pan(GridPanel.LEFT, 0.01);
    64  		} else if (src.equals(this.source.getPanRight()))
    65  		{
    66  			this.target.pan(GridPanel.RIGHT, 0.01);
    67  		} else if (src.equals(this.source.getPanUp()))
    68  		{
    69  			this.target.pan(GridPanel.UP, 0.01);
    70  		} else if (src.equals(this.source.getPanDown()))
    71  		{
    72  			this.target.pan(GridPanel.DOWN, 0.01);
    73  		} else if (src.equals(this.source.getZoomIn()))
    74  		{
    75  			this.target.zoom(GridPanel.IN, 0.95);
    76  		} else if (src.equals(this.source.getZoomOut()))
    77  		{
    78  			this.target.zoom(GridPanel.OUT, 0.95);
    79  		} else if (src.equals(this.source.getHome()))
    80  		{
    81  			this.target.home();
    82  		} else if (src.equals(this.source.getTroggleGrid()))
    83  		{
    84  			this.target.showGrid(!this.target.isShowGrid());
    85  		}
    86  	}
    87
    88  }