Changeset 173

Show
Ignore:
Timestamp:
03/08/08 11:34:57 (9 months ago)
Author:
Stuart Thiel
Message:

-Fixed #21 #19 #85 #25
--These were all related to issues with the timecode usage in the java part.

-Fixed #148
--This is the start and stop buttons in the toolbar.
--incidental addition... shoulda waited till after the other tickets were closed to add it, but oh well

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • MediAnnotate/trunk/src/org/mediannotate/app/MAController.java

    r149 r173  
    33import java.awt.event.ActionEvent; 
    44import java.awt.event.ActionListener; 
    5 import java.awt.event.FocusEvent; 
    6 import java.awt.event.FocusListener; 
    75import java.io.File; 
    86import java.io.IOException; 
     
    1614import org.mediannotate.dom.Movie; 
    1715import 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; 
    2116 
    2217 
    23 public class MAController implements ActionListener, Runnable, FocusListener
     18public class MAController implements ActionListener, Runnable
    2419        private PlayerPanel myPlayerPanel = null; 
    2520         
     
    2924        public boolean isApplet = false; 
    3025         
    31         PlayButtonListener playListener; 
    32         StopButtonListener stopListener; 
    33         TimeLineListener timeLineListener; 
     26 
     27         
    3428         
    3529        public MAController(PlayerPanel pp, boolean is_applet) { 
     
    3731                isApplet = is_applet; 
    3832                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); 
    4533                new Thread(this).start(); 
    4634        } 
     
    9987                        } 
    10088                         
    101                          
    102                         stopListener.setMovie(myPlayerPanel.getCurrentMovie()); 
    103                         playListener.setMovie(myPlayerPanel.getCurrentMovie()); 
    104                         timeLineListener.setMovie(myPlayerPanel.getCurrentMovie()); 
    105                          
    10689                        myPlayerPanel.getCurrentMovie().start(); 
    10790         
     
    135118        } 
    136119 
    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  
    161120        public boolean isRunning() { 
    162121                return Running; 
  • MediAnnotate/trunk/src/org/mediannotate/app/PlayerPanel.java

    r171 r173  
    44import java.awt.Component; 
    55import java.awt.Dimension; 
    6 import java.awt.FlowLayout; 
    76import java.awt.GridLayout; 
    87import java.awt.event.ActionEvent; 
    98import java.awt.event.ComponentEvent; 
    109import java.awt.event.ComponentListener; 
    11 import java.awt.event.FocusListener; 
    1210import java.awt.event.KeyEvent; 
    1311import java.awt.event.KeyListener; 
     12import java.awt.event.MouseEvent; 
     13import java.awt.event.MouseListener; 
    1414 
    1515import javax.swing.JButton; 
    16 import javax.swing.JLabel; 
    1716import javax.swing.JPanel; 
    18 import javax.swing.JTextField; 
    1917 
    2018import org.mediannotate.dom.IMovieObserver; 
    2119import org.mediannotate.dom.Movie; 
     20import org.mediannotate.ui.TimeCodePanel; 
    2221import org.mediannotate.ui.TimeLinePanel; 
    2322import org.mediannotate.ui.ToolButtonPanel; 
     
    2928import quicktime.QTException; 
    3029 
    31 public class PlayerPanel extends JPanel implements IMovieObserver, KeyListener, ComponentListener
     30public class PlayerPanel extends JPanel implements IMovieObserver, KeyListener, ComponentListener, MouseListener
    3231        /** 
    3332         *  
     
    3534        private static final long serialVersionUID = 1L; 
    3635         
    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          
    4536        private Time durationTime; 
    4637        private TimeLinePanel timeLinePanel = new TimeLinePanel(); 
    47         private ToolButtonPanel toolButtonPanel = new ToolButtonPanel(this)
    48          
     38        private ToolButtonPanel toolButtonPanel
     39        private TimeCodePanel timeCodePanel; 
    4940        private Component currentMovieComponent; 
    5041        private JPanel moviePanel = new JPanel(); 
    5142        Movie currentMovie; 
    5243 
     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 
    5357        public Time getDurationTime() { 
    5458                return durationTime; 
     
    6367        } 
    6468         
    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          
    11569        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(); 
    12071                timeLinePanel.setLocation(time/(float)durationTime.getAllInMilli()); 
    121                 //validate(); 
    12272        } 
    12373         
     
    12777         */ 
    12878        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(); 
    13280        } 
    13381 
     
    153101                currentMovie = m; 
    154102                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); 
    167118                } 
    168119                 
     
    173124        public PlayerPanel() { 
    174125                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                 
    178161                JPanel jp = new JPanel(); 
    179162                JButton play = new JButton("Play"); 
    180163                JButton stop = new JButton("Stop"); 
    181164                 
    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 
    186168                jp.add(play); 
    187169                jp.add(stop); 
    188170 
    189171                add(jp, BorderLayout.SOUTH); 
    190                 validate(); 
    191         } 
     172                validate();              
     173                 
     174        } 
     175 
    192176         
    193177        public void notifyOfMovieChange() { 
     
    221205        } 
    222206         
    223         public void keyPressed(KeyEvent e) { 
    224                 // TODO Auto-generated method stub 
    225                  
     207        public TimeLineListener getTimeLineListener() { 
     208                return timeLineListener; 
    226209        } 
    227210 
     
    245228        } 
    246229 
    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 
    261231 
    262232        public void componentResized(ComponentEvent e) { 
     
    277247                 
    278248        } 
    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 
    284271} 
  • MediAnnotate/trunk/src/org/mediannotate/app/WindowGUI.java

    r116 r173  
    7474                myPlayerPanel = pp; 
    7575                 
    76                 setMenuListener(myController, myController.getTimeLineListener()); 
     76                setMenuListener(myController, myPlayerPanel.getTimeLineListener()); 
    7777 
    7878                addWindowListener(this); 
     
    9898                        } 
    9999                } 
     100                if(!myController.isApplet) System.exit( 0 ); 
    100101        } 
    101102         
  • MediAnnotate/trunk/src/org/mediannotate/ui/ToolButtonPanel.java

    r171 r173  
    3131                BufferedImage inImage = null; 
    3232                BufferedImage outImage = null; 
     33                BufferedImage playImage = null; 
     34                BufferedImage stopImage = null; 
    3335                ToolTipManager.sharedInstance().setInitialDelay(200); 
    3436                ToolTipManager.sharedInstance().setReshowDelay(200); 
     
    4042                        is = getClass().getResourceAsStream("markOut.png"); 
    4143                        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); 
    4248                        is.close(); 
    4349                } catch (IOException e) { 
     
    5864                jb.addActionListener(new ToolButtonPanel.markOutEventHandler(p)); 
    5965                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"); 
    6076                this.add(jb); 
    6177