Changeset 200 in josm
- Timestamp:
- 2007-02-14T16:21:14+01:00 (18 years ago)
- Files:
-
- 12 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/OpenAction.java
r189 r200 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.data.osm.DataSet; 20 import org.openstreetmap.josm.gui.layer.MarkerLayer;21 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 21 import org.openstreetmap.josm.gui.layer.RawGpsLayer; 23 import org.openstreetmap.josm.gui.layer.MarkerLayer.Marker;24 22 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 23 import org.openstreetmap.josm.gui.layer.markerlayer.Marker; 24 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 25 25 import org.openstreetmap.josm.io.OsmReader; 26 26 import org.openstreetmap.josm.io.RawCsvReader; -
src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r181 r200 53 53 static JList instance; 54 54 private JScrollPane listScrollPane; 55 55 56 56 public final static class DeleteLayerAction extends AbstractAction { 57 57 … … 91 91 Layer l = layer == null ? (Layer)instance.getSelectedValue() : layer; 92 92 l.visible = !l.visible; 93 Main.map.mapView.repaint(); 94 instance.repaint(); 95 } 96 } 97 98 public final static class ShowHideMarkerText extends AbstractAction { 99 private final Layer layer; 100 101 public ShowHideMarkerText(Layer layer) { 102 super(tr("Show/Hide Text"), ImageProvider.get("dialogs", "showhide")); 103 putValue(SHORT_DESCRIPTION, tr("Toggle visible state of the marker text.")); 104 putValue("help", "Dialog/LayerList/ShowHideText"); 105 this.layer = layer; 106 } 107 108 public void actionPerformed(ActionEvent e) { 109 Layer l = layer == null ? (Layer)instance.getSelectedValue() : layer; 110 String current = Main.pref.get("marker.show "+l.name,"show"); 111 Main.pref.put("marker.show "+l.name, current.equalsIgnoreCase("show") ? "hide" : "show"); 93 112 Main.map.mapView.repaint(); 94 113 instance.repaint(); -
src/org/openstreetmap/josm/io/RawGpsReader.java
r189 r200 8 8 import java.util.ArrayList; 9 9 import java.util.Collection; 10 import java.util.HashMap; 10 11 import java.util.LinkedList; 11 12 import java.util.Stack; 12 13 13 14 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.gui.layer.MarkerLayer.Marker;15 15 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 16 import org.openstreetmap.josm.gui.layer.markerlayer.Marker; 16 17 import org.xml.sax.Attributes; 17 18 import org.xml.sax.SAXException; … … 43 44 private Collection<GpsPoint> current = new LinkedList<GpsPoint>(); 44 45 private LatLon currentLatLon; 45 private String currentTime = ""; 46 private String currentName = ""; 46 private HashMap<String, String> currentTagValues = new HashMap<String, String>(); 47 47 private Stack<String> tags = new Stack<String>(); 48 48 … … 50 50 if (qName.equals("wpt") || qName.equals("trkpt")) { 51 51 try { 52 double lat = Double.parseDouble(atts.getValue("lat")); 53 double lon = Double.parseDouble(atts.getValue("lon")); 54 if (Math.abs(lat) > 90) 55 throw new SAXException(tr("Data error: lat value \"{0}\" is out of bound.", lat)); 56 if (Math.abs(lon) > 180) 57 throw new SAXException(tr("Data error: lon value \"{0}\" is out of bound.", lon)); 58 currentLatLon = new LatLon(lat, lon); 59 } catch (NumberFormatException e) { 60 e.printStackTrace(); 61 throw new SAXException(e); 62 } 63 currentTime = ""; 64 currentName = ""; 52 double lat = Double.parseDouble(atts.getValue("lat")); 53 double lon = Double.parseDouble(atts.getValue("lon")); 54 if (Math.abs(lat) > 90) 55 throw new SAXException(tr("Data error: lat value \"{0}\" is out of bound.", lat)); 56 if (Math.abs(lon) > 180) 57 throw new SAXException(tr("Data error: lon value \"{0}\" is out of bound.", lon)); 58 currentLatLon = new LatLon(lat, lon); 59 } catch (NumberFormatException e) { 60 e.printStackTrace(); 61 throw new SAXException(e); 62 } 63 currentTagValues.clear(); 65 64 } 66 65 tags.push(qName); … … 69 68 @Override public void characters(char[] ch, int start, int length) { 70 69 String peek = tags.peek(); 71 if (peek.equals("time") || peek.equals("name")) { 70 if (peek.equals("time") || peek.equals("name") || peek.equals("link") || peek.equals("symbol")) { 72 71 String tag = tags.pop(); 73 72 if (tags.empty() || (!tags.peek().equals("wpt") && !tags.peek().equals("trkpt"))) { … … 76 75 } 77 76 String contents = new String(ch, start, length); 78 if (peek.equals("time")) currentTime += contents; else currentName += contents; 77 String oldContents = currentTagValues.get(peek); 78 if (oldContents == null) { 79 currentTagValues.put(peek, contents); 80 } else { 81 currentTagValues.put(peek, oldContents + contents); 82 } 79 83 tags.push(tag); 80 84 } … … 83 87 @Override public void endElement(String namespaceURI, String localName, String qName) { 84 88 if (qName.equals("trkpt")) { 85 current.add(new GpsPoint(currentLatLon, currentTime)); 86 currentTime = ""; 87 currentName = ""; 89 current.add(new GpsPoint(currentLatLon, currentTagValues.get("time"))); 90 currentTagValues.clear(); 88 91 } else if (qName.equals("wpt")) { 89 markerData.add(new Marker(currentLatLon, currentName, null)); 90 currentTime = ""; 91 currentName = ""; 92 markerData.add(Marker.createMarker(currentLatLon, currentTagValues)); 93 currentTagValues.clear(); 92 94 } else if (qName.equals("trkseg") || qName.equals("trk") || qName.equals("gpx")) { 93 95 newTrack(); 94 currentTime = ""; 95 currentName = ""; 96 currentTagValues.clear(); 96 97 } 97 98 tags.pop(); 98 99 } 99 100 100 101 private void newTrack() { -
src/org/openstreetmap/josm/tools/ImageProvider.java
r159 r200 52 52 */ 53 53 public static ImageIcon get(String subdir, String name) { 54 if (subdir != "") 54 ImageIcon icon = getIfAvailable(subdir, name); 55 if (icon == null) { 56 String ext = name.indexOf('.') != -1 ? "" : ".png"; 57 throw new NullPointerException("/images/"+subdir+name+ext+" not found"); 58 } 59 return icon; 60 } 61 62 /** 63 * Like {@link #get(String)}, but does not throw and return <code>null</code> 64 * in case of nothing is found. Use this, if the image to retrieve is optional. 65 */ 66 public static ImageIcon getIfAvailable(String subdir, String name) { 67 if (name == null) 68 return null; 69 if (subdir == null || subdir != "") 55 70 subdir += "/"; 56 71 String ext = name.indexOf('.') != -1 ? "" : ".png"; -
src/org/openstreetmap/josm/tools/OpenBrowser.java
r149 r200 2 2 3 3 import java.io.IOException; 4 import java.net.MalformedURLException; 5 import java.net.URL; 6 7 import javax.swing.JApplet; 8 9 import org.openstreetmap.josm.Main; 4 10 5 11 /** … … 13 19 */ 14 20 public static String displayUrl(String url) { 21 if (Main.applet) { 22 try { 23 JApplet applet = (JApplet) Main.parent; 24 applet.getAppletContext().showDocument(new URL(url)); 25 return null; 26 } catch (MalformedURLException mue) { 27 return mue.getMessage(); 28 } 29 } 30 15 31 String os = System.getProperty("os.name"); 16 32 if (os == null) … … 37 53 private static void linux(String url) throws IOException { 38 54 try { 39 40 41 42 55 Runtime.getRuntime().exec("gnome-open " + url); 56 } catch (IOException e) { 57 Runtime.getRuntime().exec("kfmclient openURL " + url); 58 } 43 59 } 44 60
Note:
See TracChangeset
for help on using the changeset viewer.