01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.gui.swing;
17:
18: import java.awt.Cursor;
19: import java.awt.event.ActionEvent;
20: import java.net.URL;
21: import javax.swing.AbstractAction;
22: import javax.swing.Action;
23: import javax.swing.ImageIcon;
24:
25: /**
26: * Basic action for panning mappanes
27: * @author Ian Turton
28: *
29: */
30: public class PanAction extends AbstractAction {
31: /**
32: * shut eclipse up
33: */
34: private static final long serialVersionUID = 2718536128821468386L;
35:
36: /**
37: * the icon to display
38: */
39: private ImageIcon icon;
40:
41: /**
42: * the mappane to pan
43: */
44: JMapPane map;
45:
46: /**
47: * constructor
48: * @param map - the mappane to act on
49: */
50: public PanAction(JMapPane map) {
51: URL url = this .getClass().getResource("resources/Pan16.gif"); //$NON-NLS-1$
52: icon = new ImageIcon(url);
53: this .putValue(Action.SMALL_ICON, icon);
54: this .putValue(Action.NAME, Messages.getString("PanAction.1")); //$NON-NLS-1$
55: this .map = map;
56: }
57:
58: /**
59: * the action occurred - set the state of the map pane to pan
60: */
61: public void actionPerformed(ActionEvent e) {
62: map.setState(JMapPane.Pan);
63: map.setCursor(new Cursor(Cursor.MOVE_CURSOR));
64: }
65:
66: /**
67: * get the current icon
68: * @return the icon
69: */
70: public ImageIcon getIcon() {
71: return icon;
72: }
73:
74: /**
75: * set the icon to be displayed with the action
76: * @param icon
77: */
78: public void setIcon(ImageIcon icon) {
79: this.icon = icon;
80: }
81: }
|