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-2025 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/dsol/manual/" target="_blank">DSOL Manual</a>. The DSOL
18   * project is distributed under a three-clause BSD-style license, which can be found at
19   * <a href="https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">DSOL License</a>.
20   * </p>
21   * @author <a href="mailto:nlang@fbk.eur.nl">Niels Lang </a>, <a href="http://www.peter-jacobs.com">Peter Jacobs </a>
22   */
23  public class PanUpAction extends AbstractAction
24  {
25      /** */
26      private static final long serialVersionUID = 20140909L;
27  
28      /** the panel to pan up. */
29      private VisualizationPanel panel = null;
30  
31      /**
32       * constructs a new PanUp.
33       * @param panel GridPanel; the target
34       */
35      public PanUpAction(final VisualizationPanel panel)
36      {
37          super("PanUp");
38          this.panel = panel;
39          this.putValue(Action.SMALL_ICON, new ImageIcon(URLResource.getResource("/toolbarButtonGraphics/navigation/Up16.gif")));
40          this.setEnabled(true);
41      }
42  
43      /**
44       * @see java.awt.event.ActionListener #actionPerformed(java.awt.event.ActionEvent)
45       */
46      @Override
47      public void actionPerformed(final ActionEvent actionEvent)
48      {
49          this.panel.pan(VisualizationPanel.UP, 0.1);
50          this.panel.requestFocus();
51      }
52  }