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.event.ActionEvent;
19: import java.io.IOException;
20: import java.net.URL;
21: import javax.swing.AbstractAction;
22: import javax.swing.Action;
23: import javax.swing.ImageIcon;
24:
25: public class ResetAction extends AbstractAction {
26: /**
27: * a simple reset action
28: */
29: private ImageIcon icon;
30: JMapPane map;
31:
32: public ResetAction(JMapPane map) {
33: URL url = this .getClass().getResource("resources/Reset16.gif"); //$NON-NLS-1$
34: icon = new ImageIcon(url);
35: this .putValue(Action.SMALL_ICON, icon);
36: this .putValue(Action.NAME, Messages.getString("ResetAction.1")); //$NON-NLS-1$
37:
38: this .map = map;
39: }
40:
41: public void actionPerformed(ActionEvent e) {
42: // TODO Auto-generated method stub
43: if (map == null) {
44: System.out.println("no map set in reset");
45:
46: return;
47: }
48:
49: if (map.context == null) {
50: System.out.println("no context set in reset");
51:
52: return;
53: }
54:
55: try {
56: map.mapArea = map.context.getLayerBounds();
57: } catch (IOException e1) {
58: // TODO Auto-generated catch block
59: e1.printStackTrace();
60: }
61:
62: map.setReset(true);
63: map.repaint();
64: }
65:
66: public ImageIcon getIcon() {
67: return icon;
68: }
69:
70: public void setIcon(ImageIcon icon) {
71: this.icon = icon;
72: }
73: }
|