Ignore:
Timestamp:
2005-10-02T20:32:00+02:00 (21 years ago)
Author:
imi
Message:

added mapmodes for adding and combining stuff. Reorganized images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    r4 r7  
    22
    33import java.awt.event.ActionEvent;
     4import java.awt.event.MouseEvent;
     5import java.awt.event.MouseListener;
     6import java.awt.event.MouseMotionListener;
    47
    58import javax.swing.AbstractAction;
    69import javax.swing.ImageIcon;
     10import javax.swing.JComponent;
     11import javax.swing.KeyStroke;
    712
     13import org.openstreetmap.josm.data.osm.DataSet;
    814import org.openstreetmap.josm.gui.MapFrame;
    915import org.openstreetmap.josm.gui.MapView;
     
    1723 * control.
    1824 */
    19 abstract public class MapMode extends AbstractAction {
     25abstract public class MapMode extends AbstractAction implements MouseListener, MouseMotionListener {
    2026
    2127        /**
     
    2329         */
    2430        protected final MapFrame mapFrame;
     31        /**
     32         * Shortcut to the MapView.
     33         */
     34        protected final MapView mv;
     35        /**
     36         * Shortcut to the DataSet.
     37         */
     38        protected final DataSet ds;
    2539
    2640        /**
     
    3145         */
    3246        public MapMode(String name, String iconName, String tooltip, int mnemonic, MapFrame mapFrame) {
    33                 super(name, new ImageIcon("images/"+iconName+".png"));
     47                super(name, new ImageIcon("images/mapmode/"+iconName+".png"));
    3448                putValue(MNEMONIC_KEY, mnemonic);
     49                putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(mnemonic,0));
    3550                putValue(LONG_DESCRIPTION, tooltip);
     51                mapFrame.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(mnemonic,0), this);
     52                mapFrame.getActionMap().put(this, this);
    3653                this.mapFrame = mapFrame;
     54                mv = mapFrame.mapView;
     55                ds = mv.dataSet;
    3756        }
    3857       
     
    4160         * @param mapView       The view, where the listener should be registered.
    4261         */
    43         abstract public void registerListener(MapView mapView);
     62        public void registerListener() {
     63                firePropertyChange("active", false, true);
     64        }
    4465       
    4566        /**
     
    4768         * @param mapView       The view from which the listener should be deregistered.
    4869         */
    49         abstract public void unregisterListener(MapView mapView);
     70        public void unregisterListener() {
     71                firePropertyChange("active", true, false);
     72        }
    5073
    5174        /**
     
    5578                mapFrame.selectMapMode(this);
    5679        }
     80       
     81        /**
     82         * Does nothing. Only to subclass.
     83         */
     84        public void mouseClicked(MouseEvent e) {}
     85        /**
     86         * Does nothing. Only to subclass.
     87         */
     88        public void mousePressed(MouseEvent e) {}
     89        /**
     90         * Does nothing. Only to subclass.
     91         */
     92        public void mouseReleased(MouseEvent e) {}
     93        /**
     94         * Does nothing. Only to subclass.
     95         */
     96        public void mouseEntered(MouseEvent e) {}
     97        /**
     98         * Does nothing. Only to subclass.
     99         */
     100        public void mouseExited(MouseEvent e) {}
     101        /**
     102         * Does nothing. Only to subclass.
     103         */
     104        public void mouseMoved(MouseEvent e) {}
     105        /**
     106         * Does nothing. Only to subclass.
     107         */
     108        public void mouseDragged(MouseEvent e) {}
    57109}
Note: See TracChangeset for help on using the changeset viewer.