Changeset 25865 in osm for applications/editors
- Timestamp:
- 2011-04-18T14:59:07+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
r25864 r25865 5 5 import java.awt.event.ActionEvent; 6 6 import java.awt.event.KeyEvent; 7 import java.beans.PropertyChangeListener; 7 8 import java.io.File; 8 9 import java.text.ParseException; 9 10 import java.text.SimpleDateFormat; 11 import java.util.Calendar; 10 12 import java.util.Date; 11 13 14 import javax.swing.Action; 12 15 import javax.swing.Box; 13 16 import javax.swing.InputVerifier; … … 18 21 import javax.swing.JFileChooser; 19 22 import javax.swing.JFormattedTextField; 23 import javax.swing.JLabel; 20 24 import javax.swing.JMenu; 21 25 import javax.swing.JMenuItem; … … 66 70 private String mostRecentFolder; 67 71 private GpxLayer gpsLayer; 72 private VideoPositionLayer videoPositionLayer; 73 private GPSVideoPlayer gpsVideoPlayer; 68 74 69 75 public VideoPlugin(PluginInformation info) { … … 94 100 VStart = new JosmAction(tr("Play/Pause"), "audio-playpause", tr("starts/pauses video playback"), 95 101 Shortcut.registerShortcut("videomapping:startstop","Video: "+tr("Play/Pause"),KeyEvent.VK_NUMPAD5, Shortcut.GROUP_DIRECT), false) { 96 public void actionPerformed(ActionEvent e) { 97 102 public void actionPerformed(ActionEvent e) { 103 gpsVideoPlayer.pause(); 98 104 } 99 105 }; … … 101 107 Shortcut.registerShortcut("videomapping:backward","Video: "+tr("Backward"),KeyEvent.VK_NUMPAD4, Shortcut.GROUP_DIRECT), false) { 102 108 public void actionPerformed(ActionEvent e) { 103 109 gpsVideoPlayer.backward(); 104 110 } 105 111 }; … … 107 113 Shortcut.registerShortcut("videomapping:forward","Video: "+tr("Forward"),KeyEvent.VK_NUMPAD6, Shortcut.GROUP_DIRECT), false) { 108 114 public void actionPerformed(ActionEvent e) { 109 115 gpsVideoPlayer.forward(); 110 116 111 117 } … … 115 121 116 122 public void actionPerformed(ActionEvent e) { 117 123 gpsVideoPlayer.setSpeed(gpsVideoPlayer.getSpeed()+20); 118 124 119 125 } … … 123 129 124 130 public void actionPerformed(ActionEvent e) { 125 131 gpsVideoPlayer.setSpeed(gpsVideoPlayer.getSpeed()-20); 126 132 127 133 } … … 129 135 VJump= new JosmAction(tr("Jump To"), "jumpto", tr("jumps to the entered gps time"),null, false) { 130 136 public void actionPerformed(ActionEvent e) { 131 132 137 showJumpTo(); 133 138 } 134 139 … … 138 143 Shortcut.registerShortcut("videomapping:loop","Video: "+tr("loop"),KeyEvent.VK_NUMPAD7, Shortcut.GROUP_DIRECT), false) { 139 144 public void actionPerformed(ActionEvent e) { 140 141 145 gpsVideoPlayer.toggleLooping(); 142 146 } 143 147 }; … … 146 150 VCenterIcon = new JCheckBoxMenuItem(new JosmAction(tr("Keep centered"), null, tr("follows the video icon automaticly"),null, false) { 147 151 public void actionPerformed(ActionEvent e) { 148 149 150 } 151 }); 152 //now the options menu 152 videoPositionLayer.setAutoCenter(VCenterIcon.isSelected()); 153 } 154 }); 155 153 156 VSubTitles = new JCheckBoxMenuItem(new JosmAction(tr("Subtitles"), null, tr("Show subtitles in video"),null, false) { 154 157 public void actionPerformed(ActionEvent e) { 155 156 158 gpsVideoPlayer.setSubtitles(VSubTitles.isSelected()); 157 159 } 158 160 }); 159 161 160 162 VJumpLength = new JMenuItem(new JosmAction(tr("Jump length"), null, tr("Set the length of a jump"),null, false) { 161 public void actionPerformed(ActionEvent e) { 163 public void actionPerformed(ActionEvent e) { 164 Object[] possibilities = {"200", "500", "1000", "2000", "10000"}; 165 String s = (String)JOptionPane.showInputDialog(Main.parent,tr("Jump in video for x ms"),tr("Jump length"),JOptionPane.QUESTION_MESSAGE,null,possibilities,jumpLength); 166 jumpLength=Integer.getInteger(s); 167 saveProperties(); 162 168 } 163 169 }); … … 165 171 VLoopLength = new JMenuItem(new JosmAction(tr("Loop length"), null, tr("Set the length around a looppoint"),null, false) { 166 172 public void actionPerformed(ActionEvent e) { 167 168 173 Object[] possibilities = {"500", "1000", "3000", "5000", "10000"}; 174 String s = (String)JOptionPane.showInputDialog(Main.parent,tr("Jump in video for x ms"),tr("Loop length"),JOptionPane.QUESTION_MESSAGE,null,possibilities,loopLength); 175 loopLength=Integer.getInteger(s); 176 saveProperties(); 169 177 } 170 178 }); 171 179 VDeinterlacer= new JMenu("Deinterlacer"); 172 180 VIntNone= new JRadioButtonMenuItem(new JosmAction(tr("none"), null, tr("no deinterlacing"),null, false) { 173 public void actionPerformed(ActionEvent e) { 181 public void actionPerformed(ActionEvent e) { 182 gpsVideoPlayer.setDeinterlacer("none"); 174 183 } 175 184 }); 176 185 VIntBob= new JRadioButtonMenuItem(new JosmAction("bob", null, tr("deinterlacing using line doubling"),null, false) { 177 186 public void actionPerformed(ActionEvent e) { 178 187 gpsVideoPlayer.setDeinterlacer("bob"); 179 188 } 180 189 }); 181 190 VIntLinear= new JRadioButtonMenuItem(new JosmAction("linear", null, tr("deinterlacing using linear interpolation"),null, false) { 182 191 public void actionPerformed(ActionEvent e) { 183 192 gpsVideoPlayer.setDeinterlacer("linear"); 184 193 } 185 194 }); … … 211 220 mostRecentFolder=fc.getSelectedFile().getAbsolutePath(); 212 221 saveProperties(); 213 VideoPositionLayer videoPositionLayer= new VideoPositionLayer(gpsLayer); 214 GPSVideoPlayer gpsVideoPlayer = new GPSVideoPlayer(new SimpleDateFormat("hh:mm:ss") ,videoPositionLayer); 222 videoPositionLayer= new VideoPositionLayer(gpsLayer); 223 gpsVideoPlayer = new GPSVideoPlayer(new SimpleDateFormat("hh:mm:ss") ,videoPositionLayer); 224 gpsVideoPlayer.setJumpLength(jumpLength); 225 gpsVideoPlayer.setLoopLength(loopLength); 215 226 gpsVideoPlayer.addVideo(fc.getSelectedFile()); 227 enableVideoControlMenus(true); 216 228 } 217 229 … … 273 285 } 274 286 287 private void showJumpTo() 288 { 289 String s; 290 try { 291 JOptionPane d=new JOptionPane(tr("Jump to"), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); 292 SimpleDateFormat gpsTimeFormat= new SimpleDateFormat("HH:mm:ss"); 293 String timerange=gpsTimeFormat.format(videoPositionLayer.getFirstWayPoint().getTime())+" - "; 294 timerange=timerange+gpsTimeFormat.format(videoPositionLayer.getLastWayPoint().getTime()); 295 d.add(new JLabel(timerange)); //TODO for some reason this doesn't work -> use dialog 296 final JFormattedTextField inp = new JFormattedTextField(new MaskFormatter("##:##:##")); 297 inp.setText(gpsTimeFormat.format( videoPositionLayer.getGPSDate())); 298 inp.setInputVerifier(new InputVerifier() { 299 @Override 300 public boolean verify(JComponent input) { 301 return false; 302 } 303 }); 304 //hack to set the focus 305 SwingUtilities.invokeLater(new Runnable() { 306 public void run() { 307 inp.requestFocus(); 308 inp.setCaretPosition(0); 309 } 310 }); 311 if(d.showConfirmDialog(Main.main.panel,inp, tr("Jump to GPS time"),JOptionPane.OK_CANCEL_OPTION)==JOptionPane.OK_OPTION) 312 { 313 //add the day to the time 314 Date t = gpsTimeFormat.parse(inp.getText()); 315 Calendar time = Calendar.getInstance(); 316 Calendar date = Calendar.getInstance(); 317 time.setTime(t); 318 date.setTime(videoPositionLayer.getFirstWayPoint().getTime()); 319 time.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DATE)); 320 if (t!=null) 321 { 322 videoPositionLayer.jump(time.getTime()); 323 } 324 } 325 } catch (ParseException e1) { 326 e1.printStackTrace(); 327 } 328 } 329 275 330 276 331 public void activeLayerChange(Layer oldLayer, Layer newLayer) { -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPositionLayer.java
r25864 r25865 47 47 private final int GPS_INTERVALL=1000; 48 48 private GPSVideoPlayer gpsVideoPlayer; 49 private boolean autoCenter; 49 50 50 51 public VideoPositionLayer(GpxLayer gpsLayer) { … … 142 143 143 144 //creates a waypoint for the corresponding time 144 p rivateWayPoint interpolate(Date GPSTime)145 public WayPoint interpolate(Date GPSTime) 145 146 { 146 147 WayPoint before =getWayPointBefore(GPSTime); … … 227 228 228 229 } 230 231 public void jump(Date GPSTime) 232 { 233 setIconPosition(getWayPointBefore(GPSTime)); 234 235 } 236 237 public void setIconPosition(WayPoint wp) { 238 iconPosition=wp; 239 Main.map.mapView.repaint(); 240 if (autoCenter) 241 Main.map.mapView.zoomTo(iconPosition.getCoor()); 242 243 } 229 244 230 245 public void mouseReleased(MouseEvent e) { … … 239 254 gpsVideoPlayer.jumpTo(wp.getTime()); 240 255 } 241 iconPosition=wp; 242 Main.map.mapView.repaint(); 256 setIconPosition(wp); 243 257 } 244 258 } 245 259 246 260 } 247 261 248 262 //finds the first waypoint that is nearby the given point 249 263 private WayPoint getNearestWayPoint(Point mouse) … … 341 355 gpsVideoPlayer=player; 342 356 } 357 358 public void setAutoCenter(boolean enabled) { 359 autoCenter=enabled; 360 361 } 362 363 public void unload() { 364 Main.main.removeLayer(this); 365 366 } 343 367 344 368 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideo.java
r25864 r25865 96 96 System.out.println(diff); 97 97 } 98 } 98 } 99 100 public WayPoint getCurrentWayPoint() 101 { 102 if (isSynced()) 103 { 104 long videotime=player.getTime(); 105 Date gpstime=new Date(start.getTime()+videotime); 106 return videoPositionLayer.interpolate(gpstime); 107 } 108 return null; 109 } 99 110 100 111 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoPlayer.java
r25864 r25865 84 84 return true; 85 85 } 86 87 88 @Override 89 public void update_plays() { 90 super.update_plays(); 91 if (areAllVideosSynced()) 92 videoPositionLayer.setIconPosition( videos.get(0).getCurrentWayPoint()); 93 } 94 95 @Override 96 public void windowClosing(WindowEvent arg0) { 97 videoPositionLayer.unload(); 98 super.windowClosing(arg0); 99 } 100 86 101 87 102 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoPlayer.java
r25864 r25865 60 60 //basic class of a videoplayer for one video 61 61 public class VideoPlayer extends JFrame implements WindowListener, VideosObserver, VideoPlayerObserver{ 62 private static final int notificationIntervall = 1000;62 private static final int notificationIntervall = 500; 63 63 protected JPanel screenPanel,controlsPanel,canvasPanel; 64 64 private JSlider timeline; … … 111 111 112 112 113 p rotectedvoid pause(){113 public void pause(){ 114 114 if (notificationTimer!=null) 115 115 { … … 124 124 } 125 125 126 p rotectedvoid backward() {126 public void backward() { 127 127 videoengine.jump(-jumpLength); 128 128 } 129 129 130 p rotectedvoid forward() {130 public void forward() { 131 131 videoengine.jump(jumpLength); 132 132 } 133 133 134 protected void toggleLooping() { 134 public void setSpeed(Integer percent) 135 { 136 speed.setValue(percent); 137 } 138 139 public Integer getSpeed() 140 { 141 return speed.getValue(); 142 } 143 144 public void setDeinterlacer(String deinterlacer) 145 { 146 videoengine.setDeinterlacer(deinterlacer); 147 } 148 149 public void setSubtitles(boolean enabled) 150 { 151 videoengine.setSubtitles(enabled); 152 } 153 154 public void mute() 155 { 156 videoengine.mute(); 157 } 158 159 public void toggleLooping() { 135 160 if(loopingTimer==null) 136 161 { … … 236 261 237 262 public void actionPerformed(ActionEvent arg0) { 238 videoengine.mute();263 mute(); 239 264 } 240 265 }); … … 254 279 255 280 speed.addChangeListener(new ChangeListener() { 256 public void stateChanged(ChangeEvent arg0) { 281 public void stateChanged(ChangeEvent arg0) { 257 282 if(!speed.getValueIsAdjusting()) 258 283 { -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoPlayerObserver.java
r25765 r25865 3 3 public interface VideoPlayerObserver { 4 4 public void update_plays(); 5 5 6 }
Note:
See TracChangeset
for help on using the changeset viewer.