Changeset 22691 in osm for applications/editors/josm/plugins/videomapping/src/org
- Timestamp:
- 2010-08-19T08:44:44+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PositionLayer.java
r22690 r22691 2 2 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 4 import java.sql.Time; 5 import java.text.DateFormat; 6 import java.text.SimpleDateFormat; 7 import java.util.ArrayList; 8 import java.util.Collection; 9 import java.util.Date; 10 import java.util.HashSet; 11 import java.util.Iterator; 12 import java.util.LinkedList; 13 import java.util.List; 14 import java.util.ListIterator; 15 import java.util.Set; 16 import java.util.Timer; 17 import java.util.TimerTask; 5 18 6 19 import java.awt.Color; 20 import java.awt.Component; 7 21 import java.awt.Cursor; 22 import java.awt.Dimension; 8 23 import java.awt.Graphics2D; 9 24 import java.awt.Point; 10 25 import java.awt.Rectangle; 26 import java.awt.event.ActionEvent; 27 import java.awt.event.KeyEvent; 28 import java.awt.event.KeyListener; 11 29 import java.awt.event.MouseEvent; 12 30 import java.awt.event.MouseListener; 13 31 import java.awt.event.MouseMotionListener; 14 import java.text.SimpleDateFormat; 15 import java.util.HashSet; 16 import java.util.LinkedList; 17 import java.util.List; 18 import java.util.Set; 19 20 import javax.swing.Action; 21 import javax.swing.Icon; 22 import javax.swing.ImageIcon; 32 33 import javax.swing.*; 34 35 import static org.openstreetmap.josm.tools.I18n.*; 23 36 24 37 import org.openstreetmap.josm.Main; 38 import org.openstreetmap.josm.actions.InfoAction; 25 39 import org.openstreetmap.josm.data.Bounds; 40 import org.openstreetmap.josm.data.gpx.GpxData; 26 41 import org.openstreetmap.josm.data.gpx.WayPoint; 42 import org.openstreetmap.josm.data.osm.DataSet; 43 import org.openstreetmap.josm.data.osm.Node; 27 44 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 28 45 import org.openstreetmap.josm.gui.MapView; … … 31 48 import org.openstreetmap.josm.gui.layer.Layer; 32 49 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideoPlayer; 50 import org.openstreetmap.josm.tools.ImageProvider; 51 import org.openstreetmap.josm.tools.Shortcut; 52 53 import com.sun.jna.StringArray; 33 54 34 55 //Basic rendering and GPS layer interaction … … 45 66 private SimpleDateFormat gpsTimeCode; 46 67 private GPSVideoPlayer gps; 47 68 48 69 public PositionLayer(String name, final List<WayPoint> ls) { 49 70 super(name); … … 55 76 gpsTimeCode= new SimpleDateFormat("hh:mm:ss"); 56 77 Main.map.mapView.addMouseListener(this); 57 Main.map.mapView.addMouseMotionListener(this); 58 78 Main.map.mapView.addMouseMotionListener(this); 79 59 80 } 60 81 … … 75 96 76 97 @Override 77 public Action[] getMenuEntries() {78 return new Action[]{79 LayerListDialog.getInstance().createShowHideLayerAction(),80 LayerListDialog.getInstance().createDeleteLayerAction(),81 SeparatorLayerAction.INSTANCE,98 public Component[] getMenuEntries() { 99 return new Component[]{ 100 new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)), 101 new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)), 102 new JSeparator(), 82 103 //TODO here my stuff 83 new LayerListPopup.InfoAction(this)};//TODO here infos about the linked videos 84 } 85 104 new JSeparator(), 105 new JMenuItem(new LayerListPopup.InfoAction(this))};//TODO here infos about the linked videos 106 } 107 86 108 87 109 … … 99 121 @Override 100 122 public void mergeFrom(Layer arg0) { 101 102 } 103 104 105 123 124 } 125 126 127 106 128 @Override 107 129 //Draw the current position, infos, waypoints … … 157 179 { 158 180 p=Main.map.mapView.getPoint(iconPosition.getEastNorth()); 159 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 181 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 160 182 //g.drawString(mins.format(iconPosition.getTime()),p.x-10,p.y-10); //TODO when synced we might wan't to use a different layout 161 183 g.drawString(gpsTimeCode.format(iconPosition.getTime()),p.x-10,p.y-10); … … 166 188 if (player.getCurr()!=null){ 167 189 p=Main.map.mapView.getPoint(player.getCurr().getEastNorth()); 168 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 190 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 169 191 g.drawString(gpsTimeCode.format(player.getCurr().getTime()),p.x-10,p.y-10); 170 192 } 171 193 } 172 194 } 173 195 174 196 //finds the first waypoint that is nearby the given point 175 197 private WayPoint getNearestWayPoint(Point mouse) … … 183 205 p = Main.map.mapView.getPoint(n.getEastNorth()); 184 206 if (rect.contains(p)) 185 { 207 { 186 208 return n; 187 209 } 188 210 189 211 } 190 212 return null; 191 192 } 193 213 214 } 215 194 216 //upper left corner like rectangle 195 217 private Rectangle getIconRect() … … 206 228 } 207 229 208 public void mouseClicked(MouseEvent e) { 209 } 210 211 public void mouseEntered(MouseEvent arg0) { 230 public void mouseClicked(MouseEvent e) { 231 } 232 233 public void mouseEntered(MouseEvent arg0) { 212 234 } 213 235 … … 228 250 } 229 251 } 230 231 } 232 252 253 } 254 233 255 // 234 public void mouseReleased(MouseEvent e) { 256 public void mouseReleased(MouseEvent e) { 235 257 //only leftclicks on our layer 236 258 if(e.getButton() == MouseEvent.BUTTON1) { … … 251 273 Main.map.mapView.repaint(); 252 274 } 253 254 } 255 275 276 } 277 256 278 //slide and restrict during movement 257 public void mouseDragged(MouseEvent e) { 279 public void mouseDragged(MouseEvent e) { 258 280 if(dragIcon) 259 { 281 { 260 282 mouse=e.getPoint(); 261 283 //restrict to GPS track … … 267 289 268 290 //visualize drag&drop 269 public void mouseMoved(MouseEvent e) { 291 public void mouseMoved(MouseEvent e) { 270 292 if (player.getCurr()!=null) 271 { 293 { 272 294 if (getIconRect().contains(e.getPoint())) 273 295 { … … 279 301 } 280 302 } 281 303 282 304 } 283 305 284 306 public void setGPSPlayer(GPSVideoPlayer player) { 285 307 this.gps = player; 286 287 } 288 308 309 } 310 289 311 public static void addObserver(PlayerObserver observer) { 290 312 … … 293 315 } 294 316 295 317 296 318 297 319 public static void removeObserver(PlayerObserver observer) {
Note:
See TracChangeset
for help on using the changeset viewer.