Changeset 21299 in osm for applications/editors/josm/plugins/videomapping/src/org
- Timestamp:
- 2010-05-16T12:43:01+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PositionLayer.java
r21295 r21299 2 2 3 3 4 import java.util.ArrayList; 5 import java.util.Collection; 4 6 import java.util.Iterator; 7 import java.util.List; 5 8 import java.util.Timer; 6 9 import java.util.TimerTask; … … 12 15 import java.awt.Point; 13 16 import java.awt.Rectangle; 17 import java.awt.event.KeyEvent; 18 import java.awt.event.KeyListener; 14 19 import java.awt.event.MouseEvent; 15 20 import java.awt.event.MouseListener; … … 22 27 import org.openstreetmap.josm.data.Bounds; 23 28 import org.openstreetmap.josm.data.gpx.GpxData; 29 import org.openstreetmap.josm.data.gpx.WayPoint; 24 30 import org.openstreetmap.josm.data.osm.DataSet; 25 31 import org.openstreetmap.josm.data.osm.Node; … … 31 37 import org.openstreetmap.josm.tools.ImageProvider; 32 38 33 public class PositionLayer extends Layer implements MouseListener { 34 private DataSet ds; 35 private Node sel; 36 private Iterator<Node> it; 37 38 public PositionLayer(String name, final DataSet ds) { 39 public class PositionLayer extends Layer implements MouseListener, KeyListener { 40 private List<WayPoint> ls; 41 private Collection<WayPoint> selected; 42 private WayPoint sel; 43 private Iterator<WayPoint> it; 44 45 public PositionLayer(String name, final List<WayPoint> ls) { 39 46 super(name); 40 this.ds = ds; 41 Main.map.mapView.addMouseListener(this); 42 Timer t = new Timer(); 43 it=ds.getNodes().iterator(); 44 47 this.ls = ls; 48 selected = new ArrayList<WayPoint>(); 49 Main.map.mapView.addMouseListener(this); 50 Main.map.mapView.addKeyListener(this); 51 it=ls.iterator(); 52 Timer t = new Timer(); 45 53 t.schedule(new TimerTask() { 46 54 … … 49 57 // TODO Auto-generated method stub 50 58 sel=it.next(); 51 System.out.println(sel.getTime stamp());59 System.out.println(sel.getTime()); 52 60 Main.map.mapView.repaint(); 53 61 } 54 },100 0,1000);62 },100,100); 55 63 56 64 } … … 103 111 public void paint(Graphics2D g, MapView map, Bounds bound) { 104 112 Point p; 105 for(Node n: ds.getNodes()) { 113 g.setColor(Color.green); 114 for(WayPoint n: ls) { 106 115 p = Main.map.mapView.getPoint(n.getEastNorth()); 107 if(n.isHighlighted()) 108 { 109 g.setColor(Color.red); 110 g.drawString(n.getTimestamp().toString(), p.x+10, p.y); 116 g.drawOval(p.x - 2, p.y - 2, 4, 4); // small circles 111 117 } 112 else113 {114 g.setColor(Color.green);115 }118 g.setColor(Color.red); 119 for(WayPoint n:selected) 120 { 121 p = Main.map.mapView.getPoint(n.getEastNorth()); 116 122 g.drawOval(p.x - 2, p.y - 2, 4, 4); // small circles 117 123 } 118 124 if (sel!=null){ 119 p=Main.map.mapView.getPoint(sel.getEastNorth());; 120 g.setColor(Color.CYAN); 121 g.drawRect(p.x, p.y, 100, 100); 125 p=Main.map.mapView.getPoint(sel.getEastNorth()); 126 //TODO Source out redundant calculations 127 //TODO make icon transparent 128 ImageProvider.get("videomapping.png").paintIcon(null, g, p.x-ImageProvider.get("videomapping.png").getIconWidth()/2, p.y-ImageProvider.get("videomapping.png").getIconHeight()/2); 122 129 }; 123 130 } … … 133 140 //only on leftclicks of our layer 134 141 if(e.getButton() == MouseEvent.BUTTON1) { 135 JOptionPane.showMessageDialog(Main.parent,"test"); 142 //JOptionPane.showMessageDialog(Main.parent,"test"); 136 143 getNearestNode(e.getPoint()); 137 144 Main.map.mapView.repaint(); … … 145 152 Rectangle rect = new Rectangle(mouse, new Dimension(30, 30)); 146 153 //iterate through all possible notes 147 for( Node node : ds.getNodes())154 for(WayPoint n : ls) 148 155 { 149 p = Main.map.mapView.getPoint(n ode);156 p = Main.map.mapView.getPoint(n.getEastNorth()); 150 157 if (rect.contains(p)) 151 158 { 152 node.setHighlighted(true); 159 selected.add(n); 160 sel=n; 153 161 } 154 162 … … 176 184 } 177 185 186 public void keyPressed(KeyEvent e) { 187 System.out.println(e.getKeyCode()); 188 switch(e.getKeyCode()) 189 { 190 case KeyEvent.VK_LEFT: sel = ls.get(50); 191 } 192 193 } 194 195 public void keyReleased(KeyEvent e) { 196 // TODO Auto-generated method stub 197 198 } 199 200 public void keyTyped(KeyEvent e) { 201 // TODO Auto-generated method stub 202 203 } 204 178 205 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoAction.java
r21295 r21299 3 3 import java.awt.event.ActionEvent; 4 4 import java.io.File; 5 import java.util.Collections; 6 import java.util.LinkedList; 5 7 import java.util.List; 6 8 … … 35 37 36 38 copyGPSLayer(); 37 Main.main.addLayer(new PositionLayer("test", ds));39 Main.main.addLayer(new PositionLayer("test",ls)); 38 40 } 39 41 … … 45 47 //makes a private flat copy for interaction 46 48 private void copyGPSLayer() 47 { 48 //TODO we assume that GPS points are in the correct order! 49 ds = new DataSet(); 50 for (GpxTrack trk : gps.tracks) { 51 for (GpxTrackSegment segment : trk.getSegments()) { 52 Way w = new Way(); 53 for (WayPoint p : segment.getWayPoints()) { 54 Node n = new Node(p.getCoor()); 55 String timestr = p.getString("time"); 56 if(timestr != null) 57 n.setTimestamp(DateUtils.fromString(timestr)); 58 ds.addPrimitive(n); 59 w.addNode(n); 60 //ls.add 61 } 62 ds.addPrimitive(w); 63 } 49 { 50 ls = new LinkedList<WayPoint>(); 51 for (GpxTrack trk : gps.tracks) { 52 for (GpxTrackSegment segment : trk.getSegments()) { 53 ls.addAll(segment.getWayPoints()); 64 54 } 55 } 56 Collections.sort(ls); //sort basing upon time 65 57 } 66 58 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoMappingPlugin.java
r21295 r21299 30 30 super(info); 31 31 //Register for GPS menu 32 VMenu = Main.main.menu.addMenu( tr(" Video"), KeyEvent.VK_V, Main.main.menu.defaultMenuPos,ht("/Plugin/Videomapping"));//TODO no more ugly " video" hack32 VMenu = Main.main.menu.addMenu(" Video", KeyEvent.VK_V, Main.main.menu.defaultMenuPos,ht("/Plugin/Videomapping"));//TODO no more ugly " video" hack 33 33 VMenu.setEnabled(false); //enabled only on GPS Layers 34 34 VAction = new VideoAction();
Note:
See TracChangeset
for help on using the changeset viewer.