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