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.ResourceResolver;
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 = 1L;
27  
28      /** the panel to pan up. */
29      private VisualizationPanel panel = null;
30  
31      /**
32       * constructs a new PanUp.
33       * @param panel the target
34       */
35      public PanUpAction(final VisualizationPanel panel)
36      {
37          super("PanUp");
38          this.panel = panel;
39          this.putValue(Action.SMALL_ICON,
40                  new ImageIcon(ResourceResolver.resolve("/toolbarButtonGraphics/navigation/Up16.gif").asUrl()));
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  }