/[schmitzm]/branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
ViewVC logotype

Annotation of /branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 653 - (hide annotations)
Mon Feb 1 15:09:18 2010 UTC (15 years, 1 month ago) by alfonx
File MIME type: text/plain
File size: 5942 byte(s)
GP-Cleanup: Implemented the XMapPaneAction and XMapPaneTool comcept for all GeoPublisher tools except for the SelectionTools
1 alfonx 653 package skrueger.geotools;
2    
3     import java.awt.Cursor;
4     import java.awt.event.KeyEvent;
5     import java.util.HashMap;
6     import java.util.Locale;
7     import java.util.Map;
8    
9     import javax.swing.Icon;
10     import javax.swing.ImageIcon;
11     import javax.swing.KeyStroke;
12    
13     import com.sun.org.apache.bcel.internal.generic.NEW;
14    
15     import schmitzm.lang.LangUtil;
16     import schmitzm.lang.ResourceProvider;
17     import schmitzm.swing.SwingUtil;
18     import schmitzm.swing.event.MouseInputType;
19    
20     /**
21     * This class combines the mapping of mouse-inputs and keyboard inputs to
22     * {@link XMapPaneAction}s and provides a tool icon and a default mouse cursor.
23     */
24     public class XMapPaneTool {
25    
26    
27     public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
28     .extendPackagePath(MapPaneToolBar.class,
29     "resource.locales.mapPaneToolbar"), Locale.ENGLISH);
30    
31     public static String R(String key, Object... values) {
32     return RESOURCE.getString(key, values);
33     }
34    
35     /** The cursor of the mouse if the tool is active **/
36     Cursor cursor = null;
37    
38     /** A tool-tip for the tool , optinal **/
39     String toolTip = null;
40    
41     /** The icon for the button **/
42     Icon icon = null;
43    
44     /**
45     * Defines which {@link XMapPaneAction} should be should be called when a
46     * {@link MouseInputType} is triggered
47     **/
48     Map<MouseInputType, XMapPaneAction> mouseActions = new HashMap<MouseInputType, XMapPaneAction>();
49    
50     /**
51     * Defines which {@link XMapPaneAction#performKeyboard(XMapPane, Object)}
52     * should be called when a {@link KeyStroke} is triggered
53     **/
54     Map<KeyStroke, XMapPaneAction> keyAction = new HashMap<KeyStroke, XMapPaneAction>();
55    
56     /**
57     * Defines which optional parameter should be passed to
58     * {@link XMapPaneAction#performKeyboard(XMapPane, Object)} if a
59     * {@link KeyStroke} is triggered
60     **/
61     Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>();
62    
63     /** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
64     public static XMapPaneTool ZOOM_IN = new XMapPaneTool();
65     static {
66     ZOOM_IN.icon = new ImageIcon(MapView.class
67     .getResource("resource/icons/zoom_in.png"));
68     ZOOM_IN.toolTip = R("MapPaneButtons.ZoomIn.TT");
69     ZOOM_IN.cursor = SwingUtil.ZOOMIN_CURSOR;
70    
71     // Left mouse click & drag zoom in
72     ZOOM_IN.mouseActions.put(MouseInputType.LClick,
73     XMapPaneAction_Zoom.ZOOM_IN);
74     ZOOM_IN.mouseActions.put(MouseInputType.LDrag,
75     XMapPaneAction_Zoom.ZOOM_IN);
76    
77     // Right mouse click & drag zoom out
78     ZOOM_IN.mouseActions.put(MouseInputType.RClick,
79     XMapPaneAction_Zoom.ZOOM_OUT);
80     ZOOM_IN.mouseActions.put(MouseInputType.RDrag,
81     XMapPaneAction_Zoom.ZOOM_OUT);
82    
83     // Mousewheel can zoom too
84     ZOOM_IN.mouseActions.put(MouseInputType.Wheel,
85     XMapPaneAction_Zoom.ZOOM_IN);
86    
87     // + and - keys zoom too
88     ZOOM_IN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
89     XMapPaneAction_Zoom.ZOOM_IN);
90     ZOOM_IN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
91     XMapPaneAction_Zoom.ZOOM_OUT);
92     }
93    
94     /** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
95     public static XMapPaneTool ZOOM_OUT = new XMapPaneTool();
96     static {
97     ZOOM_OUT.icon = new ImageIcon(MapView.class
98     .getResource("resource/icons/zoom_out.png"));
99     ZOOM_OUT.toolTip = R("MapPaneButtons.ZoomOut.TT");
100     ZOOM_OUT.cursor = SwingUtil.ZOOMOUT_CURSOR;
101    
102     // Left mouse click & drag zoom in
103     ZOOM_OUT.mouseActions.put(MouseInputType.LClick,
104     XMapPaneAction_Zoom.ZOOM_OUT);
105     ZOOM_OUT.mouseActions.put(MouseInputType.LDrag,
106     XMapPaneAction_Zoom.ZOOM_OUT);
107    
108     // Right mouse click & drag zoom out
109     ZOOM_OUT.mouseActions.put(MouseInputType.RClick,
110     XMapPaneAction_Zoom.ZOOM_IN);
111     ZOOM_OUT.mouseActions.put(MouseInputType.RDrag,
112     XMapPaneAction_Zoom.ZOOM_IN);
113    
114     // Mousewheel can zoom
115     ZOOM_OUT.mouseActions.put(MouseInputType.Wheel,
116     XMapPaneAction_Zoom.ZOOM_IN);
117    
118     // + and - keys zoom
119     ZOOM_OUT.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
120     XMapPaneAction_Zoom.ZOOM_IN);
121     ZOOM_OUT.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
122     XMapPaneAction_Zoom.ZOOM_OUT);
123     }
124    
125     /** The configuration of the PAN {@link XMapPaneTool} **/
126     public static final XMapPaneTool PAN = new XMapPaneTool();
127     static {
128     PAN.icon = new ImageIcon(MapView.class
129     .getResource("resource/icons/pan.png"));
130     PAN.toolTip = R("MapPaneButtons.Pan.TT");
131     PAN.cursor = SwingUtil.PAN_CURSOR;
132    
133     // Left mouse click & drag zoom in
134     PAN.mouseActions.put(MouseInputType.LClick,
135     XMapPaneAction.PAN);
136     PAN.mouseActions.put(MouseInputType.LDrag,
137     XMapPaneAction.PAN);
138    
139     // Right mouse click & drag zoom out
140     PAN.mouseActions.put(MouseInputType.RClick,
141     XMapPaneAction.PAN);
142     PAN.mouseActions.put(MouseInputType.RDrag,
143     XMapPaneAction.PAN);
144    
145     // Mousewheel can zoom
146     PAN.mouseActions.put(MouseInputType.Wheel,
147     XMapPaneAction_Zoom.ZOOM_IN);
148    
149     // + and - keys zoom
150     PAN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
151     XMapPaneAction_Zoom.ZOOM_IN);
152     PAN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
153     XMapPaneAction_Zoom.ZOOM_OUT);
154     }
155    
156    
157     /** The configuration of the INFO {@link XMapPaneTool} **/
158     public static final XMapPaneTool INFO = new XMapPaneTool();
159     static {
160     INFO.icon = new ImageIcon(MapView.class
161     .getResource("resource/icons/info.png"));
162     INFO.toolTip = R("MapPaneButtons.Info.TT");
163     INFO.cursor = SwingUtil.INFO_CURSOR;
164    
165     // Left mouse click & drag zoom in
166     INFO.mouseActions.put(MouseInputType.LClick,
167     XMapPaneAction.SELECT_ONE_FROM_TOP);
168     // INFO.mouseActions.put(MouseInputType.LDrag,
169     // XMapPaneAction.SELECT_ONE_FROM_TOP);
170    
171     INFO.mouseActions.put(MouseInputType.RDrag,
172     XMapPaneAction.PAN);
173    
174     // Mousewheel can zoom
175     INFO.mouseActions.put(MouseInputType.Wheel,
176     XMapPaneAction_Zoom.ZOOM_IN);
177    
178     // + and - keys zoom
179     INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
180     XMapPaneAction_Zoom.ZOOM_IN);
181     INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
182     XMapPaneAction_Zoom.ZOOM_OUT);
183    
184     }
185    
186     }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26