Changeset 183
- Timestamp:
- 03/09/08 16:03:46 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
MediAnnotate/trunk/src/org/mediannotate/app/PlayerPanel.java
r181 r183 18 18 import org.mediannotate.dom.IMovieObserver; 19 19 import org.mediannotate.dom.Movie; 20 import org.mediannotate.ui.TimeCodePanel;21 20 import org.mediannotate.ui.TimeLinePanel; 22 import org.mediannotate.ui. ToolButtonPanel;21 import org.mediannotate.ui.UtilityPanel; 23 22 import org.mediannotate.ui.listener.PlayButtonListener; 24 23 import org.mediannotate.ui.listener.StopButtonListener; … … 36 35 private Time durationTime; 37 36 private TimeLinePanel timeLinePanel = new TimeLinePanel(); 38 private ToolButtonPanel toolButtonPanel; 39 private TimeCodePanel timeCodePanel; 37 private UtilityPanel utilityPanel; 40 38 private Component currentMovieComponent; 41 39 private JPanel moviePanel = new JPanel(); … … 68 66 69 67 public void setTime(long time) { 70 timeCodePanel.updateTime();68 utilityPanel.updateTime(); 71 69 timeLinePanel.setLocation(time/(float)durationTime.getAllInMilli()); 72 70 } … … 111 109 moviePanel.repaint(); 112 110 durationTime = new Time(currentMovie.getDuration()); 113 timeCodePanel.setDuration(currentMovie.getDuration());111 utilityPanel.setDuration(currentMovie.getDuration()); 114 112 115 113 stopListener.setMovie(currentMovie); … … 128 126 stopListener = new StopButtonListener(); 129 127 130 toolButtonPanel = new ToolButtonPanel(this);128 utilityPanel = new UtilityPanel(this); 131 129 132 130 JPanel jp_outter = new JPanel(); 133 131 jp_outter.setLayout(new GridLayout(2, 1)); 134 jp_outter.add( toolButtonPanel, 0);132 jp_outter.add(utilityPanel, 0); 135 133 136 134 jp_outter.add(timeLinePanel, 1); … … 142 140 */ 143 141 timeLineListener.setTimeLinePanel(timeLinePanel); 144 145 timeCodePanel = new TimeCodePanel(this, toolButtonPanel); 146 142 147 143 add(jp_outter, BorderLayout.NORTH); 148 144 … … 246 242 247 243 public void mouseClicked(MouseEvent e) { 248 if(!e.getComponent().equals(timeCodePanel)) { 249 this.requestFocusInWindow(); 250 } 251 244 this.requestFocusInWindow(); 252 245 } 253 246 MediAnnotate/trunk/src/org/mediannotate/ui/UtilityPanel.java
r182 r183 3 3 import java.awt.event.ActionEvent; 4 4 import java.awt.event.ActionListener; 5 import java.awt.event.FocusEvent; 6 import java.awt.event.FocusListener; 5 7 import java.awt.image.BufferedImage; 6 8 import java.io.IOException; … … 10 12 import javax.swing.ImageIcon; 11 13 import javax.swing.JButton; 14 import javax.swing.JLabel; 15 import javax.swing.JOptionPane; 12 16 import javax.swing.JPanel; 17 import javax.swing.JTextField; 13 18 import javax.swing.ToolTipManager; 14 19 … … 18 23 import org.mediannotate.app.PlayerPanel; 19 24 20 public class ToolButtonPanel extends JPanel{25 public class UtilityPanel extends JPanel implements FocusListener{ 21 26 /** 22 27 * … … 24 29 private static final long serialVersionUID = 8627867059092046561L; 25 30 31 private static final String TIME_CODE_LABEL_FORMAT = "%02d hrs %02d min %02d sec"; 32 33 private static final String TIME_CODE_FORMAT = "%02d:%02d:%02d.%02d"; 26 34 35 private JTextField timeField; 36 private JLabel durationLabel; 37 private PlayerPanel myPlayerPanel; 38 private String innerTime = ""; 39 private boolean timecodeHasFocus; 27 40 28 public ToolButtonPanel(PlayerPanel p) {41 public UtilityPanel(PlayerPanel p) { 29 42 super(); 30 43 BufferedImage annotationImage = null; … … 52 65 } 53 66 JButton jb = new JButton(new ImageIcon(annotationImage)); 54 jb.addActionListener(new ToolButtonPanel.addAnnotationEventListener());67 jb.addActionListener(new UtilityPanel.addAnnotationEventListener()); 55 68 jb.setToolTipText("Save Annotation"); 56 69 this.add(jb); 57 70 58 71 jb = new JButton(new ImageIcon(inImage)); 59 jb.addActionListener(new ToolButtonPanel.markInEventHandler(p));72 jb.addActionListener(new UtilityPanel.markInEventHandler(p)); 60 73 jb.setToolTipText("Mark Start of Annotation (ctrl-i)"); 61 74 this.add(jb); 62 75 63 76 jb = new JButton(new ImageIcon(outImage)); 64 jb.addActionListener(new ToolButtonPanel.markOutEventHandler(p));77 jb.addActionListener(new UtilityPanel.markOutEventHandler(p)); 65 78 jb.setToolTipText("Mark End of Annotation (ctrl-o)"); 66 79 this.add(jb); … … 76 89 this.add(jb); 77 90 91 92 timeField = new JTextField(String.format(TIME_CODE_FORMAT, 0, 0, 0, 0), 8); 93 durationLabel = new JLabel(String.format(TIME_CODE_LABEL_FORMAT, 0, 0, 0)); 94 this.add(timeField); 95 this.add(durationLabel); 96 this.myPlayerPanel = p; 97 timeField.addKeyListener(p); 98 timeField.addFocusListener(this); 99 78 100 } 79 101 102 public void setDuration(long duration) { 103 durationLabel.setText(String.format(TIME_CODE_LABEL_FORMAT, 104 (duration/1000/60/60), 105 ((duration%(1000*60*60))/1000/60), 106 ((duration%(1000*60))/1000))); 107 } 108 109 public void focusGained(FocusEvent e) { 110 timecodeHasFocus = true; 111 innerTime = timeField.getText(); 112 if(myPlayerPanel.getCurrentMovie() != null) { 113 myPlayerPanel.getCurrentMovie().stop(); 114 } 115 } 116 117 public void focusLost(FocusEvent e) { 118 if(myPlayerPanel.getCurrentMovie() != null) { 119 if(timeField.getText().matches("^(\\d{2}):(\\d{2}):(\\d{2}).(\\d{2})$")) { 120 try { 121 long time = Long.parseLong(timeField.getText().replaceAll("^(\\d{2}):(\\d{2}):(\\d{2}).(\\d{2})$", "$1"))*1000*60*60 + 122 Long.parseLong(timeField.getText().replaceAll("^(\\d{2}):(\\d{2}):(\\d{2}).(\\d{2})$", "$2"))*1000*60 + 123 Long.parseLong(timeField.getText().replaceAll("^(\\d{2}):(\\d{2}):(\\d{2}).(\\d{2})$", "$3"))*1000 + 124 Long.parseLong(timeField.getText().replaceAll("^(\\d{2}):(\\d{2}):(\\d{2}).(\\d{2})$", "$4"))*33; 125 myPlayerPanel.getCurrentMovie().setTime(time); 126 } catch (NumberFormatException e1) { 127 JOptionPane.showMessageDialog(myPlayerPanel, "There was a problem processing your timecode"); 128 timeField.setText(innerTime); 129 } 130 } else { 131 JOptionPane.showMessageDialog(myPlayerPanel, "Timecodes must match the format hh:mm:ss.ff"); 132 timeField.setText(innerTime); 133 } 134 } 135 timecodeHasFocus = false; 136 } 137 138 public void updateTime() { 139 if(!timecodeHasFocus) 140 timeField.setText(String.format(TIME_CODE_FORMAT, 141 (myPlayerPanel.getCurrentMovie().getTime()/1000/60/60), 142 ((myPlayerPanel.getCurrentMovie().getTime()%(1000*60*60))/1000/60), 143 ((myPlayerPanel.getCurrentMovie().getTime()%(1000*60))/1000), 144 (int)((myPlayerPanel.getCurrentMovie().getTime()%1000)/33.3))); 145 146 } 147 80 148 public class addAnnotationEventListener implements ActionListener { 81 149 protected PlayerPanel myPanel; … … 103 171 } 104 172 105 public class markInEventHandler extends ToolButtonPanel.vertovEventListener {173 public class markInEventHandler extends UtilityPanel.vertovEventListener { 106 174 107 175 public markInEventHandler(PlayerPanel myPanel) { … … 115 183 } 116 184 117 public class markOutEventHandler extends ToolButtonPanel.vertovEventListener {185 public class markOutEventHandler extends UtilityPanel.vertovEventListener { 118 186 119 187 public markOutEventHandler(PlayerPanel myPanel) {
