- Timestamp:
- 2015-09-29T20:12:40+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r8540 r8806 15 15 import java.text.SimpleDateFormat; 16 16 import java.util.ArrayList; 17 import java.util.Arrays; 17 18 import java.util.Collection; 19 import java.util.Collections; 18 20 import java.util.Date; 19 21 import java.util.HashMap; … … 183 185 Marker.markerProducers.add(new MarkerProducers() { 184 186 @Override 185 public Marker createMarker(WayPoint wpt, File relativePath, MarkerLayer parentLayer, double time, double offset) {187 public Collection<Marker> createMarkers(WayPoint wpt, File relativePath, MarkerLayer parentLayer, double time, double offset) { 186 188 String uri = null; 187 189 // cheapest way to check whether "link" object exists and is a non-empty collection of GpxLink objects... … … 207 209 208 210 String urlStr = url == null ? "" : url.toString(); 211 String symbolName = wpt.getString("symbol"); 212 if (symbolName == null) { 213 symbolName = wpt.getString(GpxConstants.PT_SYM); 214 } 215 // text marker is returned in every case, see #10208 216 final Marker marker = new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset); 209 217 if (url == null) { 210 String symbolName = wpt.getString("symbol"); 211 if (symbolName == null) { 212 symbolName = wpt.getString(GpxConstants.PT_SYM); 213 } 214 return new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset); 218 return Collections.singleton(marker); 215 219 } else if (urlStr.endsWith(".wav")) { 216 AudioMarker audioMarker = new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset);220 final AudioMarker audioMarker = new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset); 217 221 Extensions exts = (Extensions) wpt.get(GpxConstants.META_EXTENSIONS); 218 222 if (exts != null && exts.containsKey("offset")) { … … 223 227 } 224 228 } 225 return audioMarker;229 return Arrays.asList(marker, audioMarker); 226 230 } else if (urlStr.endsWith(".png") || urlStr.endsWith(".jpg") || urlStr.endsWith(".jpeg") || urlStr.endsWith(".gif")) { 227 return new ImageMarker(wpt.getCoor(), url, parentLayer, time, offset); 231 final ImageMarker imageMarker = new ImageMarker(wpt.getCoor(), url, parentLayer, time, offset); 232 return Arrays.asList(marker, imageMarker); 228 233 } else { 229 return new WebMarker(wpt.getCoor(), url, parentLayer, time, offset); 234 final WebMarker webMarker = new WebMarker(wpt.getCoor(), url, parentLayer, time, offset); 235 return Arrays.asList(marker, webMarker); 230 236 } 231 237 } … … 246 252 * @return a new Marker object 247 253 */ 248 public static Marker createMarker(WayPoint wpt, File relativePath, MarkerLayer parentLayer, double time, double offset) {254 public static Collection<Marker> createMarkers(WayPoint wpt, File relativePath, MarkerLayer parentLayer, double time, double offset) { 249 255 for (MarkerProducers maker : Marker.markerProducers) { 250 Marker marker = maker.createMarker(wpt, relativePath, parentLayer, time, offset);251 if (marker != null)252 return marker ;256 final Collection<Marker> markers = maker.createMarkers(wpt, relativePath, parentLayer, time, offset); 257 if (markers != null) 258 return markers; 253 259 } 254 260 return null; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r8804 r8806 129 129 offset = time - firstTime; 130 130 } 131 Marker m = Marker.createMarker(wpt, indata.storageFile, this, time, offset);132 if (m != null) {133 data.add (m);131 final Collection<Marker> markers = Marker.createMarkers(wpt, indata.storageFile, this, time, offset); 132 if (markers != null) { 133 data.addAll(markers); 134 134 } 135 135 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerProducers.java
r6830 r8806 3 3 4 4 import java.io.File; 5 import java.util.Collection; 5 6 6 7 import org.openstreetmap.josm.data.gpx.WayPoint; … … 16 17 public interface MarkerProducers { 17 18 /** 18 * Returns a Marker objectif this implementation wants to create one for the19 * Returns a collection of Marker objects if this implementation wants to create one for the 19 20 * given input data, or <code>null</code> otherwise. 20 21 * … … 22 23 * @param relativePath An path to use for constructing relative URLs or 23 24 * <code>null</code> for no relative URLs 24 * @return A Marker object, or <code>null</code>.25 * @return A collection of Marker objects, or <code>null</code>. 25 26 */ 26 Marker createMarker(WayPoint wp, File relativePath, MarkerLayer parentLayer, double time, double offset);27 Collection<Marker> createMarkers(WayPoint wp, File relativePath, MarkerLayer parentLayer, double time, double offset); 27 28 }
Note:
See TracChangeset
for help on using the changeset viewer.