Changeset 14053 in osm for applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
- Timestamp:
- 2009-03-10T13:45:35+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
r11103 r14053 28 28 public class Demo extends JFrame { 29 29 30 30 private static final long serialVersionUID = 1L; 31 31 32 public Demo() { 33 super("JMapViewer Demo"); 34 setSize(400, 400); 35 final JMapViewer map = new JMapViewer(); 36 // final JMapViewer map = new JMapViewer(new MemoryTileCache(),4); 37 // map.setTileLoader(new OsmFileCacheTileLoader(map)); 38 // new DefaultMapController(map); 39 setLayout(new BorderLayout()); 40 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 41 setExtendedState(JFrame.MAXIMIZED_BOTH); 42 JPanel panel = new JPanel(); 43 JPanel helpPanel = new JPanel(); 44 add(panel, BorderLayout.NORTH); 45 add(helpPanel, BorderLayout.SOUTH); 46 JLabel helpLabel = 47 new JLabel("Use right mouse button to move,\n " 48 + "left double click or mouse wheel to zoom."); 49 helpPanel.add(helpLabel); 50 JButton button = new JButton("setDisplayToFitMapMarkers"); 51 button.addActionListener(new ActionListener() { 32 public Demo() { 33 super("JMapViewer Demo"); 34 setSize(400, 400); 35 final JMapViewer map = new JMapViewer(); 36 // final JMapViewer map = new JMapViewer(new MemoryTileCache(),4); 37 // map.setTileLoader(new OsmFileCacheTileLoader(map)); 38 // new DefaultMapController(map); 39 setLayout(new BorderLayout()); 40 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 41 setExtendedState(JFrame.MAXIMIZED_BOTH); 42 JPanel panel = new JPanel(); 43 JPanel helpPanel = new JPanel(); 44 add(panel, BorderLayout.NORTH); 45 add(helpPanel, BorderLayout.SOUTH); 46 JLabel helpLabel = new JLabel("Use right mouse button to move,\n " 47 + "left double click or mouse wheel to zoom."); 48 helpPanel.add(helpLabel); 49 JButton button = new JButton("setDisplayToFitMapMarkers"); 50 button.addActionListener(new ActionListener() { 52 51 53 public void actionPerformed(ActionEvent e) { 54 map.setDisplayToFitMapMarkers(); 55 } 56 }); 57 JComboBox tileSourceSelector = 58 new JComboBox(new TileSource[] { new OsmTileSource.Mapnik(), 59 new OsmTileSource.TilesAtHome(), new OsmTileSource.CycleMap() }); 60 tileSourceSelector.addItemListener(new ItemListener() { 61 public void itemStateChanged(ItemEvent e) { 62 map.setTileSource((TileSource) e.getItem()); 63 } 64 }); 65 JComboBox tileLoaderSelector = 66 new JComboBox(new TileLoader[] { new OsmFileCacheTileLoader(map), 67 new OsmTileLoader(map) }); 68 tileLoaderSelector.addItemListener(new ItemListener() { 69 public void itemStateChanged(ItemEvent e) { 70 map.setTileLoader((TileLoader) e.getItem()); 71 } 72 }); 73 map.setTileLoader((TileLoader) tileLoaderSelector.getSelectedItem()); 74 panel.add(tileSourceSelector); 75 panel.add(tileLoaderSelector); 76 final JCheckBox showMapMarker = new JCheckBox("Map markers visible"); 77 showMapMarker.setSelected(map.getMapMarkersVisible()); 78 showMapMarker.addActionListener(new ActionListener() { 52 public void actionPerformed(ActionEvent e) { 53 map.setDisplayToFitMapMarkers(); 54 } 55 }); 56 JComboBox tileSourceSelector = new JComboBox(new TileSource[] { new OsmTileSource.Mapnik(), 57 new OsmTileSource.TilesAtHome(), new OsmTileSource.CycleMap() }); 58 tileSourceSelector.addItemListener(new ItemListener() { 59 public void itemStateChanged(ItemEvent e) { 60 map.setTileSource((TileSource) e.getItem()); 61 } 62 }); 63 JComboBox tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmFileCacheTileLoader(map), 64 new OsmTileLoader(map) }); 65 tileLoaderSelector.addItemListener(new ItemListener() { 66 public void itemStateChanged(ItemEvent e) { 67 map.setTileLoader((TileLoader) e.getItem()); 68 } 69 }); 70 map.setTileLoader((TileLoader) tileLoaderSelector.getSelectedItem()); 71 panel.add(tileSourceSelector); 72 panel.add(tileLoaderSelector); 73 final JCheckBox showMapMarker = new JCheckBox("Map markers visible"); 74 showMapMarker.setSelected(map.getMapMarkersVisible()); 75 showMapMarker.addActionListener(new ActionListener() { 79 76 80 81 82 83 84 85 86 87 77 public void actionPerformed(ActionEvent e) { 78 map.setMapMarkerVisible(showMapMarker.isSelected()); 79 } 80 }); 81 panel.add(showMapMarker); 82 final JCheckBox showTileGrid = new JCheckBox("Tile grid visible"); 83 showTileGrid.setSelected(map.isTileGridVisible()); 84 showTileGrid.addActionListener(new ActionListener() { 88 85 89 90 91 92 93 94 95 96 86 public void actionPerformed(ActionEvent e) { 87 map.setTileGridVisible(showTileGrid.isSelected()); 88 } 89 }); 90 panel.add(showTileGrid); 91 final JCheckBox showZoomControls = new JCheckBox("Show zoom controls"); 92 showZoomControls.setSelected(map.getZoomContolsVisible()); 93 showZoomControls.addActionListener(new ActionListener() { 97 94 98 99 100 101 102 103 104 95 public void actionPerformed(ActionEvent e) { 96 map.setZoomContolsVisible(showZoomControls.isSelected()); 97 } 98 }); 99 panel.add(showZoomControls); 100 panel.add(button); 101 add(map, BorderLayout.CENTER); 105 102 106 107 108 109 110 111 103 // 104 map.addMapMarker(new MapMarkerDot(49.814284999, 8.642065999)); 105 map.addMapMarker(new MapMarkerDot(49.91, 8.24)); 106 map.addMapMarker(new MapMarkerDot(49.71, 8.64)); 107 map.addMapMarker(new MapMarkerDot(48.71, -1)); 108 map.addMapMarker(new MapMarkerDot(49.8588, 8.643)); 112 109 113 114 115 110 // map.setDisplayPositionByLatLon(49.807, 8.6, 11); 111 // map.setTileGridVisible(true); 112 } 116 113 117 118 119 120 121 122 123 124 125 114 /** 115 * @param args 116 */ 117 public static void main(String[] args) { 118 // java.util.Properties systemProperties = System.getProperties(); 119 // systemProperties.setProperty("http.proxyHost", "localhost"); 120 // systemProperties.setProperty("http.proxyPort", "8008"); 121 new Demo().setVisible(true); 122 } 126 123 127 124 }
Note:
See TracChangeset
for help on using the changeset viewer.