1 | package org.openstreetmap.josm.actions.mapmode;
|
---|
2 |
|
---|
3 | import java.awt.Cursor;
|
---|
4 | import java.awt.event.ActionEvent;
|
---|
5 | import java.awt.event.MouseEvent;
|
---|
6 | import java.awt.event.MouseListener;
|
---|
7 | import java.awt.event.MouseMotionListener;
|
---|
8 |
|
---|
9 | import javax.swing.KeyStroke;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
13 | import org.openstreetmap.josm.gui.MapFrame;
|
---|
14 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * A class implementing MapMode is able to be selected as an mode for map editing.
|
---|
18 | * As example scrolling the map is a MapMode, connecting Nodes to new Segments
|
---|
19 | * is another.
|
---|
20 | *
|
---|
21 | * MapModes should register/deregister all necessary listener on the map's view
|
---|
22 | * control.
|
---|
23 | */
|
---|
24 | abstract public class MapMode extends JosmAction implements MouseListener, MouseMotionListener {
|
---|
25 |
|
---|
26 | // private final Cursor cursor;
|
---|
27 | // private Cursor oldCursor;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Constructor for mapmodes without an menu
|
---|
31 | */
|
---|
32 | public MapMode(String name, String iconName, String tooltip, String keyname, int keystroke, MapFrame mapFrame, Cursor cursor) {
|
---|
33 | super(name, "mapmode/"+iconName, tooltip, keyname, KeyStroke.getKeyStroke(keystroke, 0));
|
---|
34 | // this.cursor = cursor;
|
---|
35 | putValue("active", false);
|
---|
36 | }
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Constructor for mapmodes with an menu (no shortcut will be registered)
|
---|
40 | */
|
---|
41 | public MapMode(String name, String iconName, String tooltip, MapFrame mapFrame, Cursor cursor) {
|
---|
42 | putValue(NAME, name);
|
---|
43 | putValue(SMALL_ICON, ImageProvider.get("mapmode", iconName));
|
---|
44 | putValue(SHORT_DESCRIPTION, tooltip);
|
---|
45 | // this.cursor = cursor;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public void enterMode() {
|
---|
49 | putValue("active", true);
|
---|
50 | // oldCursor = Main.map.mapView.getCursor();
|
---|
51 | // Main.map.mapView.setCursor(cursor);
|
---|
52 |
|
---|
53 | }
|
---|
54 | public void exitMode() {
|
---|
55 | putValue("active", false);
|
---|
56 | // Main.map.mapView.setCursor(oldCursor);
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Call selectMapMode(this) on the parent mapFrame.
|
---|
61 | */
|
---|
62 | public void actionPerformed(ActionEvent e) {
|
---|
63 | Main.map.selectMapMode(this);
|
---|
64 | }
|
---|
65 |
|
---|
66 | public void mouseReleased(MouseEvent e) {}
|
---|
67 | public void mouseExited(MouseEvent e) {}
|
---|
68 | public void mousePressed(MouseEvent e) {}
|
---|
69 | public void mouseClicked(MouseEvent e) {}
|
---|
70 | public void mouseEntered(MouseEvent e) {}
|
---|
71 | public void mouseMoved(MouseEvent e) {}
|
---|
72 | public void mouseDragged(MouseEvent e) {}
|
---|
73 | }
|
---|