Changeset 173
- Timestamp:
- 03/08/08 11:34:57 (9 months ago)
- Files:
-
- MediAnnotate/trunk/src/org/mediannotate/app/MAController.java (modified) (6 diffs)
- MediAnnotate/trunk/src/org/mediannotate/app/PlayerPanel.java (modified) (10 diffs)
- MediAnnotate/trunk/src/org/mediannotate/app/WindowGUI.java (modified) (2 diffs)
- MediAnnotate/trunk/src/org/mediannotate/ui/TimeCodePanel.java (added)
- MediAnnotate/trunk/src/org/mediannotate/ui/ToolButtonPanel.java (modified) (3 diffs)
- MediAnnotate/trunk/src/org/mediannotate/ui/play.png (added)
- MediAnnotate/trunk/src/org/mediannotate/ui/stop.png (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
MediAnnotate/trunk/src/org/mediannotate/app/MAController.java
r149 r173 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;7 5 import java.io.File; 8 6 import java.io.IOException; … … 16 14 import org.mediannotate.dom.Movie; 17 15 import org.mediannotate.dom.MovieFactory; 18 import org.mediannotate.ui.listener.PlayButtonListener;19 import org.mediannotate.ui.listener.StopButtonListener;20 import org.mediannotate.ui.listener.TimeLineListener;21 16 22 17 23 public class MAController implements ActionListener, Runnable , FocusListener{18 public class MAController implements ActionListener, Runnable{ 24 19 private PlayerPanel myPlayerPanel = null; 25 20 … … 29 24 public boolean isApplet = false; 30 25 31 PlayButtonListener playListener; 32 StopButtonListener stopListener; 33 TimeLineListener timeLineListener; 26 27 34 28 35 29 public MAController(PlayerPanel pp, boolean is_applet) { … … 37 31 isApplet = is_applet; 38 32 myPlayerPanel = pp; 39 40 timeLineListener = new TimeLineListener();41 playListener = new PlayButtonListener();42 stopListener = new StopButtonListener();43 myPlayerPanel.setButtonListener(playListener, stopListener);44 myPlayerPanel.setTimeCodeChangeListener(this, timeLineListener);45 33 new Thread(this).start(); 46 34 } … … 99 87 } 100 88 101 102 stopListener.setMovie(myPlayerPanel.getCurrentMovie());103 playListener.setMovie(myPlayerPanel.getCurrentMovie());104 timeLineListener.setMovie(myPlayerPanel.getCurrentMovie());105 106 89 myPlayerPanel.getCurrentMovie().start(); 107 90 … … 135 118 } 136 119 137 public void focusGained(FocusEvent e) {138 if(myPlayerPanel.getCurrentMovie() != null) {139 myPlayerPanel.getCurrentMovie().stop();140 }141 }142 143 public void focusLost(FocusEvent e) {144 synchronized (mutex) {145 146 if(myPlayerPanel != null && myPlayerPanel.getCurrentMovie() != null) {147 myPlayerPanel.getCurrentMovie().setTime(myPlayerPanel.getTime());148 myPlayerPanel.getCurrentMovie().start();149 }150 }151 }152 153 public TimeLineListener getTimeLineListener() {154 return timeLineListener;155 }156 157 public void setTimeLineListener(TimeLineListener timeLineListener) {158 this.timeLineListener = timeLineListener;159 }160 161 120 public boolean isRunning() { 162 121 return Running; MediAnnotate/trunk/src/org/mediannotate/app/PlayerPanel.java
r171 r173 4 4 import java.awt.Component; 5 5 import java.awt.Dimension; 6 import java.awt.FlowLayout;7 6 import java.awt.GridLayout; 8 7 import java.awt.event.ActionEvent; 9 8 import java.awt.event.ComponentEvent; 10 9 import java.awt.event.ComponentListener; 11 import java.awt.event.FocusListener;12 10 import java.awt.event.KeyEvent; 13 11 import java.awt.event.KeyListener; 12 import java.awt.event.MouseEvent; 13 import java.awt.event.MouseListener; 14 14 15 15 import javax.swing.JButton; 16 import javax.swing.JLabel;17 16 import javax.swing.JPanel; 18 import javax.swing.JTextField;19 17 20 18 import org.mediannotate.dom.IMovieObserver; 21 19 import org.mediannotate.dom.Movie; 20 import org.mediannotate.ui.TimeCodePanel; 22 21 import org.mediannotate.ui.TimeLinePanel; 23 22 import org.mediannotate.ui.ToolButtonPanel; … … 29 28 import quicktime.QTException; 30 29 31 public class PlayerPanel extends JPanel implements IMovieObserver, KeyListener, ComponentListener {30 public class PlayerPanel extends JPanel implements IMovieObserver, KeyListener, ComponentListener, MouseListener{ 32 31 /** 33 32 * … … 35 34 private static final long serialVersionUID = 1L; 36 35 37 private JLabel duration = null;38 //39 // We must disable anything that isn't numeric here.40 //41 private JTextField minute = null;42 private JTextField second = null;43 private JTextField frameslice = null;44 45 36 private Time durationTime; 46 37 private TimeLinePanel timeLinePanel = new TimeLinePanel(); 47 private ToolButtonPanel toolButtonPanel = new ToolButtonPanel(this);48 38 private ToolButtonPanel toolButtonPanel; 39 private TimeCodePanel timeCodePanel; 49 40 private Component currentMovieComponent; 50 41 private JPanel moviePanel = new JPanel(); 51 42 Movie currentMovie; 52 43 44 45 PlayButtonListener playListener; 46 StopButtonListener stopListener; 47 TimeLineListener timeLineListener; 48 49 public PlayButtonListener getPlayListener() { 50 return playListener; 51 } 52 53 public StopButtonListener getStopListener() { 54 return stopListener; 55 } 56 53 57 public Time getDurationTime() { 54 58 return durationTime; … … 63 67 } 64 68 65 public void setTimeCodeChangeListener(FocusListener controller, TimeLineListener time_line_listener) {66 67 JPanel jp_outter = new JPanel();68 jp_outter.setLayout(new GridLayout(3, 1));69 jp_outter.add(toolButtonPanel, 0);70 71 jp_outter.add(timeLinePanel, 1);72 timeLinePanel.addMouseMotionListener(time_line_listener);73 timeLinePanel.addMouseListener(time_line_listener);74 75 /**76 * I see a circular dependancy? no, the above are other interfaces.77 */78 time_line_listener.setTimeLinePanel(timeLinePanel);79 80 JPanel jp = new JPanel();81 jp_outter.add(jp, 2);82 minute = new JTextField("0", 2);83 second = new JTextField("0", 2);84 frameslice = new JTextField("0", 2);85 86 Time t = new Time(0);87 duration = new JLabel(t.getHours() + "h " + t.getMinutes() + "m " +88 t.getSeconds() + "s");89 jp.setLayout(new FlowLayout());90 jp.add(minute);91 jp.add(new JLabel(":"));92 jp.add(second);93 jp.add(new JLabel(":"));94 jp.add(frameslice);95 jp.add(new JLabel(" of "));96 jp.add(duration);97 98 add(jp_outter, BorderLayout.NORTH);99 100 minute.addFocusListener(controller);101 second.addFocusListener(controller);102 frameslice.addFocusListener(controller);103 minute.addKeyListener(this);104 second.addKeyListener(this);105 frameslice.addKeyListener(this);106 107 moviePanel.setLayout(null);108 add(moviePanel);109 validate();110 111 112 addComponentListener(this);113 }114 115 69 public void setTime(long time) { 116 Time t = new Time(time); 117 minute.setText(t.getMinutes() + ""); 118 second.setText(t.getSeconds() + ""); 119 frameslice.setText((int)(t.getMillisecond()/33.3) + ""); 70 timeCodePanel.updateTime(); 120 71 timeLinePanel.setLocation(time/(float)durationTime.getAllInMilli()); 121 //validate();122 72 } 123 73 … … 127 77 */ 128 78 public long getTime() { 129 return (long) (Integer.parseInt(minute.getText()) * 60000 + 130 Integer.parseInt(second.getText()) * 1000 + 131 (Integer.parseInt(frameslice.getText()) * 33.3)); 79 return currentMovie.getTime(); 132 80 } 133 81 … … 153 101 currentMovie = m; 154 102 if(currentMovie != null) { 155 currentMovie.addMovieObserver(this); 156 currentMovieComponent = m.getComponent(); 157 oldMovieComponent = currentMovieComponent; 158 Dimension newD = getAspectRespectingDimension(moviePanel.getSize(), currentMovieComponent.getPreferredSize()); 159 currentMovieComponent.setBounds((moviePanel.getWidth()-newD.width)/2 , (moviePanel.getHeight()-newD.height)/2, newD.width, newD.height); 160 161 moviePanel.add(currentMovieComponent); 162 currentMovieComponent.setVisible(true); 163 moviePanel.repaint(); 164 durationTime = new Time(currentMovie.getDuration()); 165 duration.setText(durationTime.getHours() + "h " + durationTime.getMinutes() + "m " + 166 durationTime.getSeconds() + "s"); 103 currentMovie.addMovieObserver(this); 104 currentMovieComponent = m.getComponent(); 105 oldMovieComponent = currentMovieComponent; 106 Dimension newD = getAspectRespectingDimension(moviePanel.getSize(), currentMovieComponent.getPreferredSize()); 107 currentMovieComponent.setBounds((moviePanel.getWidth()-newD.width)/2 , (moviePanel.getHeight()-newD.height)/2, newD.width, newD.height); 108 109 moviePanel.add(currentMovieComponent); 110 currentMovieComponent.setVisible(true); 111 moviePanel.repaint(); 112 durationTime = new Time(currentMovie.getDuration()); 113 timeCodePanel.setDuration(currentMovie.getDuration()); 114 115 stopListener.setMovie(currentMovie); 116 playListener.setMovie(currentMovie); 117 timeLineListener.setMovie(currentMovie); 167 118 } 168 119 … … 173 124 public PlayerPanel() { 174 125 super(new BorderLayout()); 175 176 } 177 public void setButtonListener(PlayButtonListener p, StopButtonListener s) { 126 timeLineListener = new TimeLineListener(); 127 playListener = new PlayButtonListener(); 128 stopListener = new StopButtonListener(); 129 130 toolButtonPanel = new ToolButtonPanel(this); 131 132 JPanel jp_outter = new JPanel(); 133 jp_outter.setLayout(new GridLayout(3, 1)); 134 jp_outter.add(toolButtonPanel, 0); 135 136 jp_outter.add(timeLinePanel, 1); 137 timeLinePanel.addMouseMotionListener(timeLineListener); 138 timeLinePanel.addMouseListener(timeLineListener); 139 140 /** 141 * I see a circular dependancy? no, the above are other interfaces. 142 */ 143 timeLineListener.setTimeLinePanel(timeLinePanel); 144 145 timeCodePanel = new TimeCodePanel(this); 146 jp_outter.add(timeCodePanel, 2); 147 148 149 150 add(jp_outter, BorderLayout.NORTH); 151 152 153 154 moviePanel.setLayout(null); 155 add(moviePanel); 156 157 addMouseListener(this); 158 addComponentListener(this); 159 addKeyListener(this); 160 178 161 JPanel jp = new JPanel(); 179 162 JButton play = new JButton("Play"); 180 163 JButton stop = new JButton("Stop"); 181 164 182 play.addActionListener(p); 183 stop.addActionListener(s); 184 play.addKeyListener(this); 185 stop.addKeyListener(this); 165 play.addActionListener(playListener); 166 stop.addActionListener(stopListener); 167 186 168 jp.add(play); 187 169 jp.add(stop); 188 170 189 171 add(jp, BorderLayout.SOUTH); 190 validate(); 191 } 172 validate(); 173 174 } 175 192 176 193 177 public void notifyOfMovieChange() { … … 221 205 } 222 206 223 public void keyPressed(KeyEvent e) { 224 // TODO Auto-generated method stub 225 207 public TimeLineListener getTimeLineListener() { 208 return timeLineListener; 226 209 } 227 210 … … 245 228 } 246 229 247 public void keyTyped(KeyEvent e) { 248 // TODO Auto-generated method stub 249 250 } 251 252 public void componentHidden(ComponentEvent e) { 253 // TODO Auto-generated method stub 254 255 } 256 257 public void componentMoved(ComponentEvent e) { 258 // TODO Auto-generated method stub 259 260 } 230 261 231 262 232 public void componentResized(ComponentEvent e) { … … 277 247 278 248 } 279 280 public void componentShown(ComponentEvent e) { 281 // TODO Auto-generated method stub 282 283 } 249 250 public void mouseClicked(MouseEvent e) { 251 if(!e.getComponent().equals(timeCodePanel)) { 252 this.requestFocusInWindow(); 253 } 254 255 } 256 257 public void keyPressed(KeyEvent e) { } 258 public void keyTyped(KeyEvent e) { } 259 public void componentHidden(ComponentEvent e) { } 260 public void componentMoved(ComponentEvent e) { } 261 public void componentShown(ComponentEvent e) { } 262 public void mouseEntered(MouseEvent e) {} 263 public void mouseExited(MouseEvent e) {} 264 public void mousePressed(MouseEvent e) {} 265 public void mouseReleased(MouseEvent e) {} 266 267 268 269 270 284 271 } MediAnnotate/trunk/src/org/mediannotate/app/WindowGUI.java
r116 r173 74 74 myPlayerPanel = pp; 75 75 76 setMenuListener(myController, my Controller.getTimeLineListener());76 setMenuListener(myController, myPlayerPanel.getTimeLineListener()); 77 77 78 78 addWindowListener(this); … … 98 98 } 99 99 } 100 if(!myController.isApplet) System.exit( 0 ); 100 101 } 101 102 MediAnnotate/trunk/src/org/mediannotate/ui/ToolButtonPanel.java
r171 r173 31 31 BufferedImage inImage = null; 32 32 BufferedImage outImage = null; 33 BufferedImage playImage = null; 34 BufferedImage stopImage = null; 33 35 ToolTipManager.sharedInstance().setInitialDelay(200); 34 36 ToolTipManager.sharedInstance().setReshowDelay(200); … … 40 42 is = getClass().getResourceAsStream("markOut.png"); 41 43 outImage = ImageIO.read(is); 44 is = getClass().getResourceAsStream("play.png"); 45 playImage = ImageIO.read(is); 46 is = getClass().getResourceAsStream("stop.png"); 47 stopImage = ImageIO.read(is); 42 48 is.close(); 43 49 } catch (IOException e) { … … 58 64 jb.addActionListener(new ToolButtonPanel.markOutEventHandler(p)); 59 65 jb.setToolTipText("Mark End of Annotation (ctrl-o)"); 66 this.add(jb); 67 68 jb = new JButton(new ImageIcon(playImage)); 69 jb.addActionListener(p.getPlayListener()); 70 jb.setToolTipText("Play Movie"); 71 this.add(jb); 72 73 jb = new JButton(new ImageIcon(stopImage)); 74 jb.addActionListener(p.getStopListener()); 75 jb.setToolTipText("Stop Movie"); 60 76 this.add(jb); 61 77
