1 |
package skrueger.geotools; |
package skrueger.geotools; |
2 |
|
|
3 |
import java.awt.Cursor; |
import java.awt.Cursor; |
4 |
|
import java.awt.event.InputEvent; |
5 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
6 |
import java.util.HashMap; |
import java.util.HashMap; |
7 |
import java.util.Locale; |
import java.util.Locale; |
11 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
12 |
import javax.swing.KeyStroke; |
import javax.swing.KeyStroke; |
13 |
|
|
|
import com.sun.org.apache.bcel.internal.generic.NEW; |
|
|
|
|
14 |
import schmitzm.lang.LangUtil; |
import schmitzm.lang.LangUtil; |
15 |
import schmitzm.lang.ResourceProvider; |
import schmitzm.lang.ResourceProvider; |
16 |
import schmitzm.swing.SwingUtil; |
import schmitzm.swing.SwingUtil; |
22 |
*/ |
*/ |
23 |
public class XMapPaneTool { |
public class XMapPaneTool { |
24 |
|
|
|
|
|
|
public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil |
|
|
.extendPackagePath(MapPaneToolBar.class, |
|
|
"resource.locales.mapPaneToolbar"), Locale.ENGLISH); |
|
|
|
|
|
public static String R(String key, Object... values) { |
|
|
return RESOURCE.getString(key, values); |
|
|
} |
|
|
|
|
25 |
/** The cursor of the mouse if the tool is active **/ |
/** The cursor of the mouse if the tool is active **/ |
26 |
Cursor cursor = null; |
private Cursor cursor = null; |
27 |
|
|
28 |
/** A tool-tip for the tool , optinal **/ |
/** A tool-tip for the tool , optional **/ |
29 |
String toolTip = null; |
private String toolTip = null; |
30 |
|
|
31 |
/** The icon for the button **/ |
/** The icon for the button **/ |
32 |
Icon icon = null; |
private Icon icon = null; |
33 |
|
|
34 |
/** |
/** |
35 |
* Defines which {@link XMapPaneAction} should be should be called when a |
* Defines which {@link XMapPaneAction} should be should be called when a |
50 |
**/ |
**/ |
51 |
Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>(); |
Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>(); |
52 |
|
|
53 |
|
/** |
54 |
|
* @return the {@link Cursor} that shall be set as the default mouse cursor |
55 |
|
* (when no button is clicked) |
56 |
|
*/ |
57 |
|
public Cursor getCursor() { |
58 |
|
return cursor; |
59 |
|
} |
60 |
|
|
61 |
|
/** |
62 |
|
* @return the {@link Cursor} that shall be set as the default mouse cursor |
63 |
|
* (when no button is clicked) |
64 |
|
*/ |
65 |
|
public void setCursor(Cursor cursor) { |
66 |
|
this.cursor = cursor; |
67 |
|
} |
68 |
|
|
69 |
|
public String getToolTip() { |
70 |
|
return toolTip; |
71 |
|
} |
72 |
|
|
73 |
|
public void setToolTip(String toolTip) { |
74 |
|
this.toolTip = toolTip; |
75 |
|
} |
76 |
|
|
77 |
|
/** |
78 |
|
* An icon to use if the tool is associated with a button. May be |
79 |
|
* <code>null</code>. |
80 |
|
*/ |
81 |
|
public Icon getIcon() { |
82 |
|
return icon; |
83 |
|
} |
84 |
|
|
85 |
|
/** |
86 |
|
* An icon to use if the tool is associated with a button. May be |
87 |
|
* <code>null</code>. |
88 |
|
*/ |
89 |
|
public void setIcon(Icon icon) { |
90 |
|
this.icon = icon; |
91 |
|
} |
92 |
|
|
93 |
|
/** |
94 |
|
* @return The {@link XMapPaneAction} associated with a given |
95 |
|
* {@link MouseInputType} |
96 |
|
*/ |
97 |
|
public XMapPaneAction getMouseAction(MouseInputType type) { |
98 |
|
return mouseActions.get(type); |
99 |
|
} |
100 |
|
|
101 |
|
/** |
102 |
|
* Sets the {@link XMapPaneAction} for a given {@link MouseInputType} |
103 |
|
*/ |
104 |
|
public void setMouseAction(MouseInputType type, XMapPaneAction mouseAction) { |
105 |
|
this.mouseActions.put(type, mouseAction); |
106 |
|
} |
107 |
|
|
108 |
|
/** |
109 |
|
* @return The {@link XMapPaneAction} associated with a {@link KeyStroke} |
110 |
|
*/ |
111 |
|
public XMapPaneAction getKeyAction(KeyStroke keyStroke) { |
112 |
|
return keyAction.get(keyStroke); |
113 |
|
} |
114 |
|
|
115 |
|
/** |
116 |
|
* Set the {@link XMapPaneAction} for a {@link KeyStroke} |
117 |
|
*/ |
118 |
|
public void setKeyAction(KeyStroke keyStroke, XMapPaneAction keyAction) { |
119 |
|
this.keyAction.put(keyStroke, keyAction); |
120 |
|
} |
121 |
|
|
122 |
|
/** |
123 |
|
* Get the optional parameter for a{@link XMapPaneAction} when triggered by |
124 |
|
* {@link KeyStroke} |
125 |
|
*/ |
126 |
|
public Object getKeyActionParam(KeyStroke keyStroke) { |
127 |
|
return keyActionParams.get(keyStroke); |
128 |
|
} |
129 |
|
|
130 |
|
/** |
131 |
|
* Set the optional parameter for a{@link XMapPaneAction} when triggered by |
132 |
|
* {@link KeyStroke} |
133 |
|
*/ |
134 |
|
public void setKeyActionParam(KeyStroke keyStroke, Object param) { |
135 |
|
this.keyActionParams.put(keyStroke, param); |
136 |
|
} |
137 |
|
|
138 |
|
/** |
139 |
|
* The default constructor sets some default keyboard settings |
140 |
|
*/ |
141 |
|
public XMapPaneTool() { |
142 |
|
addDefaultKeyboardAssignments(this); |
143 |
|
} |
144 |
|
|
145 |
|
public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil |
146 |
|
.extendPackagePath(MapPaneToolBar.class, |
147 |
|
"resource.locales.mapPaneToolbar"), Locale.ENGLISH); |
148 |
|
|
149 |
|
public static String R(String key, Object... values) { |
150 |
|
return RESOURCE.getString(key, values); |
151 |
|
} |
152 |
|
|
153 |
|
/** This {@link XMapPaneTool} does nothing **/ |
154 |
|
public static XMapPaneTool NO_ACTION = new XMapPaneTool(); |
155 |
|
static { |
156 |
|
// Remove the keyboard mapping that are defined by the default |
157 |
|
// constructor |
158 |
|
NO_ACTION.keyAction.clear(); |
159 |
|
NO_ACTION.keyActionParams.clear(); |
160 |
|
} |
161 |
|
|
162 |
/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/ |
/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/ |
163 |
public static XMapPaneTool ZOOM_IN = new XMapPaneTool(); |
public static XMapPaneTool ZOOM_IN = new XMapPaneTool(); |
164 |
static { |
static { |
168 |
ZOOM_IN.cursor = SwingUtil.ZOOMIN_CURSOR; |
ZOOM_IN.cursor = SwingUtil.ZOOMIN_CURSOR; |
169 |
|
|
170 |
// Left mouse click & drag zoom in |
// Left mouse click & drag zoom in |
171 |
ZOOM_IN.mouseActions.put(MouseInputType.LClick, |
ZOOM_IN.mouseActions.put(MouseInputType.LClick, XMapPaneAction.ZOOM_IN); |
172 |
XMapPaneAction_Zoom.ZOOM_IN); |
ZOOM_IN.mouseActions.put(MouseInputType.LDrag, XMapPaneAction.ZOOM_IN); |
|
ZOOM_IN.mouseActions.put(MouseInputType.LDrag, |
|
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
173 |
|
|
174 |
// Right mouse click & drag zoom out |
// Right mouse click & drag zoom out |
175 |
ZOOM_IN.mouseActions.put(MouseInputType.RClick, |
ZOOM_IN.mouseActions |
176 |
XMapPaneAction_Zoom.ZOOM_OUT); |
.put(MouseInputType.RClick, XMapPaneAction.ZOOM_OUT); |
177 |
ZOOM_IN.mouseActions.put(MouseInputType.RDrag, |
ZOOM_IN.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.ZOOM_OUT); |
|
XMapPaneAction_Zoom.ZOOM_OUT); |
|
178 |
|
|
179 |
// Mousewheel can zoom too |
// Mousewheel can zoom too |
180 |
ZOOM_IN.mouseActions.put(MouseInputType.Wheel, |
ZOOM_IN.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN); |
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
|
|
|
|
// + and - keys zoom too |
|
|
ZOOM_IN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), |
|
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
|
ZOOM_IN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), |
|
|
XMapPaneAction_Zoom.ZOOM_OUT); |
|
181 |
} |
} |
182 |
|
|
183 |
/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/ |
/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/ |
190 |
|
|
191 |
// Left mouse click & drag zoom in |
// Left mouse click & drag zoom in |
192 |
ZOOM_OUT.mouseActions.put(MouseInputType.LClick, |
ZOOM_OUT.mouseActions.put(MouseInputType.LClick, |
193 |
XMapPaneAction_Zoom.ZOOM_OUT); |
XMapPaneAction.ZOOM_OUT); |
194 |
ZOOM_OUT.mouseActions.put(MouseInputType.LDrag, |
ZOOM_OUT.mouseActions |
195 |
XMapPaneAction_Zoom.ZOOM_OUT); |
.put(MouseInputType.LDrag, XMapPaneAction.ZOOM_OUT); |
196 |
|
|
197 |
// Right mouse click & drag zoom out |
// Right mouse click & drag zoom out |
198 |
ZOOM_OUT.mouseActions.put(MouseInputType.RClick, |
ZOOM_OUT.mouseActions |
199 |
XMapPaneAction_Zoom.ZOOM_IN); |
.put(MouseInputType.RClick, XMapPaneAction.ZOOM_IN); |
200 |
ZOOM_OUT.mouseActions.put(MouseInputType.RDrag, |
ZOOM_OUT.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.ZOOM_IN); |
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
201 |
|
|
202 |
// Mousewheel can zoom |
// Mousewheel can zoom |
203 |
ZOOM_OUT.mouseActions.put(MouseInputType.Wheel, |
ZOOM_OUT.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN); |
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
204 |
|
|
|
// + and - keys zoom |
|
|
ZOOM_OUT.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), |
|
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
|
ZOOM_OUT.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), |
|
|
XMapPaneAction_Zoom.ZOOM_OUT); |
|
205 |
} |
} |
206 |
|
|
207 |
/** The configuration of the PAN {@link XMapPaneTool} **/ |
/** The configuration of the PAN {@link XMapPaneTool} **/ |
208 |
public static final XMapPaneTool PAN = new XMapPaneTool(); |
public static final XMapPaneTool PAN = new XMapPaneTool(); |
209 |
static { |
static { |
213 |
PAN.cursor = SwingUtil.PAN_CURSOR; |
PAN.cursor = SwingUtil.PAN_CURSOR; |
214 |
|
|
215 |
// Left mouse click & drag zoom in |
// Left mouse click & drag zoom in |
216 |
PAN.mouseActions.put(MouseInputType.LClick, |
PAN.mouseActions.put(MouseInputType.LClick, XMapPaneAction.PAN); |
217 |
XMapPaneAction.PAN); |
PAN.mouseActions.put(MouseInputType.LDrag, XMapPaneAction.PAN); |
|
PAN.mouseActions.put(MouseInputType.LDrag, |
|
|
XMapPaneAction.PAN); |
|
218 |
|
|
219 |
// Right mouse click & drag zoom out |
// Right mouse click & drag zoom out |
220 |
PAN.mouseActions.put(MouseInputType.RClick, |
PAN.mouseActions.put(MouseInputType.RClick, XMapPaneAction.PAN); |
221 |
|
PAN.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.PAN); |
222 |
|
|
223 |
|
// Mousewheel can zoom |
224 |
|
PAN.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN); |
225 |
|
|
226 |
|
} |
227 |
|
|
228 |
|
/** A tool that will do a select_top action on the left mouse button **/ |
229 |
|
public static final XMapPaneTool SELECTION_TOP_LAYER = new XMapPaneTool(); |
230 |
|
static { |
231 |
|
SELECTION_TOP_LAYER.icon = new ImageIcon(MapView.class |
232 |
|
.getResource("resource/icons/selection_set.png")); |
233 |
|
|
234 |
|
SELECTION_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR; |
235 |
|
|
236 |
|
// Left mouse click & drag zoom in |
237 |
|
SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.LClick, |
238 |
|
XMapPaneAction.SELECT_TOP); |
239 |
|
SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.LDrag, |
240 |
|
XMapPaneAction.SELECT_TOP); |
241 |
|
|
242 |
|
SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.RDrag, |
243 |
|
XMapPaneAction.PAN); |
244 |
|
|
245 |
|
// Mousewheel can zoom |
246 |
|
SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.Wheel, |
247 |
|
XMapPaneAction.ZOOM_IN); |
248 |
|
|
249 |
|
// TODO Strg-A shoud select all |
250 |
|
} |
251 |
|
|
252 |
|
/** A tool that will do a select_top action on the left mouse button **/ |
253 |
|
public static final XMapPaneTool SELECTION_ONE_FROM_TOP_LAYER = new XMapPaneTool(); |
254 |
|
static { |
255 |
|
SELECTION_ONE_FROM_TOP_LAYER.icon = new ImageIcon(MapView.class |
256 |
|
.getResource("resource/icons/selection_set.png")); |
257 |
|
|
258 |
|
SELECTION_ONE_FROM_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR; |
259 |
|
|
260 |
|
// Left mouse click & drag zoom in |
261 |
|
SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.LClick, |
262 |
|
XMapPaneAction.SELECT_ONE_FROM_TOP); |
263 |
|
SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.LDrag, |
264 |
|
XMapPaneAction.SELECT_ONE_FROM_TOP); |
265 |
|
|
266 |
|
SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.RDrag, |
267 |
XMapPaneAction.PAN); |
XMapPaneAction.PAN); |
268 |
PAN.mouseActions.put(MouseInputType.RDrag, |
|
269 |
|
// Mousewheel can zoom |
270 |
|
SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.Wheel, |
271 |
|
XMapPaneAction.ZOOM_IN); |
272 |
|
|
273 |
|
// TODO Strg-A shoud select all |
274 |
|
} |
275 |
|
|
276 |
|
/** A tool that will do a select_top action on the left mouse button **/ |
277 |
|
public static final XMapPaneTool SELECTION_ALL_LAYERS = new XMapPaneTool(); |
278 |
|
static { |
279 |
|
SELECTION_ALL_LAYERS.icon = new ImageIcon(MapView.class |
280 |
|
.getResource("resource/icons/selection_set.png")); |
281 |
|
|
282 |
|
SELECTION_ALL_LAYERS.cursor = SwingUtil.SELECTION_SET_CURSOR; |
283 |
|
|
284 |
|
// Left mouse click & drag zoom in |
285 |
|
SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.LClick, |
286 |
|
XMapPaneAction.SELECT_ALL); |
287 |
|
SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.LDrag, |
288 |
|
XMapPaneAction.SELECT_ALL); |
289 |
|
|
290 |
|
SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.RDrag, |
291 |
XMapPaneAction.PAN); |
XMapPaneAction.PAN); |
292 |
|
|
293 |
// Mousewheel can zoom |
// Mousewheel can zoom |
294 |
PAN.mouseActions.put(MouseInputType.Wheel, |
SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.Wheel, |
295 |
XMapPaneAction_Zoom.ZOOM_IN); |
XMapPaneAction.ZOOM_IN); |
296 |
|
|
297 |
// + and - keys zoom |
// TODO Strg-A shoud select all |
|
PAN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), |
|
|
XMapPaneAction_Zoom.ZOOM_IN); |
|
|
PAN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), |
|
|
XMapPaneAction_Zoom.ZOOM_OUT); |
|
298 |
} |
} |
|
|
|
299 |
|
|
300 |
/** The configuration of the INFO {@link XMapPaneTool} **/ |
/** The configuration of the INFO {@link XMapPaneTool} **/ |
301 |
public static final XMapPaneTool INFO = new XMapPaneTool(); |
public static final XMapPaneTool INFO = new XMapPaneTool(); |
302 |
|
|
303 |
static { |
static { |
304 |
INFO.icon = new ImageIcon(MapView.class |
INFO.icon = new ImageIcon(MapView.class |
305 |
.getResource("resource/icons/info.png")); |
.getResource("resource/icons/info.png")); |
309 |
// Left mouse click & drag zoom in |
// Left mouse click & drag zoom in |
310 |
INFO.mouseActions.put(MouseInputType.LClick, |
INFO.mouseActions.put(MouseInputType.LClick, |
311 |
XMapPaneAction.SELECT_ONE_FROM_TOP); |
XMapPaneAction.SELECT_ONE_FROM_TOP); |
312 |
// INFO.mouseActions.put(MouseInputType.LDrag, |
// INFO.mouseActions.put(MouseInputType.LDrag, |
313 |
// XMapPaneAction.SELECT_ONE_FROM_TOP); |
// XMapPaneAction.SELECT_ONE_FROM_TOP); |
314 |
|
|
315 |
|
INFO.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.PAN); |
316 |
|
|
317 |
|
// Mousewheel can zoom |
318 |
|
INFO.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN); |
319 |
|
|
320 |
INFO.mouseActions.put(MouseInputType.RDrag, |
} |
321 |
|
|
322 |
|
public static final XMapPaneTool SELECTION_ADD = new XMapPaneTool(); |
323 |
|
static { |
324 |
|
SELECTION_ADD.icon = new ImageIcon(MapView.class |
325 |
|
.getResource("resource/icons/selection_add.png")); |
326 |
|
SELECTION_ADD.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO |
327 |
|
// move |
328 |
|
// to |
329 |
|
// schmitzm |
330 |
|
|
331 |
|
SELECTION_ADD.cursor = SwingUtil.SELECTION_ADD_CURSOR; |
332 |
|
|
333 |
|
// Left mouse click & drag zoom in |
334 |
|
SELECTION_ADD.mouseActions.put(MouseInputType.LClick, |
335 |
|
XMapPaneAction.SELECT_ALL); |
336 |
|
SELECTION_ADD.mouseActions.put(MouseInputType.LDrag, |
337 |
|
XMapPaneAction.SELECT_ALL); |
338 |
|
|
339 |
|
SELECTION_ADD.mouseActions |
340 |
|
.put(MouseInputType.RDrag, XMapPaneAction.PAN); |
341 |
|
|
342 |
|
// Mousewheel can zoom |
343 |
|
SELECTION_ADD.mouseActions.put(MouseInputType.Wheel, |
344 |
|
XMapPaneAction.ZOOM_IN); |
345 |
|
|
346 |
|
// TODO Strg-A shoud select all |
347 |
|
} |
348 |
|
|
349 |
|
public static final XMapPaneTool SELECTION_REMOVE = new XMapPaneTool(); |
350 |
|
static { |
351 |
|
SELECTION_REMOVE.icon = new ImageIcon(MapView.class |
352 |
|
.getResource("resource/icons/selection_remove.png")); |
353 |
|
SELECTION_REMOVE.toolTip = R("MapPaneButtons.Selection.RemoveSelection.TT"); // TODO |
354 |
|
// move |
355 |
|
// to |
356 |
|
// schmitzm |
357 |
|
|
358 |
|
SELECTION_REMOVE.cursor = SwingUtil.SELECTION_REMOVE_CURSOR; |
359 |
|
|
360 |
|
// Left mouse click & drag zoom in |
361 |
|
SELECTION_REMOVE.mouseActions.put(MouseInputType.LClick, |
362 |
|
XMapPaneAction.SELECT_ALL); |
363 |
|
SELECTION_REMOVE.mouseActions.put(MouseInputType.LDrag, |
364 |
|
XMapPaneAction.SELECT_ALL); |
365 |
|
|
366 |
|
SELECTION_REMOVE.mouseActions.put(MouseInputType.RDrag, |
367 |
XMapPaneAction.PAN); |
XMapPaneAction.PAN); |
368 |
|
|
369 |
// Mousewheel can zoom |
// Mousewheel can zoom |
370 |
INFO.mouseActions.put(MouseInputType.Wheel, |
SELECTION_REMOVE.mouseActions.put(MouseInputType.Wheel, |
371 |
XMapPaneAction_Zoom.ZOOM_IN); |
XMapPaneAction.ZOOM_IN); |
372 |
|
|
373 |
// + and - keys zoom |
// TODO Strg-A shoud select all |
374 |
INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), |
} |
375 |
XMapPaneAction_Zoom.ZOOM_IN); |
|
376 |
INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), |
public static final XMapPaneTool SELECTION_SET = new XMapPaneTool(); |
377 |
XMapPaneAction_Zoom.ZOOM_OUT); |
static { |
378 |
|
SELECTION_SET.icon = new ImageIcon(MapView.class |
379 |
|
.getResource("resource/icons/selection_set.png")); |
380 |
|
SELECTION_SET.toolTip = R("MapPaneButtons.Selection.SetSelection.TT"); // TODO |
381 |
|
// move |
382 |
|
// to |
383 |
|
// schmitzm |
384 |
|
|
385 |
|
SELECTION_SET.cursor = SwingUtil.SELECTION_SET_CURSOR; |
386 |
|
|
387 |
|
// Left mouse click & drag zoom in |
388 |
|
SELECTION_SET.mouseActions.put(MouseInputType.LClick, |
389 |
|
XMapPaneAction.SELECT_ALL); |
390 |
|
SELECTION_SET.mouseActions.put(MouseInputType.LDrag, |
391 |
|
XMapPaneAction.SELECT_ALL); |
392 |
|
|
393 |
|
SELECTION_SET.mouseActions |
394 |
|
.put(MouseInputType.RDrag, XMapPaneAction.PAN); |
395 |
|
|
396 |
|
// Mousewheel can zoom |
397 |
|
SELECTION_SET.mouseActions.put(MouseInputType.Wheel, |
398 |
|
XMapPaneAction.ZOOM_IN); |
399 |
|
|
400 |
|
// TODO Strg-A shoud select all |
401 |
} |
} |
402 |
|
|
403 |
|
/** |
404 |
|
* Adds default Keyboard actions to a given {@link XMapPaneTool} |
405 |
|
*/ |
406 |
|
public static void addDefaultKeyboardAssignments(XMapPaneTool tool) { |
407 |
|
|
408 |
|
// + and - keys zoom |
409 |
|
tool.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), |
410 |
|
XMapPaneAction.ZOOM_IN); |
411 |
|
tool.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), |
412 |
|
XMapPaneAction.ZOOM_OUT); |
413 |
|
|
414 |
|
KeyStroke keyStroke; |
415 |
|
|
416 |
|
for (int modifier : new int[] { InputEvent.ALT_DOWN_MASK, |
417 |
|
InputEvent.ALT_GRAPH_DOWN_MASK, InputEvent.CTRL_DOWN_MASK, |
418 |
|
InputEvent.SHIFT_DOWN_MASK, InputEvent.META_DOWN_MASK }) { |
419 |
|
|
420 |
|
// RIGHT button pan |
421 |
|
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, modifier); |
422 |
|
tool.keyAction.put(keyStroke, XMapPaneAction.PAN); |
423 |
|
tool.keyActionParams.put(keyStroke, |
424 |
|
XMapPaneAction_Pan.Direction.RIGHT); |
425 |
|
|
426 |
|
// LEFT button pan |
427 |
|
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, modifier); |
428 |
|
tool.keyAction.put(keyStroke, XMapPaneAction.PAN); |
429 |
|
tool.keyActionParams.put(keyStroke, |
430 |
|
XMapPaneAction_Pan.Direction.LEFT); |
431 |
|
|
432 |
|
// UP button pan |
433 |
|
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, modifier); |
434 |
|
tool.keyAction.put(keyStroke, XMapPaneAction.PAN); |
435 |
|
tool.keyActionParams |
436 |
|
.put(keyStroke, XMapPaneAction_Pan.Direction.UP); |
437 |
|
|
438 |
|
// DOWN button pan |
439 |
|
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_UP, modifier); |
440 |
|
tool.keyAction.put(keyStroke, XMapPaneAction.PAN); |
441 |
|
tool.keyActionParams.put(keyStroke, |
442 |
|
XMapPaneAction_Pan.Direction.DOWN); |
443 |
|
} |
444 |
|
|
445 |
|
} |
446 |
} |
} |