Changeset 4282 in josm for trunk/src/org/openstreetmap/josm/gui/layer/markerlayer
- Timestamp:
- 2011-08-07T09:08:29+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java
r1685 r4282 8 8 import org.openstreetmap.josm.data.coor.LatLon; 9 9 import org.openstreetmap.josm.tools.AudioPlayer; 10 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 10 11 11 12 /** … … 22 23 public boolean timeFromAudio = false; // as opposed to from the GPX track 23 24 24 /** 25 * Verifies the parameter whether a new AudioMarker can be created and return 26 * one or return <code>null</code>. 27 */ 28 public static AudioMarker create(LatLon ll, String text, String url, MarkerLayer parentLayer, double time, double offset) { 29 try { 30 return new AudioMarker(ll, text, new URL(url), parentLayer, time, offset); 31 } catch (Exception ex) { 32 return null; 33 } 34 } 35 36 private AudioMarker(LatLon ll, String text, URL audioUrl, MarkerLayer parentLayer, double time, double offset) { 37 super(ll, text, "speech.png", parentLayer, time, offset); 25 public AudioMarker(LatLon ll, TemplateEngineDataProvider dataProvider, URL audioUrl, MarkerLayer parentLayer, double time, double offset) { 26 super(ll, dataProvider, "speech.png", parentLayer, time, offset); 38 27 this.audioUrl = audioUrl; 39 28 this.syncOffset = 0.0; … … 84 73 } 85 74 86 public static String inventName (double offset) { 87 int wholeSeconds = (int)(offset + 0.5); 88 if (wholeSeconds < 60) 89 return Integer.toString(wholeSeconds); 90 else if (wholeSeconds < 3600) 91 return String.format("%d:%02d", wholeSeconds / 60, wholeSeconds % 60); 92 else 93 return String.format("%d:%02d:%02d", wholeSeconds / 3600, (wholeSeconds % 3600)/60, wholeSeconds % 60); 75 @Override 76 protected TemplateEntryProperty getTextTemplate() { 77 return TemplateEntryProperty.forAudioMarker(parentLayer.getName()); 94 78 } 95 79 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java
r3396 r4282 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.gui.MapView; 16 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 16 17 17 18 /** … … 26 27 27 28 public ButtonMarker(LatLon ll, String buttonImage, MarkerLayer parentLayer, double time, double offset) { 28 super(ll, "", buttonImage, parentLayer, time, offset);29 super(ll, null, buttonImage, parentLayer, time, offset); 29 30 buttonRectangle = new Rectangle(0, 0, symbol.getIconWidth(), symbol.getIconHeight()); 30 31 } 31 32 32 public ButtonMarker(LatLon ll, String text, String buttonImage, MarkerLayer parentLayer, double time, double offset) {33 super(ll, text, buttonImage, parentLayer, time, offset);33 public ButtonMarker(LatLon ll, TemplateEngineDataProvider dataProvider, String buttonImage, MarkerLayer parentLayer, double time, double offset) { 34 super(ll, dataProvider, buttonImage, parentLayer, time, offset); 34 35 buttonRectangle = new Rectangle(0, 0, symbol.getIconWidth(), symbol.getIconHeight()); 35 36 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java
r1847 r4282 34 34 public URL imageUrl; 35 35 36 public static ImageMarker create(LatLon ll, String url, MarkerLayer parentLayer, double time, double offset) { 37 try { 38 return new ImageMarker(ll, new URL(url), parentLayer, time, offset); 39 } catch (Exception ex) { 40 return null; 41 } 42 } 43 44 private ImageMarker(LatLon ll, URL imageUrl, MarkerLayer parentLayer, double time, double offset) { 36 public ImageMarker(LatLon ll, URL imageUrl, MarkerLayer parentLayer, double time, double offset) { 45 37 super(ll, "photo.png", parentLayer, time, offset); 46 38 this.imageUrl = imageUrl; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r4172 r4282 5 5 import java.awt.Point; 6 6 import java.awt.event.ActionEvent; 7 import java.awt.event.ActionListener;8 7 import java.io.File; 9 8 import java.net.MalformedURLException; 10 9 import java.net.URL; 10 import java.util.ArrayList; 11 11 import java.util.Collection; 12 12 import java.util.HashMap; 13 13 import java.util.LinkedList; 14 import java.util.List; 14 15 import java.util.Map; 15 16 16 17 import javax.swing.Icon; 17 18 19 import org.openstreetmap.josm.actions.search.SearchCompiler.Match; 20 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 18 21 import org.openstreetmap.josm.data.coor.CachedLatLon; 19 22 import org.openstreetmap.josm.data.coor.EastNorth; … … 22 25 import org.openstreetmap.josm.data.gpx.GpxLink; 23 26 import org.openstreetmap.josm.data.gpx.WayPoint; 27 import org.openstreetmap.josm.data.preferences.CachedProperty; 24 28 import org.openstreetmap.josm.data.preferences.IntegerProperty; 25 29 import org.openstreetmap.josm.gui.MapView; 26 30 import org.openstreetmap.josm.tools.ImageProvider; 31 import org.openstreetmap.josm.tools.template_engine.ParseError; 32 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 33 import org.openstreetmap.josm.tools.template_engine.TemplateEntry; 34 import org.openstreetmap.josm.tools.template_engine.TemplateParser; 27 35 28 36 /** … … 61 69 * @author Frederik Ramm <frederik@remote.org> 62 70 */ 63 public class Marker implements ActionListener { 64 public final String text; 65 public final Map<String,String> textMap = new HashMap<String,String>(); 66 public final Icon symbol; 67 public final MarkerLayer parentLayer; 68 public double time; /* absolute time of marker since epoch */ 69 public double offset; /* time offset in seconds from the gpx point from which it was derived, 70 may be adjusted later to sync with other data, so not final */ 71 72 private CachedLatLon coor; 73 74 public final void setCoor(LatLon coor) { 75 if(this.coor == null) { 76 this.coor = new CachedLatLon(coor); 77 } else { 78 this.coor.setCoor(coor); 79 } 80 } 81 82 public final LatLon getCoor() { 83 return coor; 84 } 85 86 public final void setEastNorth(EastNorth eastNorth) { 87 coor.setEastNorth(eastNorth); 88 } 89 90 public final EastNorth getEastNorth() { 91 return coor.getEastNorth(); 92 } 71 public class Marker implements TemplateEngineDataProvider { 72 73 public static class TemplateEntryProperty extends CachedProperty<TemplateEntry> { 74 // This class is a bit complicated because it supports both global and per layer settings. I've added per layer settings because 75 // GPXSettingsPanel had possibility to set waypoint label but then I've realized that markers use different layer then gpx data 76 // so per layer settings is useless. Anyway it's possible to specify marker layer pattern in Einstein preferences and maybe somebody 77 // will make gui for it so I'm keeping it here 78 79 private final static Map<String, TemplateEntryProperty> cache = new HashMap<String, Marker.TemplateEntryProperty>(); 80 81 // Legacy code - convert label from int to template engine expression 82 private static final IntegerProperty PROP_LABEL = new IntegerProperty("draw.rawgps.layer.wpt", 0 ); 83 private static String getDefaultLabelPattern() { 84 switch (PROP_LABEL.get()) { 85 case 1: 86 return LABEL_PATTERN_NAME; 87 case 2: 88 return LABEL_PATTERN_DESC; 89 case 0: 90 case 3: 91 return LABEL_PATTERN_AUTO; 92 default: 93 return ""; 94 } 95 } 96 97 public static TemplateEntryProperty forMarker(String layerName) { 98 String key = "draw.rawgps.layer.wpt.pattern"; 99 if (layerName != null) { 100 key += "." + layerName; 101 } 102 TemplateEntryProperty result = cache.get(key); 103 if (result == null) { 104 String defaultValue = layerName == null?getDefaultLabelPattern():""; 105 TemplateEntryProperty parent = layerName == null?null:forMarker(null); 106 result = new TemplateEntryProperty(key, defaultValue, parent); 107 cache.put(key, result); 108 } 109 return result; 110 } 111 112 public static TemplateEntryProperty forAudioMarker(String layerName) { 113 String key = "draw.rawgps.layer.audiowpt.pattern"; 114 if (layerName != null) { 115 key += "." + layerName; 116 } 117 TemplateEntryProperty result = cache.get(key); 118 if (result == null) { 119 String defaultValue = layerName == null?"?{ '{name}' | '{desc}' | '{" + Marker.MARKER_FORMATTED_OFFSET + "}' }":""; 120 TemplateEntryProperty parent = layerName == null?null:forAudioMarker(null); 121 result = new TemplateEntryProperty(key, defaultValue, parent); 122 cache.put(key, result); 123 } 124 return result; 125 } 126 127 private TemplateEntryProperty parent; 128 129 130 private TemplateEntryProperty(String key, String defaultValue, TemplateEntryProperty parent) { 131 super(key, defaultValue); 132 this.parent = parent; 133 updateValue(); // Needs to be called because parent wasn't know in super constructor 134 } 135 136 @Override 137 protected TemplateEntry fromString(String s) { 138 try { 139 return new TemplateParser(s).parse(); 140 } catch (ParseError e) { 141 System.out.println(String.format("Unable to parse template engine pattern '%s' for property %s. Using default ('%s') instead", 142 s, getKey(), defaultValue)); 143 return getDefaultValue(); 144 } 145 } 146 147 @Override 148 public String getDefaultValueAsString() { 149 if (parent == null) 150 return super.getDefaultValueAsString(); 151 else 152 return parent.getAsString(); 153 } 154 155 @Override 156 public void preferenceChanged(PreferenceChangeEvent e) { 157 if (e.getKey().equals(key) || (parent != null && e.getKey().equals(parent.getKey()))) { 158 updateValue(); 159 } 160 } 161 } 162 93 163 94 164 /** … … 97 167 * stuff). 98 168 */ 99 public static LinkedList<MarkerProducers> markerProducers = new LinkedList<MarkerProducers>(); 100 101 private static final IntegerProperty PROP_LABEL = new IntegerProperty("draw.rawgps.layer.wpt", 0 ); 102 private static final String[] labelAttributes = new String[] {"name", "desc"}; 169 public static List<MarkerProducers> markerProducers = new LinkedList<MarkerProducers>(); 103 170 104 171 // Add one Maker specifying the default behaviour. … … 110 177 // cheapest way to check whether "link" object exists and is a non-empty 111 178 // collection of GpxLink objects... 112 try { 113 for (GpxLink oneLink : (Collection<GpxLink>) wpt.attr.get(GpxData.META_LINKS)) { 179 Collection<GpxLink> links = (Collection<GpxLink>)wpt.attr.get(GpxData.META_LINKS); 180 if (links != null) { 181 for (GpxLink oneLink : links ) { 114 182 uri = oneLink.uri; 115 183 break; 116 184 } 117 } catch (Exception ex) {}118 119 // Try a relative file:// url, if the link is not in an URL-compatible form120 if (relativePath != null && uri != null && !isWellFormedAddress(uri)) {121 uri = new File(relativePath.getParentFile(), uri).toURI().toString();122 185 } 123 186 124 Map<String,String> nameDesc = new HashMap<String,String>(); 125 for(String attribute : labelAttributes) { 126 if (wpt.attr.containsKey(attribute)) { 127 nameDesc.put(attribute, wpt.getString(attribute)); 187 URL url = null; 188 if (uri != null) { 189 try { 190 url = new URL(uri); 191 } catch (MalformedURLException e) { 192 // Try a relative file:// url, if the link is not in an URL-compatible form 193 if (relativePath != null) { 194 try { 195 url = new File(relativePath.getParentFile(), uri).toURI().toURL(); 196 } catch (MalformedURLException e1) { 197 System.err.println("Unable to convert uri " + uri + " to URL: " + e1.getMessage()); 198 } 199 } 128 200 } 129 201 } 130 202 131 if (uri == null) { 203 204 if (url == null) { 132 205 String symbolName = wpt.getString("symbol"); 133 206 if (symbolName == null) { 134 207 symbolName = wpt.getString("sym"); 135 208 } 136 return new Marker(wpt.getCoor(), nameDesc, symbolName, parentLayer, time, offset);209 return new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset); 137 210 } 138 else if (ur i.endsWith(".wav"))139 return AudioMarker.create(wpt.getCoor(), getText(nameDesc), uri, parentLayer, time, offset);140 else if (ur i.endsWith(".png") || uri.endsWith(".jpg") || uri.endsWith(".jpeg") || uri.endsWith(".gif"))141 return ImageMarker.create(wpt.getCoor(), uri, parentLayer, time, offset);211 else if (url.toString().endsWith(".wav")) 212 return new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset); 213 else if (url.toString().endsWith(".png") || url.toString().endsWith(".jpg") || url.toString().endsWith(".jpeg") || url.toString().endsWith(".gif")) 214 return new ImageMarker(wpt.getCoor(), url, parentLayer, time, offset); 142 215 else 143 return WebMarker.create(wpt.getCoor(), uri, parentLayer, time, offset); 144 } 145 146 private boolean isWellFormedAddress(String link) { 147 try { 148 new URL(link); 149 return true; 150 } catch (MalformedURLException x) { 151 return false; 152 } 216 return new WebMarker(wpt.getCoor(), url, parentLayer, time, offset); 153 217 } 154 218 }); 155 }156 157 public Marker(LatLon ll, String text, String iconName, MarkerLayer parentLayer, double time, double offset) {158 setCoor(ll);159 if (text == null || text.length() == 0) {160 this.text = null;161 }162 else {163 this.text = text;164 }165 this.offset = offset;166 this.time = time;167 this.symbol = ImageProvider.getIfAvailable("markers",iconName);168 this.parentLayer = parentLayer;169 }170 171 public Marker(LatLon ll, Map<String,String> textMap, String iconName, MarkerLayer parentLayer, double time, double offset) {172 setCoor(ll);173 if (textMap != null) {174 this.textMap.clear();175 this.textMap.putAll(textMap);176 }177 178 this.text = null;179 this.offset = offset;180 this.time = time;181 // /* ICON(markers/) */"Bridge"182 // /* ICON(markers/) */"Crossing"183 this.symbol = ImageProvider.getIfAvailable("markers",iconName);184 this.parentLayer = parentLayer;185 }186 187 /**188 * Checks whether the marker display area contains the given point.189 * Markers not interested in mouse clicks may always return false.190 *191 * @param p The point to check192 * @return <code>true</code> if the marker "hotspot" contains the point.193 */194 public boolean containsPoint(Point p) {195 return false;196 }197 198 /**199 * Called when the mouse is clicked in the marker's hotspot. Never200 * called for markers which always return false from containsPoint.201 *202 * @param ev A dummy ActionEvent203 */204 public void actionPerformed(ActionEvent ev) {205 }206 207 /**208 * Paints the marker.209 * @param g graphics context210 * @param mv map view211 * @param mousePressed true if the left mouse button is pressed212 */213 public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {214 Point screen = mv.getPoint(getEastNorth());215 if (symbol != null && showTextOrIcon) {216 symbol.paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2);217 } else {218 g.drawLine(screen.x-2, screen.y-2, screen.x+2, screen.y+2);219 g.drawLine(screen.x+2, screen.y-2, screen.x-2, screen.y+2);220 }221 222 String labelText = getText();223 if ((labelText != null) && showTextOrIcon) {224 g.drawString(labelText, screen.x+4, screen.y+2);225 }226 219 } 227 220 … … 246 239 } 247 240 248 /** 249 * Returns an AudioMarker derived from this Marker and the provided uri 250 * Subclasses of specific marker types override this to return null as they can't 251 * be turned into AudioMarkers. This includes AudioMarkers themselves, as they 252 * already have audio. 241 public static final String MARKER_OFFSET = "waypointOffset"; 242 public static final String MARKER_FORMATTED_OFFSET = "formattedWaypointOffset"; 243 244 public static final String LABEL_PATTERN_AUTO = "?{ '{name} - {desc}' | '{name}' | '{desc}' }"; 245 public static final String LABEL_PATTERN_NAME = "{name}"; 246 public static final String LABEL_PATTERN_DESC = "{desc}"; 247 248 249 private final TemplateEngineDataProvider dataProvider; 250 public final Icon symbol; 251 public final MarkerLayer parentLayer; 252 public double time; /* absolute time of marker since epoch */ 253 public double offset; /* time offset in seconds from the gpx point from which it was derived, 254 may be adjusted later to sync with other data, so not final */ 255 256 private String cachedText; 257 private int textVersion = -1; 258 private CachedLatLon coor; 259 260 public Marker(LatLon ll, TemplateEngineDataProvider dataProvider, String iconName, MarkerLayer parentLayer, double time, double offset) { 261 setCoor(ll); 262 263 this.offset = offset; 264 this.time = time; 265 // /* ICON(markers/) */"Bridge" 266 // /* ICON(markers/) */"Crossing" 267 this.symbol = ImageProvider.getIfAvailable("markers",iconName); 268 this.parentLayer = parentLayer; 269 270 this.dataProvider = dataProvider; 271 } 272 273 public final void setCoor(LatLon coor) { 274 if(this.coor == null) { 275 this.coor = new CachedLatLon(coor); 276 } else { 277 this.coor.setCoor(coor); 278 } 279 } 280 281 public final LatLon getCoor() { 282 return coor; 283 } 284 285 public final void setEastNorth(EastNorth eastNorth) { 286 coor.setEastNorth(eastNorth); 287 } 288 289 public final EastNorth getEastNorth() { 290 return coor.getEastNorth(); 291 } 292 293 294 /** 295 * Checks whether the marker display area contains the given point. 296 * Markers not interested in mouse clicks may always return false. 253 297 * 254 * @param uri uri of wave file 255 * @return AudioMarker 256 */ 257 258 public AudioMarker audioMarkerFromMarker(String uri) { 259 AudioMarker audioMarker = AudioMarker.create(getCoor(), this.getText(), uri, this.parentLayer, this.time, this.offset); 260 return audioMarker; 298 * @param p The point to check 299 * @return <code>true</code> if the marker "hotspot" contains the point. 300 */ 301 public boolean containsPoint(Point p) { 302 return false; 303 } 304 305 /** 306 * Called when the mouse is clicked in the marker's hotspot. Never 307 * called for markers which always return false from containsPoint. 308 * 309 * @param ev A dummy ActionEvent 310 */ 311 public void actionPerformed(ActionEvent ev) { 312 } 313 314 315 /** 316 * Paints the marker. 317 * @param g graphics context 318 * @param mv map view 319 * @param mousePressed true if the left mouse button is pressed 320 */ 321 public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) { 322 Point screen = mv.getPoint(getEastNorth()); 323 if (symbol != null && showTextOrIcon) { 324 symbol.paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2); 325 } else { 326 g.drawLine(screen.x-2, screen.y-2, screen.x+2, screen.y+2); 327 g.drawLine(screen.x+2, screen.y-2, screen.x-2, screen.y+2); 328 } 329 330 String labelText = getText(); 331 if ((labelText != null) && showTextOrIcon) { 332 g.drawString(labelText, screen.x+4, screen.y+2); 333 } 334 } 335 336 337 protected TemplateEntryProperty getTextTemplate() { 338 return TemplateEntryProperty.forMarker(parentLayer.getName()); 261 339 } 262 340 … … 266 344 */ 267 345 public String getText() { 268 if (this.text != null ) 269 return this.text; 346 TemplateEntryProperty property = getTextTemplate(); 347 if (property.getUpdateCount() != textVersion) { 348 TemplateEntry templateEntry = property.get(); 349 StringBuilder sb = new StringBuilder(); 350 templateEntry.appendText(sb, this); 351 352 cachedText = sb.toString(); 353 textVersion = property.getUpdateCount(); 354 } 355 return cachedText; 356 } 357 358 @Override 359 public List<String> getTemplateKeys() { 360 List<String> result; 361 if (dataProvider != null) { 362 result = dataProvider.getTemplateKeys(); 363 } else { 364 result = new ArrayList<String>(); 365 } 366 result.add(MARKER_FORMATTED_OFFSET); 367 result.add(MARKER_OFFSET); 368 return result; 369 } 370 371 private String formatOffset () { 372 int wholeSeconds = (int)(offset + 0.5); 373 if (wholeSeconds < 60) 374 return Integer.toString(wholeSeconds); 375 else if (wholeSeconds < 3600) 376 return String.format("%d:%02d", wholeSeconds / 60, wholeSeconds % 60); 270 377 else 271 return getText(this.textMap); 272 } 273 274 /** 275 * Returns the Text which should be displayed, depending on chosen preference. 276 * The possible attributes are read from textMap. 277 * 278 * @param textMap A map with available texts/attributes 279 * @return Text 280 */ 281 private static String getText(Map<String,String> textMap) { 282 String text = ""; 283 284 if (textMap != null && !textMap.isEmpty()) { 285 switch(PROP_LABEL.get()) 286 { 287 // name 288 case 1: 289 { 290 if (textMap.containsKey("name")) { 291 text = textMap.get("name"); 292 } 293 break; 294 } 295 296 // desc 297 case 2: 298 { 299 if (textMap.containsKey("desc")) { 300 text = textMap.get("desc"); 301 } 302 break; 303 } 304 305 // auto 306 case 0: 307 // both 308 case 3: 309 { 310 if (textMap.containsKey("name")) { 311 text = textMap.get("name"); 312 313 if (textMap.containsKey("desc")) { 314 if (PROP_LABEL.get() != 0 || !text.equals(textMap.get("desc"))) { 315 text += " - " + textMap.get("desc"); 316 } 317 } 318 } 319 else if (textMap.containsKey("desc")) { 320 text = textMap.get("desc"); 321 } 322 break; 323 } 324 325 // none 326 case 4: 327 default: 328 { 329 text = ""; 330 break; 331 } 332 } 333 } 334 335 return text; 378 return String.format("%d:%02d:%02d", wholeSeconds / 3600, (wholeSeconds % 3600)/60, wholeSeconds % 60); 379 } 380 381 @Override 382 public Object getTemplateValue(String name) { 383 if (MARKER_FORMATTED_OFFSET.equals(name)) 384 return formatOffset(); 385 else if (MARKER_OFFSET.equals(name)) 386 return offset; 387 else if (dataProvider != null) 388 return dataProvider.getTemplateValue(name); 389 else 390 return null; 391 } 392 393 @Override 394 public boolean evaluateCondition(Match condition) { 395 throw new UnsupportedOperationException(); 336 396 } 337 397 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r4230 r4282 32 32 import org.openstreetmap.josm.data.coor.LatLon; 33 33 import org.openstreetmap.josm.data.gpx.GpxData; 34 import org.openstreetmap.josm.data.gpx.GpxLink;35 34 import org.openstreetmap.josm.data.gpx.WayPoint; 36 35 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 72 71 this.fromLayer = fromLayer; 73 72 double firstTime = -1.0; 74 String lastLinkedFile = "";75 73 76 74 for (WayPoint wpt : indata.waypoints) { 77 /* calculate time differences in waypoints */78 75 double time = wpt.time; 79 boolean wpt_has_link = wpt.attr.containsKey(GpxData.META_LINKS); 80 if (firstTime < 0 && wpt_has_link) { 76 if (firstTime < 0) { 81 77 firstTime = time; 82 for (GpxLink oneLink : (Collection<GpxLink>) wpt.attr.get(GpxData.META_LINKS)) {83 lastLinkedFile = oneLink.uri;84 break;85 }86 }87 if (wpt_has_link) {88 for (GpxLink oneLink : (Collection<GpxLink>) wpt.attr.get(GpxData.META_LINKS)) {89 if (!oneLink.uri.equals(lastLinkedFile)) {90 firstTime = time;91 }92 lastLinkedFile = oneLink.uri;93 break;94 }95 78 } 96 79 Marker m = Marker.createMarker(wpt, indata.storageFile, this, time, time - firstTime); … … 274 257 tr("Error"), 275 258 JOptionPane.ERROR_MESSAGE 276 );259 ); 277 260 return null; 278 261 } 279 262 280 263 // make our new marker 281 AudioMarker newAudioMarker = AudioMarker.create(coor,282 AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset);264 AudioMarker newAudioMarker = new AudioMarker(coor, 265 null, AudioPlayer.url(), this, time, offset); 283 266 284 267 // insert it at the right place in a copy the collection … … 425 408 tr("Warning"), 426 409 JOptionPane.WARNING_MESSAGE 427 );410 ); 428 411 return; 429 412 } … … 432 415 JOptionPane.showMessageDialog( 433 416 Main.parent, 434 tr("Audio synchronized at point {0}.", recent. text),417 tr("Audio synchronized at point {0}.", recent.getText()), 435 418 tr("Information"), 436 419 JOptionPane.INFORMATION_MESSAGE 437 );420 ); 438 421 } else { 439 422 JOptionPane.showMessageDialog( … … 442 425 tr("Error"), 443 426 JOptionPane.ERROR_MESSAGE 444 );427 ); 445 428 } 446 429 } … … 462 445 tr("Warning"), 463 446 JOptionPane.WARNING_MESSAGE 464 );447 ); 465 448 return; 466 449 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r2907 r4282 59 59 60 60 private PlayHeadMarker() { 61 super(new LatLon(0.0,0.0), "",61 super(new LatLon(0.0,0.0), null, 62 62 Main.pref.get("marker.audiotracericon", "audio-tracer"), 63 63 null, -1.0, 0.0); … … 171 171 tr("Warning"), 172 172 JOptionPane.WARNING_MESSAGE 173 );173 ); 174 174 endDrag(true); 175 175 } else { … … 226 226 tr("Warning"), 227 227 JOptionPane.WARNING_MESSAGE 228 );228 ); 229 229 endDrag(true); 230 230 return; … … 241 241 tr("Error"), 242 242 JOptionPane.ERROR_MESSAGE 243 );243 ); 244 244 endDrag(true); 245 245 } … … 247 247 JOptionPane.showMessageDialog( 248 248 Main.parent, 249 tr("Audio synchronized at point {0}.", ca. text),249 tr("Audio synchronized at point {0}.", ca.getText()), 250 250 tr("Information"), 251 251 JOptionPane.INFORMATION_MESSAGE 252 );252 ); 253 253 setCoor(ca.getCoor()); 254 254 endDrag(false); … … 259 259 tr("Error"), 260 260 JOptionPane.ERROR_MESSAGE 261 );261 ); 262 262 endDrag(true); 263 263 } … … 294 294 return; 295 295 double audioTime = recentlyPlayedMarker.time + 296 AudioPlayer.position() -297 recentlyPlayedMarker.offset -298 recentlyPlayedMarker.syncOffset;296 AudioPlayer.position() - 297 recentlyPlayedMarker.offset - 298 recentlyPlayedMarker.syncOffset; 299 299 if (Math.abs(audioTime - time) < animationInterval) 300 300 return; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/WebMarker.java
r2017 r4282 21 21 public class WebMarker extends ButtonMarker { 22 22 23 public URL webUrl;23 public final URL webUrl; 24 24 25 public static WebMarker create (LatLon ll, String url, MarkerLayer parentLayer, double time, double offset) { 26 try { 27 return new WebMarker(ll, new URL(url), parentLayer, time, offset); 28 } catch (Exception ex) { 29 return null; 30 } 31 } 32 33 private WebMarker(LatLon ll, URL webUrl, MarkerLayer parentLayer, double time, double offset) { 25 public WebMarker(LatLon ll, URL webUrl, MarkerLayer parentLayer, double time, double offset) { 34 26 super(ll, "web.png", parentLayer, time, offset); 35 27 this.webUrl = webUrl; … … 41 33 JOptionPane.showMessageDialog(Main.parent, 42 34 "<html><b>" + 43 tr("There was an error while trying to display the URL for this marker") +44 "</b><br>" + tr("(URL was: ") + webUrl.toString() + ")" + "<br>" + error,45 tr("Error displaying URL"), JOptionPane.ERROR_MESSAGE);35 tr("There was an error while trying to display the URL for this marker") + 36 "</b><br>" + tr("(URL was: ") + webUrl.toString() + ")" + "<br>" + error, 37 tr("Error displaying URL"), JOptionPane.ERROR_MESSAGE); 46 38 } 47 39 }
Note:
See TracChangeset
for help on using the changeset viewer.