View Javadoc
1   package nl.tudelft.simulation.dsol.swing.animation.d2.actions;
2   
3   import java.awt.event.ActionEvent;
4   
5   import javax.swing.AbstractAction;
6   import javax.swing.Action;
7   import javax.swing.ImageIcon;
8   
9   import org.djutils.io.URLResource;
10  
11  import nl.tudelft.simulation.dsol.swing.animation.d2.VisualizationPanel;
12  
13  /**
14   * The PanUpAction.
15   * <p>
16   * Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
17   * for project information <a href="https://simulation.tudelft.nl/" target="_blank"> https://simulation.tudelft.nl</a>. The DSOL
18   * project is distributed under a three-clause BSD-style license, which can be found at
19   * <a href="https://https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">
20   * https://https://simulation.tudelft.nl/dsol/docs/latest/license.html</a>.
21   * </p>
22   * @author <a href="mailto:nlang@fbk.eur.nl">Niels Lang </a>, <a href="http://www.peter-jacobs.com">Peter Jacobs </a>
23   */
24  public class PanUpAction extends AbstractAction
25  {
26      /** */
27      private static final long serialVersionUID = 20140909L;
28  
29      /** the panel to pan up. */
30      private VisualizationPanel panel = null;
31  
32      /**
33       * constructs a new PanUp.
34       * @param panel GridPanel; the target
35       */
36      public PanUpAction(final VisualizationPanel panel)
37      {
38          super("PanUp");
39          this.panel = panel;
40          this.putValue(Action.SMALL_ICON, new ImageIcon(URLResource.getResource("/toolbarButtonGraphics/navigation/Up16.gif")));
41          this.setEnabled(true);
42      }
43  
44      /**
45       * @see java.awt.event.ActionListener #actionPerformed(java.awt.event.ActionEvent)
46       */
47      @Override
48      public void actionPerformed(final ActionEvent actionEvent)
49      {
50          this.panel.pan(VisualizationPanel.UP, 0.1);
51          this.panel.requestFocus();
52      }
53  }