Changeset 25864 in osm for applications/editors/josm/plugins/videomapping/src/org
- Timestamp:
- 2011-04-17T22:34:09+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPlugin.java
r25861 r25864 29 29 import org.openstreetmap.josm.plugins.*; 30 30 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideoPlayer; 31 import org.openstreetmap.josm.plugins.videomapping.video.VideoEngine; 31 32 import org.openstreetmap.josm.tools.Shortcut; 32 33 import org.openstreetmap.josm.actions.JosmAction; … … 68 69 public VideoPlugin(PluginInformation info) { 69 70 super(info); 71 VideoEngine.setupPlayer(); 70 72 MapView.addLayerChangeListener(this); 71 73 createMenusAndShortCuts(); -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPositionLayer.java
r25861 r25864 35 35 import org.openstreetmap.josm.gui.layer.GpxLayer; 36 36 import org.openstreetmap.josm.gui.layer.Layer; 37 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideo; 37 38 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideoPlayer; 39 import org.openstreetmap.josm.plugins.videomapping.video.Video; 38 40 39 41 //Basic rendering and GPS layer interaction … … 44 46 private WayPoint iconPosition; 45 47 private final int GPS_INTERVALL=1000; 48 private GPSVideoPlayer gpsVideoPlayer; 46 49 47 50 public VideoPositionLayer(GpxLayer gpsLayer) { … … 73 76 public void paint(Graphics2D g, MapView map, Bounds bound) { 74 77 paintGpsTrack(g); 78 paintSyncedTrack(g); 75 79 paintPositionIcon(g); 76 paintInterpolatedSegment(g); 80 //paintInterpolatedSegment(g); //just a test for my own 77 81 } 78 82 … … 85 89 } 86 90 91 private void paintSyncedTrack(Graphics2D g) { 92 g.setColor(Color.GREEN); 93 for (WayPoint n : gpsTrack) { 94 if (n.attr.containsKey("synced")) 95 { 96 Point p = Main.map.mapView.getPoint(n.getEastNorth()); 97 g.drawOval(p.x - 2, p.y - 2, 4, 4); 98 } 99 } 100 101 } 102 87 103 private void paintPositionIcon(Graphics2D g) { 88 104 Point p=Main.map.mapView.getPoint(iconPosition.getEastNorth()); … … 119 135 test.setHours(14); 120 136 test.setMinutes(50); 121 test.setSeconds(33); 122 137 test.setSeconds(33); 123 138 ls.add(getWayPointBefore(new Date(test.getTime()+500))); 124 139 ls.add(interpolate(new Date(test.getTime()+500))); 125 System.out.print(test);126 140 return ls; 127 141 } … … 201 215 return iconPosition.getTime(); 202 216 } 217 218 public WayPoint getCurrentWayPoint() 219 { 220 return iconPosition; 221 } 222 223 224 225 public List<WayPoint> getTrack() { 226 return gpsTrack; 227 228 } 203 229 204 230 public void mouseReleased(MouseEvent e) { … … 208 234 if(wp!=null) 209 235 { 236 if (gpsVideoPlayer.areAllVideosSynced()) 237 { 238 //we set the video to right position 239 gpsVideoPlayer.jumpTo(wp.getTime()); 240 } 210 241 iconPosition=wp; 211 }212 Main.map.mapView.repaint();242 Main.map.mapView.repaint(); 243 } 213 244 } 214 245 … … 293 324 } 294 325 295 public void mousePressed(MouseEvent arg0) { 296 // TODO Auto-generated method stub 297 326 public void mousePressed(MouseEvent e) { 298 327 } 299 328 … … 306 335 // TODO Auto-generated method stub 307 336 337 } 338 339 public void setGPSVideoPlayer(GPSVideoPlayer player) 340 { 341 gpsVideoPlayer=player; 308 342 } 309 343 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideo.java
r25861 r25864 2 2 import java.awt.Canvas; 3 3 import java.io.File; 4 import java.util.Calendar; 5 import java.util.Date; 6 import java.util.List; 4 7 5 8 import javax.swing.JComponent; 9 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.gpx.WayPoint; 12 import org.openstreetmap.josm.plugins.videomapping.VideoPositionLayer; 6 13 7 14 // a specific synced video 8 15 public class GPSVideo extends Video{ 9 16 public JComponent SyncComponent; 10 public GPSVideo(File filename, Canvas canvas) { 11 super(filename, canvas); 17 private WayPoint syncWayPoint; 18 private long syncVideoTime; 19 private Date start; 20 private Date end; 21 public WayPoint firstWayPoint; 22 public WayPoint lastWayPoint; 23 private VideoPositionLayer videoPositionLayer; 24 25 public GPSVideo(File filename) { 26 super(filename); 12 27 } 13 28 29 public GPSVideo(Video video) 30 { 31 super(video.filename); 32 this.player=video.player; 33 } 34 35 public void doSync(VideoPositionLayer layer) { 36 this.videoPositionLayer=layer; 37 syncWayPoint=layer.getCurrentWayPoint(); 38 syncVideoTime=getCurrentTime(); 39 //calc now, to avoid calculations on every click 40 start=new Date(syncWayPoint.getTime().getTime()-syncVideoTime); 41 end=new Date(start.getTime()+player.getLength()); 42 firstWayPoint=getFirstGPS(); 43 lastWayPoint=getLastGPS(); 44 markSyncedWayPoints(); 45 Main.map.mapView.repaint(); 46 System.out.println(firstWayPoint.getTime()); 47 System.out.println(lastWayPoint.getTime()); 48 49 } 50 51 //make sure we don't leave the GPS track 52 private WayPoint getFirstGPS() { 53 if(start.before(videoPositionLayer.getFirstWayPoint().getTime())) 54 { 55 return videoPositionLayer.getFirstWayPoint(); 56 } 57 else 58 { 59 return videoPositionLayer.getWayPointBefore(start); 60 } 61 } 62 63 //make sure we don't leave the GPS track 64 private WayPoint getLastGPS() { 65 if(end.after(videoPositionLayer.getLastWayPoint().getTime())) 66 { 67 return videoPositionLayer.getLastWayPoint(); 68 } 69 else 70 { 71 return videoPositionLayer.getWayPointBefore(end); 72 } 73 } 74 75 private void markSyncedWayPoints() { 76 List <WayPoint> track =videoPositionLayer.getTrack(); 77 int start=track.indexOf(firstWayPoint); 78 int end=track.indexOf(lastWayPoint); 79 List <WayPoint> ls =videoPositionLayer.getTrack().subList(start, end); 80 for (WayPoint n : ls) { 81 n.attr.put("synced", Boolean.TRUE); 82 } 83 84 85 } 86 87 public boolean isSynced() { 88 return firstWayPoint!=null; 89 } 90 91 public void jumpTo(Date GPSTime) { 92 if((GPSTime.after(firstWayPoint.getTime())&(GPSTime.before(lastWayPoint.getTime())))) 93 { 94 long diff=GPSTime.getTime()-start.getTime(); 95 player.setTime(diff); 96 System.out.println(diff); 97 } 98 } 14 99 15 100 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoPlayer.java
r25861 r25864 8 8 import java.awt.event.WindowEvent; 9 9 import java.io.File; 10 import java.sql.Date;11 import java.sql.Time;12 10 import java.text.DateFormat; 11 import java.util.Calendar; 12 import java.util.Date; 13 13 import java.util.Iterator; 14 14 import java.util.LinkedList; … … 23 23 import org.openstreetmap.josm.Main; 24 24 import org.openstreetmap.josm.data.gpx.WayPoint; 25 import org.openstreetmap.josm.plugins.videomapping.GpsPlayer;26 25 import org.openstreetmap.josm.plugins.videomapping.VideoObserver; 27 26 import org.openstreetmap.josm.plugins.videomapping.VideoPositionLayer; … … 33 32 public class GPSVideoPlayer extends VideoPlayer 34 33 { 35 private JPanel syncPanel;36 34 private List<GPSVideo> videos; 37 private List<JButton> syncButtons;38 35 private VideoPositionLayer videoPositionLayer; 39 36 40 37 public GPSVideoPlayer(DateFormat videoTimeFormat,VideoPositionLayer videoPositionLayer) throws HeadlessException { 41 38 super(videoTimeFormat); 42 extendUI(); 43 syncButtons=new LinkedList<JButton>(); 39 videos = new LinkedList<GPSVideo>(); 44 40 this.videoPositionLayer=videoPositionLayer; 41 videoPositionLayer.setGPSVideoPlayer(this); 45 42 } 46 43 44 47 45 @Override 48 public GPSVideo addVideo(File Videofile) { 49 50 GPSVideo video=(GPSVideo) super.addVideo(Videofile); 46 public GPSVideo addVideo(File Videofile) { 47 GPSVideo video = new GPSVideo(super.addVideo(Videofile)); 51 48 videos.add(video); 52 49 JButton syncButton= new JButton(tr("Sync")); 53 syncButton.setBackground(Color.RED); 54 syncPanel.add(syncButton); 50 syncButton.setBackground(Color.RED); 55 51 syncButton.addActionListener(new ActionListener() { 56 52 //do a sync 57 53 public void actionPerformed(ActionEvent e) { 58 54 GPSVideo v=findVideo((JButton)e.getSource()); 59 doSync( v,videoPositionLayer);55 v.doSync(videoPositionLayer); 60 56 } 61 57 }); 58 video.SyncComponent=syncButton; 59 //video.panel.add(syncButton,BorderLayout.SOUTH); 60 controlsPanel.add(syncButton); 62 61 return video; 63 } 64 65 protected void doSync(GPSVideo v, VideoPositionLayer layer) { 66 WayPoint first=getFirstGPS(v.getTime(),layer.getGPSDate()); 67 68 } 69 70 //make sure we don't leave the GPS track 71 private WayPoint getFirstGPS(long videoTime, java.util.Date gpsDate) { 72 Date start=new Date(gpsDate.getTime()-videoTime); 73 if(start.before(videoPositionLayer.getFirstWayPoint().getTime())) 74 { 75 return videoPositionLayer.getFirstWayPoint(); 76 } 77 else 78 { 79 return videoPositionLayer.getWayPointBefore(start); 80 } 81 } 82 83 //make sure we don't leave the GPS track 84 private WayPoint getLastGPS(long videoTime, java.util.Date gpsDate) { 85 Date end=new Date(gpsDate.getTime()-videoTime); 86 if(end.after(videoPositionLayer.getLastWayPoint().getTime())) 87 { 88 return videoPositionLayer.getLastWayPoint(); 89 } 90 else 91 { 92 return videoPositionLayer.getWayPointBefore(end); 93 } 94 } 62 } 95 63 96 64 protected GPSVideo findVideo(JButton source) { … … 100 68 return null; 101 69 } 70 71 public void jumpTo(Date date) 72 { 73 for (GPSVideo video : videos) { 74 video.jumpTo(date); 75 } 76 } 77 78 public boolean areAllVideosSynced() 79 { 102 80 103 private void extendUI() {104 syncPanel=new JPanel(new FlowLayout());105 screenPanel.add(syncPanel,BorderLayout.EAST);106 81 for (GPSVideo video : videos) { 82 if (!video.isSynced()) return false; 83 } 84 return true; 107 85 } 108 86 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/Video.java
r25861 r25864 1 1 package org.openstreetmap.josm.plugins.videomapping.video; 2 2 3 import java.awt.BorderLayout; 3 4 import java.awt.Canvas; 5 import java.awt.FlowLayout; 4 6 import java.io.File; 7 8 import javax.swing.JPanel; 5 9 6 10 import uk.co.caprica.vlcj.player.MediaPlayer; … … 10 14 public MediaPlayer player; 11 15 public Canvas canvas; 16 public JPanel panel; 12 17 13 public Video(File filename , Canvas canvas) {18 public Video(File filename) { 14 19 this.filename=filename; 15 this.canvas=canvas; 20 canvas=new Canvas(); 21 panel=new JPanel(); 22 panel.setLayout(new FlowLayout()); 23 panel.add(canvas,BorderLayout.CENTER); 16 24 } 17 25 18 public long getTime() 26 public long getCurrentTime() 19 27 { 20 28 return player.getTime(); -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoEngine.java
r25765 r25864 85 85 } 86 86 87 private Video getVideo(MediaPlayer mp) 88 { 89 for (Video video : videos) { 90 if (video.player==mp) return video; 91 } 92 return null; 93 } 94 95 public List<Video> getVideos() { 96 return videos; 97 } 98 87 99 public void play() 88 100 { … … 119 131 120 132 //TODO muss auf Rückgabe für alle Videos erweitert werden 121 public long get CurrentVideoTime()133 public long getVideoTime() 122 134 { 123 135 return videos.get(0).player.getTime(); … … 212 224 } 213 225 226 public void addObserver(VideosObserver observer) { 227 observers.add(observer); 228 229 } 230 231 private void notifyObservers(VideoObserversEvents event) 232 { 233 for (VideosObserver observer : observers) { 234 observer.update(event); 235 } 236 } 237 214 238 public void backward(MediaPlayer arg0) { 215 239 … … 285 309 286 310 } 287 288 private Video getVideo(MediaPlayer mp)289 {290 for (Video video : videos) {291 if (video.player==mp) return video;292 }293 return null;294 }295 296 private void notifyObservers(VideoObserversEvents event)297 {298 for (VideosObserver observer : observers) {299 observer.update(event);300 }301 }302 303 public void addObserver(VideosObserver observer) {304 observers.add(observer);305 306 }307 311 308 312 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoPlayer.java
r25861 r25864 96 96 public Video addVideo(File Videofile) 97 97 { 98 Video video = new Video(Videofile ,new Canvas());99 canvasPanel.add(video. canvas);98 Video video = new Video(Videofile); 99 canvasPanel.add(video.panel); 100 100 video.canvas.setSize(new Dimension(300, 300)); // will be updated by the video engine itself 101 101 videoengine.add(video); … … 104 104 return video; 105 105 } 106 107 protected void play() { 108 videoengine.play(); 109 110 } 106 107 public List <Video> getVideos() 108 { 109 return videoengine.getVideos(); 110 } 111 111 112 112 113 protected void pause(){ 114 if (notificationTimer!=null) 115 { 116 notificationTimer.cancel(); 117 notificationTimer=null; 118 } 119 else 120 { 121 startNotificationTimer(); 122 } 113 123 videoengine.pause(); 114 124 } … … 126 136 { 127 137 //do reset after loop time experienced 128 final long videoResetTime=(long) videoengine.get CurrentVideoTime()-loopLength/2;138 final long videoResetTime=(long) videoengine.getVideoTime()-loopLength/2; 129 139 TimerTask reset=new TimerTask() { 130 140 @Override … … 237 247 isManualJump=true; 238 248 videoengine.jumpToPosition((timeline.getValue())); 249 System.out.println("manual jump"); 239 250 } 240 251 } … … 343 354 public void update_plays() { 344 355 timeline.setValue(videoengine.getPosition()); 345 System.out.println(videoengine.getPosition());356 setTitle(Long.toString(videoengine.getVideoTime())); 346 357 isManualJump=false; 358 System.out.println("update"); 347 359 348 360 }
Note:
See TracChangeset
for help on using the changeset viewer.