Ticket #6869: jmapviewer.2.diff

File jmapviewer.2.diff, 23.8 KB (added by jhuntley, 14 years ago)
  • org/openstreetmap/gui/jmapviewer/OsmMercator.java

     
    1818    private static int TILE_SIZE = 256;
    1919    public static final double MAX_LAT = 85.05112877980659;
    2020    public static final double MIN_LAT = -85.05112877980659;
     21    private static double EARTH_RADIUS_KM = 6371;
     22   
     23        private static double KMTOM=1000;
     24        private static double MTOKM=1/1000;
    2125
     26        public static double kmToMeters(double kmeters) {
     27                return kmeters*KMTOM;
     28        }
     29       
     30        public static double metersToKm(double meters) {
     31                return meters*MTOKM;
     32        }
     33       
    2234    public static double radius(int aZoomlevel) {
    2335        return (TILE_SIZE * (1 << aZoomlevel)) / (2.0 * Math.PI);
    2436    }
     
    4153    public static int falseNorthing(int aZoomlevel) {
    4254        return (-1 * getMaxPixels(aZoomlevel) / 2);
    4355    }
     56   
     57    /**
     58     * Transform pixelspace to coordinates and get the distance.
     59     *
     60     * @param x1 the first x coordinate
     61     * @param y1 the first y coordinate
     62     * @param x2 the second x coordinate
     63     * @param y2 the second y coordinate
     64     *
     65     * @param zoomLevel the zoom level
     66     * @return the distance
     67     * @author Jason Huntley
     68     */
     69    public static double getDistance(int x1, int y1, int x2, int y2, int zoomLevel) {
     70        double la1 = YToLat(y1, zoomLevel);
     71        double lo1 = XToLon(x1, zoomLevel);
     72        double la2 = YToLat(y2, zoomLevel);
     73        double lo2 = XToLon(x2, zoomLevel);
     74       
     75        return getDistance(la1, lo1, la2, lo2);
     76    }
     77   
     78        /**
     79         * Gets the distance using Spherical law of cosines.
     80         *
     81         * @param la1 the Latitude in degrees
     82         * @param lo1 the Longitude in degrees
     83         * @param la2 the Latitude from 2nd coordinate in degrees
     84         * @param lo2 the Longitude from 2nd coordinate in degrees
     85         * @return the distance
     86         * @author Jason Huntley
     87         */
     88        public static double getDistance(double la1, double lo1, double la2, double lo2) {
     89            double aStartLat = Math.toRadians(la1);
     90            double aStartLong = Math.toRadians(lo1);
     91            double aEndLat =Math.toRadians(la2);
     92            double aEndLong = Math.toRadians(lo2);
     93
     94            double distance = Math.acos(Math.sin(aStartLat) * Math.sin(aEndLat)
     95                + Math.cos(aStartLat) * Math.cos(aEndLat)
     96                * Math.cos(aEndLong - aStartLong));
     97
     98            return (EARTH_RADIUS_KM * distance);               
     99        }
    44100
    45101    /**
    46102     * Transform longitude to pixelspace
  • org/openstreetmap/gui/jmapviewer/JMapViewer.java

     
    2525import javax.swing.JSlider;
    2626import javax.swing.event.ChangeEvent;
    2727import javax.swing.event.ChangeListener;
     28import javax.swing.event.EventListenerList;
    2829
     30import org.openstreetmap.gui.jmapviewer.events.JMVCommandEvent;
     31import org.openstreetmap.gui.jmapviewer.events.JMVCommandEvent.COMMAND;
     32import org.openstreetmap.gui.jmapviewer.interfaces.JMapViewerEventListener;
    2933import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;
    3034import org.openstreetmap.gui.jmapviewer.interfaces.MapPolygon;
    3135import org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle;
     
    3640import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource;
    3741
    3842/**
    39  * 
     43 *
    4044 * Provides a simple panel that displays pre-rendered map tiles loaded from the
    4145 * OpenStreetMap project.
    42  * 
     46 *
    4347 * @author Jan Peter Stotz
    44  * 
     48 *
    4549 */
    4650public class JMapViewer extends JPanel implements TileLoaderListener {
    4751
     
    117121        tileSource = new OsmTileSource.Mapnik();
    118122        tileController = new TileController(tileSource, tileCache, this);
    119123        mapMarkerList = new LinkedList<MapMarker>();
     124         mapPolygonList = new LinkedList<MapPolygon>();
    120125        mapRectangleList = new LinkedList<MapRectangle>();
    121         mapPolygonList = new LinkedList<MapPolygon>();
    122126        mapMarkersVisible = true;
    123127        mapRectanglesVisible = true;
    124128        mapPolygonsVisible = true;
     
    187191    /**
    188192     * Changes the map pane so that it is centered on the specified coordinate
    189193     * at the given zoom level.
    190      * 
     194     *
    191195     * @param lat
    192196     *            latitude of the specified coordinate
    193197     * @param lon
     
    203207     * Changes the map pane so that the specified coordinate at the given zoom
    204208     * level is displayed on the map at the screen coordinate
    205209     * <code>mapPoint</code>.
    206      * 
     210     *
    207211     * @param mapPoint
    208212     *            point on the map denoted in pixels where the coordinate should
    209213     *            be set
     
    264268            nbElemToCheck += mapPolygonList.size();
    265269        if (nbElemToCheck == 0)
    266270            return;
    267        
     271
    268272        int x_min = Integer.MAX_VALUE;
    269273        int y_min = Integer.MAX_VALUE;
    270274        int x_max = Integer.MIN_VALUE;
    271275        int y_max = Integer.MIN_VALUE;
    272276        int mapZoomMax = tileController.getTileSource().getMaxZoom();
    273        
     277
    274278        if (markers) {
    275279            for (MapMarker marker : mapMarkerList) {
    276280                int x = OsmMercator.LonToX(marker.getLon(), mapZoomMax);
     
    290294                y_min = Math.min(y_min, OsmMercator.LatToY(rectangle.getBottomRight().getLat(), mapZoomMax));
    291295            }
    292296        }
    293        
     297
    294298        if (polygons) {
    295299            for (MapPolygon polygon : mapPolygonList) {
    296300                for (Coordinate c : polygon.getPoints()) {
     
    303307                }
    304308            }
    305309        }
    306        
     310
    307311        int height = Math.max(0, getHeight());
    308312        int width = Math.max(0, getWidth());
    309313        int newZoom = mapZoomMax;
     
    321325        y /= z;
    322326        setDisplayPosition(x, y, newZoom);
    323327    }
    324    
     328
     329
    325330    /**
    326331     * Sets the displayed map pane and zoom level so that all map markers are
    327332     * visible.
     
    337342    public void setDisplayToFitMapRectangles() {
    338343        setDisplayToFitMapElements(false, true, false);
    339344    }
    340    
     345
    341346    /**
    342347     * Sets the displayed map pane and zoom level so that all map polygons are
    343348     * visible.
     
    347352    }
    348353
    349354    /**
     355         * @return the center
     356         */
     357        public Point getCenter() {
     358                return center;
     359        }
     360
     361        /**
     362         * @param center the center to set
     363         */
     364        public void setCenter(Point center) {
     365                this.center = center;
     366        }
     367
     368        /**
    350369     * Calculates the latitude/longitude coordinate of the center of the
    351370     * currently displayed map area.
    352      * 
     371     *
    353372     * @return latitude / longitude
    354373     */
    355374    public Coordinate getPosition() {
     
    361380    /**
    362381     * Converts the relative pixel coordinate (regarding the top left corner of
    363382     * the displayed map) into a latitude / longitude coordinate
    364      * 
     383     *
    365384     * @param mapPoint
    366385     *            relative pixel coordinate regarding the top left corner of the
    367386     *            displayed map
     
    374393    /**
    375394     * Converts the relative pixel coordinate (regarding the top left corner of
    376395     * the displayed map) into a latitude / longitude coordinate
    377      * 
     396     *
    378397     * @param mapPointX
    379398     * @param mapPointY
    380399     * @return
     
    389408
    390409    /**
    391410     * Calculates the position on the map of a given coordinate
    392      * 
     411     *
    393412     * @param lat
    394413     * @param lon
    395414     * @param checkOutside
     
    410429
    411430    /**
    412431     * Calculates the position on the map of a given coordinate
    413      * 
     432     *
    414433     * @param lat
    415434     * @param lon
    416435     * @return point on the map or <code>null</code> if the point is not visible
     
    421440
    422441    /**
    423442     * Calculates the position on the map of a given coordinate
    424      * 
     443     *
    425444     * @param coord
    426445     * @return point on the map or <code>null</code> if the point is not visible
    427446     */
     
    434453
    435454    /**
    436455     * Calculates the position on the map of a given coordinate
    437      * 
     456     *
    438457     * @param coord
    439458     * @return point on the map or <code>null</code> if the point is not visible
    440459     *         and checkOutside set to <code>true</code>
     
    446465            return null;
    447466    }
    448467
    449     @Override
     468        /**
     469         * Gets the meter per pixel.
     470         *
     471         * @return the meter per pixel
     472         * @author Jason Huntley
     473         */
     474        public double getMeterPerPixel() {
     475                Point origin=new Point(5,5);
     476                Point center=new Point(getWidth()/2, getHeight()/2);
     477
     478                double pDistance=center.distance(origin);
     479
     480                Coordinate originCoord=getPosition(origin);
     481                Coordinate centerCoord=getPosition(center);
     482
     483                double kmDistance=OsmMercator.getDistance(originCoord.getLat(), originCoord.getLon(),
     484                                centerCoord.getLat(), centerCoord.getLon());
     485
     486                double mDistance=OsmMercator.kmToMeters(kmDistance);
     487
     488                return mDistance/pDistance;
     489        }
     490
     491        @Override
    450492    protected void paintComponent(Graphics g) {
    451493        super.paintComponent(g);
    452494
     
    542584                paintMarker(g, marker);
    543585            }
    544586        }
     587
    545588        paintAttribution(g);
    546589    }
    547590
     
    587630            polygon.paint(g, points);
    588631        }
    589632    }
    590    
     633
    591634    /**
    592635     * Moves the visible map pane.
    593      * 
     636     *
    594637     * @param x
    595638     *            horizontal movement in pixel.
    596639     * @param y
     
    645688        tileController.cancelOutstandingJobs(); // Clearing outstanding load
    646689        // requests
    647690        setDisplayPositionByLatLon(mapPoint, zoomPos.getLat(), zoomPos.getLon(), zoom);
     691
     692        this.fireJMVEvent(new JMVCommandEvent(COMMAND.ZOOM, this));
    648693    }
    649694
    650695    public void setZoom(int zoom) {
     
    655700     * Every time the zoom level changes this method is called. Override it in
    656701     * derived implementations for adapting zoom dependent values. The new zoom
    657702     * level can be obtained via {@link #getZoom()}.
    658      * 
     703     *
    659704     * @param oldZoom
    660705     *            the previous zoom level
    661706     */
     
    682727
    683728    /**
    684729     * Enables or disables painting of the {@link MapMarker}
    685      * 
     730     *
    686731     * @param mapMarkersVisible
    687732     * @see #addMapMarker(MapMarker)
    688733     * @see #getMapMarkerList()
     
    763808        mapPolygonList.clear();
    764809        repaint();
    765810    }
    766    
     811
    767812    public void setZoomContolsVisible(boolean visible) {
    768813        zoomSlider.setVisible(visible);
    769814        zoomInButton.setVisible(visible);
     
    808853
    809854    /**
    810855     * Enables or disables painting of the {@link MapRectangle}
    811      * 
     856     *
    812857     * @param mapRectanglesVisible
    813858     * @see #addMapRectangle(MapRectangle)
    814859     * @see #getMapRectangleList()
     
    824869
    825870    /**
    826871     * Enables or disables painting of the {@link MapPolygon}
    827      * 
     872     *
    828873     * @param mapPolygonsVisible
    829874     * @see #addMapPolygon(MapPolygon)
    830875     * @see #getMapPolygonList()
     
    836881
    837882    /*
    838883     * (non-Javadoc)
    839      * 
     884     *
    840885     * @see
    841886     * org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener#getTileCache
    842887     * ()
     
    898943
    899944        g.setFont(font);
    900945    }
     946
     947    protected EventListenerList listenerList = new EventListenerList();
     948
     949        /**
     950         * @param listener to set
     951         */
     952        public void addJMVListener(JMapViewerEventListener listener) {
     953                listenerList.add(JMapViewerEventListener.class, listener);
     954        }
     955
     956        public void removeJMVListener(JMapViewerEventListener listener) {
     957                listenerList.remove(JMapViewerEventListener.class, listener);
     958        }
     959
     960    void fireJMVEvent(JMVCommandEvent evt) {
     961        Object[] listeners = listenerList.getListenerList();
     962        for (int i=0; i<listeners.length; i+=2) {
     963            if (listeners[i]==JMapViewerEventListener.class) {
     964                ((JMapViewerEventListener)listeners[i+1]).processCommand(evt);
     965            }
     966        }
     967    }
    901968}
  • org/openstreetmap/gui/jmapviewer/Demo.java

     
    1616import javax.swing.JLabel;
    1717import javax.swing.JPanel;
    1818
     19import org.openstreetmap.gui.jmapviewer.events.JMVCommandEvent;
     20import org.openstreetmap.gui.jmapviewer.interfaces.JMapViewerEventListener;
    1921import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    2022import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    2123import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource;
     
    2830 * @author Jan Peter Stotz
    2931 *
    3032 */
    31 public class Demo extends JFrame {
     33public class Demo extends JFrame implements JMapViewerEventListener  {
     34
     35        private static final long serialVersionUID = 1L;
     36
     37        private JMapViewer map = null;
     38
     39        private JLabel zoomLabel=null;
     40        private JLabel zoomValue=null;
     41
     42        private JLabel mperpLabelName=null;
     43        private JLabel mperpLabelValue = null;
     44
     45        public Demo() {
     46                super("JMapViewer Demo");
     47                setSize(400, 400);
     48
     49                map = new JMapViewer();
     50
     51                // Listen to the map viewer for user operations so components will
     52                // recieve events and update
     53                map.addJMVListener(this);
     54
     55                // final JMapViewer map = new JMapViewer(new MemoryTileCache(),4);
     56                // map.setTileLoader(new OsmFileCacheTileLoader(map));
     57                // new DefaultMapController(map);
     58
     59                setLayout(new BorderLayout());
     60                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     61                setExtendedState(JFrame.MAXIMIZED_BOTH);
     62                JPanel panel = new JPanel();
     63                JPanel helpPanel = new JPanel();
     64
     65                mperpLabelName=new JLabel("Meters/Pixels: ");
     66                mperpLabelValue=new JLabel(String.format("%s",map.getMeterPerPixel()));
    3267
    33     private static final long serialVersionUID = 1L;
     68                zoomLabel=new JLabel("Zoom: ");
     69                zoomValue=new JLabel(String.format("%s", map.getZoom()));
    3470
    35     public Demo() {
    36         super("JMapViewer Demo");
    37         setSize(400, 400);
    38         final JMapViewer map = new JMapViewer();
    39         // final JMapViewer map = new JMapViewer(new MemoryTileCache(),4);
    40         // map.setTileLoader(new OsmFileCacheTileLoader(map));
    41         // new DefaultMapController(map);
    42         setLayout(new BorderLayout());
    43         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    44         setExtendedState(JFrame.MAXIMIZED_BOTH);
    45         JPanel panel = new JPanel();
    46         JPanel helpPanel = new JPanel();
    47         add(panel, BorderLayout.NORTH);
    48         add(helpPanel, BorderLayout.SOUTH);
    49         JLabel helpLabel = new JLabel("Use right mouse button to move,\n "
    50                 + "left double click or mouse wheel to zoom.");
    51         helpPanel.add(helpLabel);
    52         JButton button = new JButton("setDisplayToFitMapMarkers");
    53         button.addActionListener(new ActionListener() {
     71                add(panel, BorderLayout.NORTH);
     72                add(helpPanel, BorderLayout.SOUTH);
     73                JLabel helpLabel = new JLabel("Use right mouse button to move,\n "
     74                                + "left double click or mouse wheel to zoom.");
     75                helpPanel.add(helpLabel);
     76                JButton button = new JButton("setDisplayToFitMapMarkers");
     77                button.addActionListener(new ActionListener() {
    5478
    55             public void actionPerformed(ActionEvent e) {
    56                 map.setDisplayToFitMapMarkers();
    57             }
    58         });
    59         JComboBox tileSourceSelector = new JComboBox(new TileSource[] { new OsmTileSource.Mapnik(),
    60                 new OsmTileSource.TilesAtHome(), new OsmTileSource.CycleMap(), new BingAerialTileSource() });
    61         tileSourceSelector.addItemListener(new ItemListener() {
    62             public void itemStateChanged(ItemEvent e) {
    63                 map.setTileSource((TileSource) e.getItem());
    64             }
    65         });
    66         JComboBox tileLoaderSelector;
    67         try {
    68             tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmFileCacheTileLoader(map),
    69                     new OsmTileLoader(map) });
    70         } catch (IOException e) {
    71             tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmTileLoader(map) });
    72         }
    73         tileLoaderSelector.addItemListener(new ItemListener() {
    74             public void itemStateChanged(ItemEvent e) {
    75                 map.setTileLoader((TileLoader) e.getItem());
    76             }
    77         });
    78         map.setTileLoader((TileLoader) tileLoaderSelector.getSelectedItem());
    79         panel.add(tileSourceSelector);
    80         panel.add(tileLoaderSelector);
    81         final JCheckBox showMapMarker = new JCheckBox("Map markers visible");
    82         showMapMarker.setSelected(map.getMapMarkersVisible());
    83         showMapMarker.addActionListener(new ActionListener() {
     79                        public void actionPerformed(ActionEvent e) {
     80                                map.setDisplayToFitMapMarkers();
     81                        }
     82                });
     83                JComboBox tileSourceSelector = new JComboBox(new TileSource[] { new OsmTileSource.Mapnik(),
     84                                new OsmTileSource.TilesAtHome(), new OsmTileSource.CycleMap(), new BingAerialTileSource() });
     85                tileSourceSelector.addItemListener(new ItemListener() {
     86                        public void itemStateChanged(ItemEvent e) {
     87                                map.setTileSource((TileSource) e.getItem());
     88                        }
     89                });
     90                JComboBox tileLoaderSelector;
     91                try {
     92                        tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmFileCacheTileLoader(map),
     93                                        new OsmTileLoader(map) });
     94                } catch (IOException e) {
     95                        tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmTileLoader(map) });
     96                }
     97                tileLoaderSelector.addItemListener(new ItemListener() {
     98                        public void itemStateChanged(ItemEvent e) {
     99                                map.setTileLoader((TileLoader) e.getItem());
     100                        }
     101                });
     102                map.setTileLoader((TileLoader) tileLoaderSelector.getSelectedItem());
     103                panel.add(tileSourceSelector);
     104                panel.add(tileLoaderSelector);
     105                final JCheckBox showMapMarker = new JCheckBox("Map markers visible");
     106                showMapMarker.setSelected(map.getMapMarkersVisible());
     107                showMapMarker.addActionListener(new ActionListener() {
    84108
    85             public void actionPerformed(ActionEvent e) {
    86                 map.setMapMarkerVisible(showMapMarker.isSelected());
    87             }
    88         });
    89         panel.add(showMapMarker);
    90         final JCheckBox showTileGrid = new JCheckBox("Tile grid visible");
    91         showTileGrid.setSelected(map.isTileGridVisible());
    92         showTileGrid.addActionListener(new ActionListener() {
     109                        public void actionPerformed(ActionEvent e) {
     110                                map.setMapMarkerVisible(showMapMarker.isSelected());
     111                        }
     112                });
     113                panel.add(showMapMarker);
     114                final JCheckBox showTileGrid = new JCheckBox("Tile grid visible");
     115                showTileGrid.setSelected(map.isTileGridVisible());
     116                showTileGrid.addActionListener(new ActionListener() {
    93117
    94             public void actionPerformed(ActionEvent e) {
    95                 map.setTileGridVisible(showTileGrid.isSelected());
    96             }
    97         });
    98         panel.add(showTileGrid);
    99         final JCheckBox showZoomControls = new JCheckBox("Show zoom controls");
    100         showZoomControls.setSelected(map.getZoomContolsVisible());
    101         showZoomControls.addActionListener(new ActionListener() {
     118                        public void actionPerformed(ActionEvent e) {
     119                                map.setTileGridVisible(showTileGrid.isSelected());
     120                        }
     121                });
     122                panel.add(showTileGrid);
     123                final JCheckBox showZoomControls = new JCheckBox("Show zoom controls");
     124                showZoomControls.setSelected(map.getZoomContolsVisible());
     125                showZoomControls.addActionListener(new ActionListener() {
    102126
    103             public void actionPerformed(ActionEvent e) {
    104                 map.setZoomContolsVisible(showZoomControls.isSelected());
    105             }
    106         });
    107         panel.add(showZoomControls);
    108         panel.add(button);
    109         add(map, BorderLayout.CENTER);
     127                        public void actionPerformed(ActionEvent e) {
     128                                map.setZoomContolsVisible(showZoomControls.isSelected());
     129                        }
     130                });
     131                panel.add(showZoomControls);
     132                panel.add(button);
    110133
    111         //
    112         map.addMapMarker(new MapMarkerDot(49.814284999, 8.642065999));
    113         map.addMapMarker(new MapMarkerDot(49.91, 8.24));
    114         map.addMapMarker(new MapMarkerDot(49.71, 8.64));
    115         map.addMapMarker(new MapMarkerDot(48.71, -1));
    116         map.addMapMarker(new MapMarkerDot(49.8588, 8.643));
     134                panel.add(zoomLabel);
     135                panel.add(zoomValue);
     136                panel.add(mperpLabelName);
     137                panel.add(mperpLabelValue);
    117138
    118         // map.setDisplayPositionByLatLon(49.807, 8.6, 11);
    119         // map.setTileGridVisible(true);
    120     }
     139                add(map, BorderLayout.CENTER);
    121140
    122     /**
    123      * @param args
    124      */
    125     public static void main(String[] args) {
    126         // java.util.Properties systemProperties = System.getProperties();
    127         // systemProperties.setProperty("http.proxyHost", "localhost");
    128         // systemProperties.setProperty("http.proxyPort", "8008");
    129         new Demo().setVisible(true);
    130     }
     141                //
     142                map.addMapMarker(new MapMarkerDot(49.814284999, 8.642065999));
     143                map.addMapMarker(new MapMarkerDot(49.91, 8.24));
     144                map.addMapMarker(new MapMarkerDot(49.71, 8.64));
     145                map.addMapMarker(new MapMarkerDot(48.71, -1));
     146                map.addMapMarker(new MapMarkerDot(49.8588, 8.643));
     147
     148                // map.setDisplayPositionByLatLon(49.807, 8.6, 11);
     149                // map.setTileGridVisible(true);
     150        }
     151
     152        /**
     153         * @param args
     154         */
     155        public static void main(String[] args) {
     156                // java.util.Properties systemProperties = System.getProperties();
     157                // systemProperties.setProperty("http.proxyHost", "localhost");
     158                // systemProperties.setProperty("http.proxyPort", "8008");
     159                new Demo().setVisible(true);
     160        }
     161
     162        private void updateZoomParameters() {
     163                if (mperpLabelValue!=null)
     164                        mperpLabelValue.setText(String.format("%s",map.getMeterPerPixel()));
     165                if (zoomValue!=null)
     166                        zoomValue.setText(String.format("%s", map.getZoom()));
     167        }
     168
     169        @Override
     170        public void processCommand(JMVCommandEvent command) {
     171                if (command.getCommand().equals(JMVCommandEvent.COMMAND.ZOOM)) {
     172                        updateZoomParameters();
     173                }
     174        }
    131175
    132176}
  • org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java

     
     1/**
     2 *
     3 */
     4package org.openstreetmap.gui.jmapviewer.events;
     5
     6import java.util.EventObject;
     7
     8/**
     9 * @author Jason Huntley
     10 *
     11 */
     12public class JMVCommandEvent extends EventObject {
     13        public static enum COMMAND {
     14                ZOOM
     15        }
     16       
     17        private COMMAND command;
     18        /**
     19         *
     20         */
     21        private static final long serialVersionUID = 8701544867914969620L;
     22       
     23        public JMVCommandEvent(COMMAND cmd, Object source) {
     24                super(source);
     25               
     26                setCommand(cmd);
     27        }
     28
     29        public JMVCommandEvent(Object source) {
     30                super(source);
     31        }
     32
     33        /**
     34         * @return the command
     35         */
     36        public COMMAND getCommand() {
     37                return command;
     38        }
     39
     40        /**
     41         * @param command the command to set
     42         */
     43        public void setCommand(COMMAND command) {
     44                this.command = command;
     45        }
     46}
  • org/openstreetmap/gui/jmapviewer/interfaces/JMapViewerEventListener.java

    Property changes on: org\openstreetmap\gui\jmapviewer\events\JMVCommandEvent.java
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
     1/**
     2 *
     3 */
     4package org.openstreetmap.gui.jmapviewer.interfaces;
     5
     6import java.util.EventListener;
     7
     8import org.openstreetmap.gui.jmapviewer.events.JMVCommandEvent;
     9
     10/**
     11 * @author Jason Huntley
     12 *
     13 */
     14public interface JMapViewerEventListener extends EventListener {
     15        public void processCommand(JMVCommandEvent command);
     16}