Changeset 19680 in osm for applications/editors/josm/plugins/livegps/src
- Timestamp:
- 2010-01-30T20:06:10+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/livegps/src/livegps
- Files:
-
- 1 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java
r16945 r19680 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.coor.EastNorth;12 11 import org.openstreetmap.josm.data.coor.LatLon; 13 12 import org.openstreetmap.josm.data.osm.Way; -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java
r19011 r19680 9 9 import java.beans.PropertyChangeListener; 10 10 import java.text.SimpleDateFormat; 11 import java.util.ArrayList;12 import java.util.Collection;13 11 import java.util.Date; 12 import java.util.HashMap; 13 import java.util.Map; 14 14 15 15 import org.openstreetmap.josm.Main; … … 18 18 import org.openstreetmap.josm.data.gpx.GpxData; 19 19 import org.openstreetmap.josm.data.gpx.GpxTrack; 20 import org.openstreetmap.josm.data.gpx.SingleSegmentGpxTrack; 20 21 import org.openstreetmap.josm.data.gpx.WayPoint; 21 22 import org.openstreetmap.josm.gui.MapView; … … 27 28 LatLon lastPos; 28 29 WayPoint lastPoint; 29 GpxTrack trackBeingWritten; 30 Collection<WayPoint> trackSegment; 30 private final AppendableGpxTrackSegment trackSegment; 31 31 float speed; 32 32 float course; … … 35 35 boolean autocenter; 36 36 private SimpleDateFormat dateFormat = new SimpleDateFormat( 37 37 "yyyy-MM-dd'T'HH:mm:ss.SSS"); 38 38 39 39 /** … … 44 44 public LiveGpsLayer(GpxData data) { 45 45 super(data, LAYER_NAME); 46 trackBeingWritten = new GpxTrack(); 47 trackBeingWritten.attr.put("desc", "josm live gps"); 48 trackSegment = new ArrayList<WayPoint>(); 49 trackBeingWritten.trackSegs.add(trackSegment); 46 trackSegment = new AppendableGpxTrackSegment(); 47 48 Map<String, Object> attr = new HashMap<String, Object>(); 49 attr.put("desc", "josm live gps"); 50 51 GpxTrack trackBeingWritten = new SingleSegmentGpxTrack(trackSegment, attr); 50 52 data.tracks.add(trackBeingWritten); 51 53 } … … 63 65 lastPoint = new WayPoint(thisPos); 64 66 lastPoint.attr.put("time", dateFormat.format(new Date())); 65 // synchronize when adding data, as otherwise the autosave action 66 // needs concurrent access and this results in an exception! 67 synchronized (LiveGpsLock.class) { 68 trackSegment.add(lastPoint); 69 } 67 trackSegment.addWaypoint(lastPoint); 70 68 if (autocenter && allowRedraw()) { 71 69 center(); … … 104 102 public void paint(Graphics2D g, MapView mv, Bounds bounds) { 105 103 // System.out.println("in paint"); 106 synchronized (LiveGpsLock.class) { 107 // System.out.println("in synced paint"); 108 super.paint(g, mv, bounds); 109 // int statusHeight = 50; 110 // Rectangle mvs = mv.getBounds(); 111 // mvs.y = mvs.y + mvs.height - statusHeight; 112 // mvs.height = statusHeight; 113 // g.setColor(new Color(1.0f, 1.0f, 1.0f, 0.8f)); 114 // g.fillRect(mvs.x, mvs.y, mvs.width, mvs.height); 104 // System.out.println("in synced paint"); 105 super.paint(g, mv, bounds); 106 // int statusHeight = 50; 107 // Rectangle mvs = mv.getBounds(); 108 // mvs.y = mvs.y + mvs.height - statusHeight; 109 // mvs.height = statusHeight; 110 // g.setColor(new Color(1.0f, 1.0f, 1.0f, 0.8f)); 111 // g.fillRect(mvs.x, mvs.y, mvs.width, mvs.height); 115 112 116 117 118 119 120 121 113 if (lastPoint != null) { 114 Point screen = mv.getPoint(lastPoint.getCoor()); 115 g.setColor(Main.pref.getColor(KEY_LIVEGPS_COLOR, Color.RED)); 116 g.drawOval(screen.x - 10, screen.y - 10, 20, 20); 117 g.drawOval(screen.x - 9, screen.y - 9, 18, 18); 118 } 122 119 123 124 125 126 127 128 120 // lbl.setText("gpsd: "+status+" Speed: " + speed + 121 // " Course: "+course); 122 // lbl.setBounds(0, 0, mvs.width-10, mvs.height-10); 123 // Graphics sub = g.create(mvs.x+5, mvs.y+5, mvs.width-10, 124 // mvs.height-10); 125 // lbl.paint(sub); 129 126 130 // if(status != null) { 131 // g.setColor(Color.WHITE); 132 // g.drawString("gpsd: " + status, 5, mv.getBounds().height - 15); 133 // // lower left corner 134 // } 135 } 127 // if(status != null) { 128 // g.setColor(Color.WHITE); 129 // g.drawString("gpsd: " + status, 5, mv.getBounds().height - 15); 130 // // lower left corner 131 // } 136 132 } 137 133 … … 176 172 /** 177 173 * Check, if a redraw is currently allowed. 178 * 179 * @return true, if a redraw is permitted, false, if a re-draw 174 * 175 * @return true, if a redraw is permitted, false, if a re-draw 180 176 * should be suppressed. 181 177 */
Note:
See TracChangeset
for help on using the changeset viewer.