Changeset 22550 in osm for applications/editors/josm/plugins/videomapping/src/org
- Timestamp:
- 2010-08-03T08:21:38+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
r21779 r22550 2 2 3 3 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; 4 import static org.openstreetmap.josm.tools.I18n.tr; 18 5 19 6 import java.awt.Color; 20 import java.awt.Component;21 7 import java.awt.Cursor; 22 import java.awt.Dimension;23 8 import java.awt.Graphics2D; 24 9 import java.awt.Point; 25 10 import java.awt.Rectangle; 26 import java.awt.event.ActionEvent;27 import java.awt.event.KeyEvent;28 import java.awt.event.KeyListener;29 11 import java.awt.event.MouseEvent; 30 12 import java.awt.event.MouseListener; 31 13 import java.awt.event.MouseMotionListener; 32 33 import javax.swing.*; 34 35 import static org.openstreetmap.josm.tools.I18n.*; 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; 36 23 37 24 import org.openstreetmap.josm.Main; 38 import org.openstreetmap.josm.actions.InfoAction;39 25 import org.openstreetmap.josm.data.Bounds; 40 import org.openstreetmap.josm.data.gpx.GpxData;41 26 import org.openstreetmap.josm.data.gpx.WayPoint; 42 import org.openstreetmap.josm.data.osm.DataSet;43 import org.openstreetmap.josm.data.osm.Node;44 27 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 45 28 import org.openstreetmap.josm.gui.MapView; … … 48 31 import org.openstreetmap.josm.gui.layer.Layer; 49 32 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;54 33 55 34 //Basic rendering and GPS layer interaction … … 65 44 private SimpleDateFormat ms; 66 45 private GPSVideoPlayer gps; 67 46 68 47 public PositionLayer(String name, final List<WayPoint> ls) { 69 48 super(name); … … 74 53 ms= new SimpleDateFormat("mm:ss"); 75 54 Main.map.mapView.addMouseListener(this); 76 Main.map.mapView.addMouseMotionListener(this); 77 55 Main.map.mapView.addMouseMotionListener(this); 56 78 57 } 79 58 … … 94 73 95 74 @Override 96 public Component[] getMenuEntries() {97 return new Component[]{98 new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)),99 new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)),100 new JSeparator(),75 public Action[] getMenuEntries() { 76 return new Action[]{ 77 LayerListDialog.getInstance().createShowHideLayerAction(), 78 LayerListDialog.getInstance().createDeleteLayerAction(), 79 SeparatorLayerAction.INSTANCE, 101 80 //TODO here my stuff 102 new JSeparator(), 103 new JMenuItem(new LayerListPopup.InfoAction(this))};//TODO here infos about the linked videos 104 } 105 81 new LayerListPopup.InfoAction(this)};//TODO here infos about the linked videos 82 } 83 106 84 107 85 … … 119 97 @Override 120 98 public void mergeFrom(Layer arg0) { 121 122 } 123 124 125 99 100 } 101 102 103 126 104 @Override 127 105 //Draw the current position, infos, waypoints … … 177 155 { 178 156 p=Main.map.mapView.getPoint(iconPosition.getEastNorth()); 179 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 157 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 180 158 g.drawString(mins.format(iconPosition.getTime()),p.x-10,p.y-10); 181 159 } … … 185 163 if (player.getCurr()!=null){ 186 164 p=Main.map.mapView.getPoint(player.getCurr().getEastNorth()); 187 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 165 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 188 166 g.drawString(ms.format(player.getRelativeTime()),p.x-10,p.y-10); 189 167 } 190 168 } 191 169 } 192 170 193 171 //finds the first waypoint that is nearby the given point 194 172 private WayPoint getNearestWayPoint(Point mouse) … … 202 180 p = Main.map.mapView.getPoint(n.getEastNorth()); 203 181 if (rect.contains(p)) 204 { 182 { 205 183 return n; 206 184 } 207 185 208 186 } 209 187 return null; 210 211 } 212 188 189 } 190 213 191 //upper left corner like rectangle 214 192 private Rectangle getIconRect() … … 225 203 } 226 204 227 public void mouseClicked(MouseEvent e) { 228 } 229 230 public void mouseEntered(MouseEvent arg0) { 205 public void mouseClicked(MouseEvent e) { 206 } 207 208 public void mouseEntered(MouseEvent arg0) { 231 209 } 232 210 … … 247 225 } 248 226 } 249 250 } 251 227 228 } 229 252 230 // 253 public void mouseReleased(MouseEvent e) { 231 public void mouseReleased(MouseEvent e) { 254 232 //only leftclicks on our layer 255 233 if(e.getButton() == MouseEvent.BUTTON1) { … … 270 248 Main.map.mapView.repaint(); 271 249 } 272 273 } 274 250 251 } 252 275 253 //slide and restrict during movement 276 public void mouseDragged(MouseEvent e) { 254 public void mouseDragged(MouseEvent e) { 277 255 if(dragIcon) 278 { 256 { 279 257 mouse=e.getPoint(); 280 258 //restrict to GPS track … … 286 264 287 265 //visualize drag&drop 288 public void mouseMoved(MouseEvent e) { 266 public void mouseMoved(MouseEvent e) { 289 267 if (player.getCurr()!=null) 290 { 268 { 291 269 if (getIconRect().contains(e.getPoint())) 292 270 { … … 298 276 } 299 277 } 300 278 301 279 } 302 280 303 281 public void setGPSPlayer(GPSVideoPlayer player) { 304 282 this.gps = player; 305 306 } 307 283 284 } 285 308 286 public static void addObserver(PlayerObserver observer) { 309 287 … … 312 290 } 313 291 314 292 315 293 316 294 public static void removeObserver(PlayerObserver observer) {
Note:
See TracChangeset
for help on using the changeset viewer.