source: josm/src/org/openstreetmap/josm/actions/MapMode.java@ 1

Last change on this file since 1 was 1, checked in by imi, 21 years ago

wiki 19:37, 27. Sep 2005

File size: 1.5 KB
Line 
1package org.openstreetmap.josm.actions;
2
3import java.awt.event.ActionEvent;
4
5import javax.swing.AbstractAction;
6import javax.swing.ImageIcon;
7
8import org.openstreetmap.josm.gui.MapFrame;
9import org.openstreetmap.josm.gui.MapView;
10
11/**
12 * A class implementing MapMode is able to be selected as an mode for map editing.
13 * As example scrolling the map is a MapMode, connecting Nodes to new LineSegments
14 * is another.
15 *
16 * MapModes should register/deregister all necessary listener on the map's view
17 * control.
18 */
19abstract public class MapMode extends AbstractAction {
20
21 /**
22 * The parent mapframe this mode belongs to.
23 */
24 protected final MapFrame mapFrame;
25
26 /**
27 * Construct a mapMode with the given icon and the given MapFrame
28 *
29 * @param iconName The filename of the icon.
30 * @param mapFrame The parent MapFrame, this MapMode belongs to.
31 */
32 public MapMode(String name, String iconName, int mnemonic, MapFrame mapFrame) {
33 super(name, new ImageIcon(iconName));
34 putValue(MNEMONIC_KEY, mnemonic);
35 this.mapFrame = mapFrame;
36 }
37
38 /**
39 * Register all listener to the mapView
40 * @param mapView The view, where the listener should be registered.
41 */
42 abstract public void registerListener(MapView mapView);
43
44 /**
45 * Unregister all listener previously registered.
46 * @param mapView The view from which the listener should be deregistered.
47 */
48 abstract public void unregisterListener(MapView mapView);
49
50 /**
51 * Call selectMapMode(this) on the parent mapFrame.
52 */
53 public void actionPerformed(ActionEvent e) {
54 mapFrame.selectMapMode(this);
55 }
56}
Note: See TracBrowser for help on using the repository browser.