3939import javax .swing .event .ListSelectionEvent ;
4040import javax .swing .event .ListSelectionListener ;
4141
42-
43- import net .imglib2 .type .NativeType ;
44- import net .imglib2 .type .numeric .RealType ;
45-
4642import bigtrace .BigTrace ;
4743import bigtrace .gui .NumberField ;
4844import bigtrace .gui .PanelTitle ;
5450import ij .io .OpenDialog ;
5551import ij .io .SaveDialog ;
5652
57- public class AnimationPanel < T extends RealType < T > & NativeType < T > > extends JPanel implements ListSelectionListener , NumberField .Listener , ChangeListener , ActionListener
53+ public class AnimationPanel extends JPanel implements ListSelectionListener , NumberField .Listener , ChangeListener , ActionListener
5854{
59- final BigTrace <T > bt ;
55+ final BigTrace <? > bt ;
6056
6157 final JButton butRecord ;
6258 final JButton butPlayStop ;
@@ -82,7 +78,7 @@ public class AnimationPanel < T extends RealType< T > & NativeType< T > > extend
8278
8379 final public NumberField nfTotalTime ;
8480
85- public static final int ANIMTIME_START = 0 , ANIMTIME_END = 1 , ANIMTIME_STRETCH = 2 ;
81+ public static final int ANIMTIME_START = 0 , ANIMTIME_END = 1 , ANIMTIME_STRETCH = 2 ;
8682
8783 int nChangeTotalTimeMode = (int )Prefs .get ("BigTrace.nChangeTotalTimeMode" , ANIMTIME_END );
8884
@@ -94,22 +90,20 @@ public class AnimationPanel < T extends RealType< T > & NativeType< T > > extend
9490 int tsSpan = 100 ;
9591
9692 /** play preview **/
97- AnimationPlayer < T > player ;
93+ final AnimationPlayer player ;
9894
9995 ImageIcon tabIconRecord ;
10096
10197 ImageIcon tabIconPlay ;
10298
10399 ImageIcon tabIconStop ;
104100
105- float fPlaySpeedFactor = 1.0f ;
106-
107101 boolean bPlayerBackForth = Prefs .get ("BigTrace.bPlayerBackForth" , false );
108102
109103 boolean bUpdateSlider = true ;
110104
111105 /** keyframe render **/
112- AnimationRender < T > render ;
106+ AnimationRender render ;
113107
114108 int nRenderFPS = (int )Prefs .get ("BigTrace.nRenderFPS" , 24.0 );
115109
@@ -125,13 +119,13 @@ public class AnimationPanel < T extends RealType< T > & NativeType< T > > extend
125119
126120 String sRenderSavePath = null ;
127121
128- final AnimationPanelDialogs < T > dialogsAnim ;
122+ final AnimationPanelDialogs dialogsAnim ;
129123
130- public AnimationPanel (final BigTrace <T > bt )
124+ public AnimationPanel (final BigTrace <? > bt )
131125 {
132126 this .bt = bt ;
133127
134- dialogsAnim = new AnimationPanelDialogs <> (bt , this );
128+ dialogsAnim = new AnimationPanelDialogs (bt , this );
135129
136130 int nInitialTotalTime = 5 ;
137131
@@ -140,7 +134,7 @@ public AnimationPanel(final BigTrace<T> bt)
140134
141135 kfAnim = new KeyFrameAnimation (listModel );
142136 kfAnim .setTotalTime ( nInitialTotalTime );
143- this .player = null ;
137+ this .player = new AnimationPlayer ( bt , this ) ;
144138
145139 JPanel panAnimTools = new JPanel (new GridBagLayout ());
146140 panAnimTools .setBorder (new PanelTitle (" Animation " ));
@@ -423,7 +417,7 @@ void sortListModel()
423417
424418 void runRender ()
425419 {
426- render = new AnimationRender < > (bt , this );
420+ render = new AnimationRender (bt , this );
427421 bt .bInputLock = true ;
428422 bt .setLockMode (true );
429423 render .addPropertyChangeListener ( bt .btPanel );
@@ -436,21 +430,6 @@ void runRender()
436430 render .execute ();
437431 }
438432
439- void runPlayer ()
440- {
441- player = new AnimationPlayer < >(bt , this );
442- bt .bInputLock = true ;
443- bt .setLockMode (true );
444- player .addPropertyChangeListener ( bt .btPanel );
445-
446- butPlayStop .setEnabled ( true );
447- butPlayStop .setIcon ( tabIconStop );
448- butPlayStop .setToolTipText ( "Stop playing" );
449- player .butPlayStop = butPlayStop ;
450- player .tabIconPlay = tabIconPlay ;
451- player .execute ();
452- }
453-
454433 @ Override
455434 public void actionPerformed ( ActionEvent e )
456435 {
@@ -460,7 +439,7 @@ public void actionPerformed( ActionEvent e )
460439 {
461440 if (listModel .size () > 0 )
462441 {
463- if (!bt .bInputLock )
442+ if (!bt .bInputLock )
464443 {
465444 if (dialogsAnim .dialRenderSettings ())
466445 {
@@ -488,18 +467,12 @@ public void actionPerformed( ActionEvent e )
488467 {
489468 if (!bt .bInputLock )
490469 {
491- runPlayer ();
470+ if (!player .isPlaying ())
471+ player .play ();
492472 }
493473 else
494474 {
495- if ( bt .bInputLock &&
496- butPlayStop .isEnabled () &&
497- player !=null &&
498- !player .isCancelled () &&
499- !player .isDone ())
500- {
501- player .cancel ( false );
502- }
475+ player .stop ();
503476 }
504477 }
505478 else
@@ -866,11 +839,10 @@ protected void paintComponent(Graphics g)
866839 }
867840 }
868841
869- public void updateScene ()
842+ public void updateScene (final float fTimePoint )
870843 {
871844 if (listModel .size () > 1 )
872845 {
873- float fTimePoint = (kfAnim .getTotalTime ())*(timeSlider .getValue ()/(float )tsSpan );
874846 bt .setScene ( kfAnim .getScene ( fTimePoint ) );
875847 }
876848 }
@@ -883,7 +855,8 @@ public void stateChanged( ChangeEvent e )
883855 {
884856 if (bUpdateSlider )
885857 {
886- updateScene ();
858+ float fTimePoint = (kfAnim .getTotalTime ())*(timeSlider .getValue ()/(float )tsSpan );
859+ updateScene (fTimePoint );
887860 }
888861 }
889862
@@ -904,7 +877,7 @@ void dialStorylineSave()
904877
905878 bt .setLockMode (true );
906879 bt .bInputLock = true ;
907- StorylineSave < T > stSave = new StorylineSave <> (bt , this );
880+ StorylineSave stSave = new StorylineSave (bt , this );
908881 stSave .saveAnimation ( filename );
909882 bt .setLockMode (false );
910883 bt .bInputLock = false ;
@@ -926,7 +899,7 @@ void dialStorylineLoad()
926899 filename = path + openDial .getFileName ();
927900 bt .setLockMode (true );
928901 bt .bInputLock = true ;
929- StorylineLoad < T > stLoad = new StorylineLoad <> (bt , this );
902+ StorylineLoad stLoad = new StorylineLoad (bt , this );
930903 stLoad .loadAnimation ( filename );
931904 bt .setLockMode (false );
932905 bt .bInputLock = false ;
0 commit comments