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 PanLeftAction.
15   * <p>
16   * Copyright (c) 2002-2023 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>
23   * @author <a href="http://www.peter-jacobs.com">Peter Jacobs </a>
24   */
25  public class PanDownAction extends AbstractAction
26  {
27      /** */
28      private static final long serialVersionUID = 20140909L;
29  
30      /** the panel to pan. */
31      private VisualizationPanel panel = null;
32  
33      /**
34       * constructs a new PanDown.
35       * @param panel GridPanel; the target
36       */
37      public PanDownAction(final VisualizationPanel panel)
38      {
39          super("PanDown");
40          this.panel = panel;
41          this.putValue(Action.SMALL_ICON,
42                  new ImageIcon(URLResource.getResource("/toolbarButtonGraphics/navigation/Down16.gif")));
43          this.setEnabled(true);
44      }
45  
46      /**
47       * @see java.awt.event.ActionListener #actionPerformed(java.awt.event.ActionEvent)
48       */
49      @Override
50      public void actionPerformed(final ActionEvent actionEvent)
51      {
52          this.panel.pan(VisualizationPanel.DOWN, 0.1);
53          this.panel.requestFocus();
54      }
55  }