Changeset 25894 in osm for applications/editors/josm/plugins/videomapping/src/org
- Timestamp:
- 2011-04-25T16:28:14+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPlugin.java
r25865 r25894 176 176 saveProperties(); 177 177 } 178 }); 178 }); 179 //TODO read deinterlacers list out of videoengine 179 180 VDeinterlacer= new JMenu("Deinterlacer"); 180 181 VIntNone= new JRadioButtonMenuItem(new JosmAction(tr("none"), null, tr("no deinterlacing"),null, false) { … … 217 218 fc.setSelectedFile(new File(mostRecentFolder)); 218 219 if(fc.showOpenDialog(Main.main.parent)!=JFileChooser.CANCEL_OPTION) 219 { 220 { 220 221 mostRecentFolder=fc.getSelectedFile().getAbsolutePath(); 221 222 saveProperties(); 222 videoPositionLayer= new VideoPositionLayer(gpsLayer); 223 gpsVideoPlayer = new GPSVideoPlayer(new SimpleDateFormat("hh:mm:ss") ,videoPositionLayer); 224 gpsVideoPlayer.setJumpLength(jumpLength); 225 gpsVideoPlayer.setLoopLength(loopLength); 226 gpsVideoPlayer.addVideo(fc.getSelectedFile()); 227 enableVideoControlMenus(true); 223 if(videoPositionLayer==null) 224 { 225 videoPositionLayer= new VideoPositionLayer(gpsLayer); 226 gpsVideoPlayer = new GPSVideoPlayer(new SimpleDateFormat("hh:mm:ss") ,videoPositionLayer); 227 gpsVideoPlayer.setJumpLength(jumpLength); 228 gpsVideoPlayer.setLoopLength(loopLength); 229 enableVideoControlMenus(true); 230 } 231 gpsVideoPlayer.addVideo(fc.getSelectedFile()); 228 232 } 229 233 … … 272 276 } 273 277 274 private void applySettings() 275 { 276 //GUI 277 VCenterIcon.setSelected(autoCenter); 278 VIntNone.setSelected(true); 279 if(deinterlacer=="") 280 VIntNone.setSelected(true); 281 if(deinterlacer=="bob") 282 VIntBob.setSelected(true); 283 if(deinterlacer=="linear") 284 VIntLinear.setSelected(true); 285 } 286 278 287 279 private void showJumpTo() 288 280 { … … 345 337 346 338 public void layerRemoved(Layer arg0) { 339 if(arg0 instanceof VideoPositionLayer) 340 enableVideoControlMenus(false); 347 341 activeLayerChange(null,arg0); 348 342 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideo.java
r25865 r25894 14 14 // a specific synced video 15 15 public class GPSVideo extends Video{ 16 private static final String SYNC_KEY = "synced"; 16 17 public JComponent SyncComponent; 17 18 private WayPoint syncWayPoint; … … 23 24 private VideoPositionLayer videoPositionLayer; 24 25 25 public GPSVideo(File filename) { 26 super(filename); 26 public GPSVideo(File filename, String id) { 27 super(filename,id); 27 28 } 28 29 29 30 public GPSVideo(Video video) 30 31 { 31 super(video.filename); 32 super(video.filename,video.id); 32 33 this.player=video.player; 33 34 } 34 35 36 //calculates attributes basing upon the current position 35 37 public void doSync(VideoPositionLayer layer) { 36 38 this.videoPositionLayer=layer; 39 if (isSynced()) 40 removeSyncedWayPoints(); 37 41 syncWayPoint=layer.getCurrentWayPoint(); 38 42 syncVideoTime=getCurrentTime(); … … 44 48 markSyncedWayPoints(); 45 49 Main.map.mapView.repaint(); 46 System.out.println(firstWayPoint.getTime());47 System.out.println(lastWayPoint.getTime());48 49 50 } 50 51 … … 72 73 } 73 74 } 75 76 private void removeSyncedWayPoints() { 77 List <WayPoint> track =videoPositionLayer.getTrack(); 78 int start=track.indexOf(firstWayPoint); 79 int end=track.indexOf(lastWayPoint); 80 List <WayPoint> ls =videoPositionLayer.getTrack().subList(start, end); 81 for (WayPoint n : ls) { 82 n.attr.keySet().remove(SYNC_KEY); 83 } 84 } 74 85 75 86 private void markSyncedWayPoints() { … … 79 90 List <WayPoint> ls =videoPositionLayer.getTrack().subList(start, end); 80 91 for (WayPoint n : ls) { 81 n.attr.put("synced", Boolean.TRUE); 82 } 83 84 92 n.attr.put(SYNC_KEY, id); 93 } 85 94 } 86 95 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoPlayer.java
r25865 r25894 43 43 44 44 45 @Override46 45 public GPSVideo addVideo(File Videofile) { 47 GPSVideo video = new GPSVideo(super.addVideo(Videofile)); 46 GPSVideo video = new GPSVideo(super.addVideo(Videofile,Integer.toString(videos.size()))); 47 enableSingleVideoMode(true); 48 48 videos.add(video); 49 addSyncButton(video); 50 return video; 51 } 52 53 54 private void addSyncButton(GPSVideo video) { 49 55 JButton syncButton= new JButton(tr("Sync")); 50 56 syncButton.setBackground(Color.RED); 51 57 syncButton.addActionListener(new ActionListener() { 52 //do a sync53 58 public void actionPerformed(ActionEvent e) { 54 GPSVideo v=findVideo((JButton)e.getSource()); 55 v.doSync(videoPositionLayer); 56 } 59 resync(e); 60 } 57 61 }); 58 62 video.SyncComponent=syncButton; 59 63 //video.panel.add(syncButton,BorderLayout.SOUTH); 60 64 controlsPanel.add(syncButton); 61 return video;62 65 } 63 66 67 //do a (re)sync 68 private void resync(ActionEvent e) { 69 JButton btn =(JButton)e.getSource(); 70 GPSVideo v=findVideo(btn); 71 v.doSync(videoPositionLayer); 72 btn.setBackground(Color.GREEN); 73 enableSingleVideoMode(false); 74 } 75 64 76 protected GPSVideo findVideo(JButton source) { 65 77 for (GPSVideo v : videos) { -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/Video.java
r25864 r25894 12 12 public class Video { 13 13 public File filename; 14 public String id; //unique id to make it easy to identify 14 15 public MediaPlayer player; 15 16 public Canvas canvas; 16 public JPanel panel; 17 public JPanel panel; 17 18 18 public Video(File filename) { 19 public Video(File filename, String id) { 19 20 this.filename=filename; 21 this.id=id; 20 22 canvas=new Canvas(); 21 23 panel=new JPanel(); -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoEngine.java
r25864 r25894 31 31 private final String[] libvlcArgs = {""}; 32 32 private final String[] standardMediaOptions = {""}; 33 private final String[] deinterlacers = {"bob","linear"}; 33 private final static String[] deinterlacers = {"bob","linear"}; 34 34 private final float initialCanvasFactor = 0.5f; 35 private boolean singleVideoMode; //commands will only affect the last added video 36 private Video lastAddedVideo; 35 37 36 38 //called at plugin start to setup library … … 69 71 mp.setStandardMediaOptions(standardMediaOptions); 70 72 videos.add(video); 73 lastAddedVideo=video; 71 74 mp.setVideoSurface(video.canvas); 72 75 mp.addMediaPlayerEventListener(this); … … 97 100 } 98 101 99 public void play() 100 { 101 for (Video video : videos) { 102 video.player.play(); 102 public void play() 103 { 104 if (singleVideoMode) 105 { 106 lastAddedVideo.player.play(); 107 } 108 else 109 { 110 for (Video video : videos) { 111 video.player.play(); 112 } 103 113 } 104 114 System.out.println("abspielen"); 105 115 } 106 116 117 //toggles pause and play 107 118 public void pause() 108 119 { 109 for (Video video : videos) { 110 video.player.pause(); 111 } 112 } 113 120 if (singleVideoMode) 121 { 122 lastAddedVideo.player.pause(); 123 } 124 else 125 { 126 for (Video video : videos) { 127 video.player.pause(); 128 } 129 } 130 } 131 132 //ensures that all stop 133 public void pauseAll() { 134 for (Video video : videos) { 135 if (video.player.isPlaying()) 136 video.player.pause(); 137 } 138 } 139 114 140 //jumps relative for ms in all videos 115 public void jump(long ms) { 116 for (Video video : videos) { 117 long start=video.player.getTime(); 118 video.player.setTime(start+ms); 119 } 141 public void jumpFor(long ms) { 142 if (singleVideoMode) 143 { 144 long start=lastAddedVideo.player.getTime(); 145 lastAddedVideo.player.setTime(start+ms); 146 } 147 else 148 { 149 for (Video video : videos) { 150 long start=video.player.getTime(); 151 video.player.setTime(start+ms); 152 } 153 } 154 notifyObservers(VideoObserversEvents.jumping); 120 155 121 156 } … … 124 159 public void jumpTo(long msVideo) 125 160 { 126 for (Video video : videos) { 127 video.player.setTime(msVideo); 161 if (singleVideoMode) 162 { 163 lastAddedVideo.player.setTime(msVideo); 164 } 165 else 166 { 167 for (Video video : videos) { 168 video.player.setTime(msVideo); 169 } 128 170 } 129 171 notifyObservers(VideoObserversEvents.jumping); 130 172 } 131 173 132 //TODO muss auf Rückgabe für alle Videos erweitert werden 174 //TODO muss evtl. auf Rückgabe für alle Videos erweitert werden 133 175 public long getVideoTime() 134 176 { … … 139 181 public void jumpToPosition(int percent) 140 182 { 141 for (Video video : videos) { 142 float position = ((float)percent/100f); 143 video.player.setPosition(position); 183 float position = ((float)percent/100f); 184 if (singleVideoMode) 185 { 186 lastAddedVideo.player.setPosition(position); 187 } 188 else 189 { 190 for (Video video : videos) { 191 video.player.setPosition(position); 192 } 144 193 } 145 194 notifyObservers(VideoObserversEvents.jumping); 146 195 } 147 196 197 //TODO has to be for every video 148 198 public int getPosition() 149 199 { … … 155 205 public void setSpeed(int percent) 156 206 { 207 if (singleVideoMode) 208 { 209 lastAddedVideo.player.setRate((float)(percent/100f)); 210 } 157 211 for (Video video : videos) { 158 212 video.player.setRate((float)(percent/100f)); … … 196 250 public void setDeinterlacer (String deinterlacer) 197 251 { 198 for (Video video : videos) { 199 video.player.setDeinterlace(deinterlacer); 200 } 201 } 202 203 public String[] getDeinterlacers() 252 if (singleVideoMode) 253 { 254 lastAddedVideo.player.setDeinterlace(deinterlacer); 255 } 256 else 257 { 258 for (Video video : videos) { 259 video.player.setDeinterlace(deinterlacer); 260 } 261 } 262 } 263 264 public static String[] getDeinterlacers() 204 265 { 205 266 return deinterlacers; … … 208 269 public void mute() 209 270 { 271 if (singleVideoMode) 272 { 273 lastAddedVideo.player.mute(); 274 } 210 275 for (Video video : videos) { 211 276 video.player.mute(); … … 310 375 } 311 376 377 public boolean isNoVideoPlaying() { 378 for (Video video : videos) { 379 if (video.player.isPlaying()) 380 return false; 381 } 382 return true; 383 } 384 385 public void enableSingleVideoMode(boolean enabled) { 386 singleVideoMode = true; 387 388 } 389 312 390 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoPlayer.java
r25865 r25894 94 94 } 95 95 96 public Video addVideo(File Videofile) 97 { 98 Video video = new Video(Videofile); 96 public Video addVideo(File Videofile,String id) 97 { 98 Video video = new Video(Videofile,id); 99 99 canvasPanel.add(video.panel); 100 100 video.canvas.setSize(new Dimension(300, 300)); // will be updated by the video engine itself … … 112 112 113 113 public void pause(){ 114 if (notificationTimer!=null) 115 { 116 notificationTimer.cancel(); 117 notificationTimer=null; 118 } 114 videoengine.pause(); 115 if (videoengine.isNoVideoPlaying()) 116 stopNotificationTimer(); 119 117 else 120 {121 118 startNotificationTimer(); 122 } 123 videoengine.pause(); 119 } 120 121 public void pauseAll() 122 { 123 stopNotificationTimer(); 124 videoengine.pauseAll(); 124 125 } 125 126 126 127 public void backward() { 127 videoengine.jump(-jumpLength); 128 videoengine.jumpFor(-jumpLength); 128 129 } 129 130 130 131 public void forward() { 131 videoengine.jump(jumpLength); 132 videoengine.jumpFor(jumpLength); 132 133 } 133 134 … … 157 158 } 158 159 160 //TODO auf mehrere Videos umstellen 159 161 public void toggleLooping() { 160 162 if(loopingTimer==null) … … 299 301 } 300 302 303 public void enableSingleVideoMode(boolean enabled) 304 { 305 pauseAll(); 306 videoengine.enableSingleVideoMode(enabled); 307 } 308 301 309 public void addObserver(VideoPlayerObserver observer) 302 310 { … … 305 313 306 314 315 private void stopNotificationTimer() { 316 /* 317 if(notificationTimer!=null) 318 { 319 notificationTimer.cancel(); 320 notificationTimer=null; 321 } 322 */ 323 } 324 307 325 private void startNotificationTimer() { 308 if(notificationTimer==null) 309 { 310 notificationTimer= new Timer(); 311 notificationTimer.schedule(new TimerTask() { 312 @Override 313 public void run() { 314 notifyObservers(); 315 316 } 317 },notificationIntervall,notificationIntervall); 318 } 326 notificationTimer= new Timer(); 327 notificationTimer.schedule(new TimerTask() { 328 @Override 329 public void run() { 330 notifyObservers(); 331 332 } 333 },notificationIntervall,notificationIntervall); 319 334 } 320 335 … … 369 384 { 370 385 speed.setValue(videoengine.getSpeed()); 386 break; 371 387 } 372 388 case jumping: 373 { 389 { 390 break; 374 391 } 375 392 }
Note:
See TracChangeset
for help on using the changeset viewer.