~ubuntu-branches/debian/sid/geogebra/sid

« back to all changes in this revision

Viewing changes to geogebra/gui/view/consprotocol/ConstructionProtocolNavigation.java

  • Committer: Package Import Robot
  • Author(s): Giovanni Mascellani
  • Date: 2012-01-10 11:37:41 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120110113741-satwohsd4de4ite1
Tags: 4.0.19.0+dfsg1-1
* New upstream version (closes: #649893).
* Update dependency: icedtea-plugin -> icedtea-netx-common (LP: #893007).
* New thumbnailer configuration compatible with Gnome 3.
* Package building is now managed by javahelper instead of upstream
  build.xml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
GeoGebra - Dynamic Mathematics for Everyone
3
 
http://www.geogebra.org
4
 
 
5
 
This file is part of GeoGebra.
6
 
 
7
 
This program is free software; you can redistribute it and/or modify it 
8
 
under the terms of the GNU General Public License as published by 
9
 
the Free Software Foundation.
10
 
 
11
 
*/
12
 
package geogebra.gui.view.consprotocol;
13
 
 
14
 
import geogebra.main.Application;
15
 
 
16
 
import java.awt.Component;
17
 
import java.awt.Cursor;
18
 
import java.awt.Dimension;
19
 
import java.awt.FlowLayout;
20
 
import java.awt.event.ActionEvent;
21
 
import java.awt.event.ActionListener;
22
 
import java.text.DecimalFormat;
23
 
import java.text.DecimalFormatSymbols;
24
 
import java.util.Locale;
25
 
 
26
 
import javax.swing.Box;
27
 
import javax.swing.BoxLayout;
28
 
import javax.swing.ImageIcon;
29
 
import javax.swing.JButton;
30
 
import javax.swing.JLabel;
31
 
import javax.swing.JPanel;
32
 
import javax.swing.JSpinner;
33
 
import javax.swing.JSpinner.NumberEditor;
34
 
import javax.swing.SpinnerModel;
35
 
import javax.swing.SpinnerNumberModel;
36
 
import javax.swing.Timer;
37
 
import javax.swing.event.ChangeEvent;
38
 
import javax.swing.event.ChangeListener;
39
 
 
40
 
/**
41
 
 * Navigation buttons for the construction protocol
42
 
 */
43
 
public class ConstructionProtocolNavigation extends JPanel implements ActionListener {
44
 
 
45
 
        /**
46
 
         * 
47
 
         */
48
 
        private static final long serialVersionUID = 1L;
49
 
        private JButton btFirst, btPrev, btPlay, btNext, btLast, btOpenWindow;
50
 
        private JLabel lbSteps;
51
 
        private JSpinner spDelay;
52
 
        private double playDelay = 2; // in seconds      
53
 
        private JPanel playPanel;
54
 
        
55
 
        private Application app;
56
 
        private ConstructionProtocol prot;
57
 
        private boolean showPlayButton = true, 
58
 
                                        showConsProtButton = true;
59
 
        
60
 
        private AutomaticPlayer player;
61
 
        private boolean isPlaying;
62
 
        
63
 
        /**
64
 
         * Creates a new navigation bar to step through the construction protocol.
65
 
         * @param internalNavigation: true if navigation bar is part of the protocol window
66
 
         */
67
 
        public ConstructionProtocolNavigation(ConstructionProtocol prot) {              
68
 
                this.prot = prot;                       
69
 
                app = prot.getApplication();    
70
 
                                
71
 
                SpinnerModel model =
72
 
                new SpinnerNumberModel(2, //initial value
73
 
                                       0.25, //min
74
 
                                       10, //max
75
 
                                       0.25); //step
76
 
                spDelay = new JSpinner(model);  
77
 
                NumberEditor numEdit = new JSpinner.NumberEditor(spDelay, "#.##");
78
 
                DecimalFormat format = numEdit.getFormat();
79
 
                format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
80
 
                spDelay.setEditor(numEdit);
81
 
                
82
 
                lbSteps = new JLabel();
83
 
                
84
 
                initGUI();                      
85
 
        }
86
 
                
87
 
        public boolean isPlayButtonVisible() {
88
 
                return showPlayButton;
89
 
        }
90
 
        
91
 
        public void setPlayButtonVisible(boolean flag) {
92
 
                showPlayButton = flag;  
93
 
                playPanel.setVisible(flag);
94
 
        }
95
 
        
96
 
        public boolean isConsProtButtonVisible() {
97
 
                return showConsProtButton;
98
 
        }       
99
 
        
100
 
        public void setConsProtButtonVisible(boolean flag) {            
101
 
                showConsProtButton = flag;      
102
 
                btOpenWindow.setVisible(flag);
103
 
        }
104
 
        
105
 
        /**
106
 
         * Returns delay between frames of automatic construction protocol
107
 
         * playing in seconds.
108
 
         * @return
109
 
         */
110
 
        public double getPlayDelay() {
111
 
                return playDelay;
112
 
        }
113
 
        
114
 
        public void setPlayDelay(double delay) {
115
 
                playDelay = delay;
116
 
                
117
 
                try {
118
 
                        spDelay.setValue(new Double(playDelay));
119
 
                } catch (Exception e) {
120
 
                        spDelay.setValue(new Integer((int) Math.round(playDelay)));
121
 
                        
122
 
                }
123
 
        }       
124
 
        
125
 
        public void initGUI() {
126
 
                removeAll();    
127
 
                                        
128
 
                btFirst = new JButton(app.getImageIcon("nav_skipback.png"));
129
 
                btLast = new JButton(app.getImageIcon("nav_skipforward.png"));          
130
 
                btPrev = new JButton(app.getImageIcon("nav_rewind.png"));               
131
 
                btNext = new JButton(app.getImageIcon("nav_fastforward.png"));                          
132
 
                                
133
 
                btFirst.addActionListener(this);
134
 
                btLast.addActionListener(this);         
135
 
                btPrev.addActionListener(this); 
136
 
                btNext.addActionListener(this);                         
137
 
                
138
 
                JPanel leftPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));       
139
 
                leftPanel.add(btFirst);
140
 
                leftPanel.add(btPrev);
141
 
                leftPanel.add(lbSteps);                 
142
 
                leftPanel.add(btNext);
143
 
                leftPanel.add(btLast);
144
 
                
145
 
                playPanel = new JPanel();
146
 
                playPanel.setVisible(showPlayButton);
147
 
                playPanel.add(Box.createRigidArea(new Dimension(20,10)));
148
 
                btPlay = new JButton();
149
 
                btPlay.setIcon(new ImageIcon(app.getPlayImage()));
150
 
                btPlay.addActionListener(this);         
151
 
                                                                                        
152
 
                spDelay.addChangeListener(new ChangeListener() {
153
 
                        public void stateChanged(ChangeEvent e) {
154
 
                                try {
155
 
                                        playDelay = Double.parseDouble(spDelay.getValue().toString());
156
 
                                } catch (Exception ex) {
157
 
                                        playDelay = 2;
158
 
                                }
159
 
                        }                       
160
 
                });
161
 
                                        
162
 
                playPanel.add(btPlay);
163
 
                playPanel.add(spDelay); 
164
 
                playPanel.add(new JLabel("s"));         
165
 
                
166
 
                                
167
 
                btOpenWindow = new JButton();
168
 
                btOpenWindow.setIcon(app.getImageIcon("table.gif"));                    
169
 
                btOpenWindow.addActionListener(new ActionListener() {
170
 
                        public void actionPerformed(ActionEvent e) {
171
 
                                app.getGuiManager().showConstructionProtocol();                                 
172
 
                        }                               
173
 
                });                     
174
 
                        
175
 
                // add panels together to center
176
 
                setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));            
177
 
                add(leftPanel);
178
 
                add(playPanel);
179
 
                add(btOpenWindow);
180
 
                add(Box.createRigidArea(new Dimension(20,10)));
181
 
                                                                
182
 
                setLabels();
183
 
                setPlayDelay(playDelay);
184
 
                update();
185
 
        }
186
 
        
187
 
        public void setLabels() {
188
 
                if (btPlay != null)
189
 
                        btPlay.setText(app.getPlain("Play"));
190
 
                if (btOpenWindow != null)
191
 
                        btOpenWindow.setToolTipText(app.getPlain("ConstructionProtocol"));
192
 
        }
193
 
        
194
 
        /**
195
 
         * Updates the texts that show the current construction step and
196
 
         * the number of construction steps.    
197
 
         */
198
 
        public void update() {  
199
 
                int currentStep = prot.getCurrentStepNumber();
200
 
                int stepNumber  = prot.getLastStepNumber();
201
 
                lbSteps.setText(currentStep + " / " + stepNumber);      
202
 
        }
203
 
        
204
 
        /**
205
 
         * Registers this navigation bar at its protocol
206
 
         * to be informed about updates.
207
 
         */
208
 
        public void register() {
209
 
                prot.registerNavigationBar(this);
210
 
                update();
211
 
        }
212
 
        
213
 
        /**
214
 
         * Unregisters this navigation bar from its protocol.
215
 
         */
216
 
        public void unregister() {
217
 
                prot.unregisterNavigationBar(this);
218
 
        }
219
 
 
220
 
        public void actionPerformed(ActionEvent e) {
221
 
                Object source = e.getSource();
222
 
                
223
 
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));              
224
 
                
225
 
                if (source == btFirst) {
226
 
                        prot.firstStep();               
227
 
                } 
228
 
                else if (source == btLast) {                    
229
 
                        prot.lastStep();
230
 
                }
231
 
                else if (source == btPrev) {
232
 
                        prot.previousStep();
233
 
                }
234
 
                else if (source == btNext) {
235
 
                        prot.nextStep();
236
 
                }
237
 
                else if (source == btPlay) {                                            
238
 
                        if (isPlaying) {                                
239
 
                                player.stopAnimation();
240
 
                        } else {                                                                        
241
 
                                player = new AutomaticPlayer(playDelay);
242
 
                                player.startAnimation();
243
 
                        }                                                                       
244
 
                }       
245
 
                        
246
 
                if (prot.isVisible()) 
247
 
                        prot.scrollToConstructionStep();
248
 
                                
249
 
                setCursor(Cursor.getDefaultCursor());           
250
 
        }
251
 
        
252
 
        private void setComponentsEnabled(boolean flag) {
253
 
                Component comps[] = getComponents();
254
 
                for (int i=0; i < comps.length; i++) {
255
 
                        comps[i].setEnabled(flag);
256
 
                }
257
 
                btPlay.setEnabled(true);        
258
 
                lbSteps.setEnabled(true);
259
 
        }       
260
 
        
261
 
        /**
262
 
         * Steps through the construction automatically.
263
 
         */
264
 
        private class AutomaticPlayer implements ActionListener {             
265
 
        private Timer timer; // for animation                     
266
 
        
267
 
        /**
268
 
         * Creates a new player to step through the construction
269
 
         * automatically.
270
 
         * @param delay in seconds between steps
271
 
         */
272
 
        public AutomaticPlayer(double delay) {
273
 
                 timer = new Timer((int) (delay * 1000), this);                                         
274
 
        }      
275
 
 
276
 
        public synchronized void startAnimation() {    
277
 
                // dispatch events to play button
278
 
                        app.startDispatchingEventsTo(btPlay);
279
 
                        isPlaying = true;
280
 
                        btPlay.setIcon(new ImageIcon(app.getPauseImage()));
281
 
                        btPlay.setText(app.getPlain("Pause"));
282
 
                        setComponentsEnabled(false);
283
 
                        app.setWaitCursor();
284
 
                        
285
 
                        if (prot.getCurrentStepNumber() == prot.getLastStepNumber()) {
286
 
                        prot.firstStep();
287
 
                }
288
 
                        
289
 
            timer.start();
290
 
        }
291
 
 
292
 
        public synchronized void stopAnimation() {
293
 
            timer.stop();                   
294
 
            
295
 
            // unblock application events
296
 
                        app.stopDispatchingEvents();
297
 
                        isPlaying = false;
298
 
                        btPlay.setIcon(new ImageIcon(app.getPlayImage()));
299
 
                        btPlay.setText(app.getPlain("Play"));
300
 
                        setComponentsEnabled(true);
301
 
                        app.setDefaultCursor();
302
 
        }
303
 
 
304
 
        public synchronized void actionPerformed(ActionEvent e) {                               
305
 
                prot.nextStep();                
306
 
                if (prot.getCurrentStepNumber() == prot.getLastStepNumber()) {
307
 
                        stopAnimation();
308
 
                }
309
 
        }       
310
 
    }   
311
 
}
 
1
/* 
 
2
GeoGebra - Dynamic Mathematics for Everyone
 
3
http://www.geogebra.org
 
4
 
 
5
This file is part of GeoGebra.
 
6
 
 
7
This program is free software; you can redistribute it and/or modify it 
 
8
under the terms of the GNU General Public License as published by 
 
9
the Free Software Foundation.
 
10
 
 
11
*/
 
12
package geogebra.gui.view.consprotocol;
 
13
 
 
14
import geogebra.gui.SetLabels;
 
15
import geogebra.main.Application;
 
16
import geogebra.main.settings.AbstractSettings;
 
17
import geogebra.main.settings.ConstructionProtocolSettings;
 
18
import geogebra.main.settings.SettingListener;
 
19
 
 
20
import java.awt.Component;
 
21
import java.awt.Cursor;
 
22
import java.awt.Dimension;
 
23
import java.awt.FlowLayout;
 
24
import java.awt.event.ActionEvent;
 
25
import java.awt.event.ActionListener;
 
26
import java.text.DecimalFormat;
 
27
import java.text.DecimalFormatSymbols;
 
28
import java.util.Locale;
 
29
 
 
30
import javax.swing.Box;
 
31
import javax.swing.BoxLayout;
 
32
import javax.swing.ImageIcon;
 
33
import javax.swing.JButton;
 
34
import javax.swing.JLabel;
 
35
import javax.swing.JPanel;
 
36
import javax.swing.JSpinner;
 
37
import javax.swing.SpinnerModel;
 
38
import javax.swing.SpinnerNumberModel;
 
39
import javax.swing.Timer;
 
40
import javax.swing.JSpinner.NumberEditor;
 
41
import javax.swing.event.ChangeEvent;
 
42
import javax.swing.event.ChangeListener;
 
43
 
 
44
/**
 
45
 * Navigation buttons for the construction protocol
 
46
 */
 
47
public class ConstructionProtocolNavigation extends JPanel implements ActionListener, SettingListener, SetLabels {
 
48
 
 
49
        /**
 
50
         * 
 
51
         */
 
52
        private static final long serialVersionUID = 1L;
 
53
        private JButton btFirst, btPrev, btPlay, btNext, btLast, btOpenWindow;
 
54
        private JLabel lbSteps;
 
55
        private JSpinner spDelay;
 
56
        private double playDelay = 2; // in seconds      
 
57
        private JPanel playPanel;
 
58
        
 
59
        private Application app;
 
60
        private ConstructionProtocolView prot;
 
61
        private boolean showPlayButton = true, 
 
62
                                        showConsProtButton = true;
 
63
        
 
64
        private AutomaticPlayer player;
 
65
        private boolean isPlaying;
 
66
        
 
67
        /**
 
68
         * Creates a new navigation bar to step through the construction protocol.
 
69
         * @param internalNavigation: true if navigation bar is part of the protocol window
 
70
         */
 
71
        public ConstructionProtocolNavigation(ConstructionProtocolView prot) {
 
72
                this.prot = prot;                       
 
73
                app = prot.getApplication();    
 
74
                                
 
75
                SpinnerModel model =
 
76
                new SpinnerNumberModel(2, //initial value
 
77
                                       0.25, //min
 
78
                                       10, //max
 
79
                                       0.25); //step
 
80
                spDelay = new JSpinner(model);  
 
81
                NumberEditor numEdit = new JSpinner.NumberEditor(spDelay, "#.##");
 
82
                DecimalFormat format = numEdit.getFormat();
 
83
                format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
 
84
                
 
85
                lbSteps = new JLabel();
 
86
                
 
87
                initGUI();
 
88
                
 
89
/*              //next 3 rows moved into EuclidianDockPanel.loadComponent
 
90
                //because it not neccessary for all Contruction protocol navigation issue
 
91
                ConstructionProtocolSettings cps = app.getSettings().getConstructionProtocol();
 
92
                settingsChanged(cps);
 
93
                cps.addListener(this);
 
94
                */
 
95
        }
 
96
                
 
97
        public boolean isPlayButtonVisible() {
 
98
                return showPlayButton;
 
99
        }
 
100
        
 
101
        public void setPlayButtonVisible(boolean flag) {
 
102
                showPlayButton = flag;  
 
103
                playPanel.setVisible(flag);
 
104
        }
 
105
        
 
106
        public boolean isConsProtButtonVisible() {
 
107
                return showConsProtButton;
 
108
        }       
 
109
        
 
110
        public void setConsProtButtonVisible(boolean flag) {            
 
111
                showConsProtButton = flag;      
 
112
                btOpenWindow.setVisible(flag);
 
113
        }
 
114
        
 
115
        /**
 
116
         * Returns delay between frames of automatic construction protocol
 
117
         * playing in seconds.
 
118
         * @return
 
119
         */
 
120
        public double getPlayDelay() {
 
121
                return playDelay;
 
122
        }
 
123
        
 
124
        public void setPlayDelay(double delay) {
 
125
                playDelay = delay;
 
126
                
 
127
                try {
 
128
                        spDelay.setValue(new Double(playDelay));
 
129
                } catch (Exception e) {
 
130
                        spDelay.setValue(new Integer((int) Math.round(playDelay)));
 
131
                        
 
132
                }
 
133
        }       
 
134
        
 
135
        public void initGUI() {
 
136
                removeAll();    
 
137
                                        
 
138
                btFirst = new JButton(app.getImageIcon("nav_skipback.png"));
 
139
                btLast = new JButton(app.getImageIcon("nav_skipforward.png"));          
 
140
                btPrev = new JButton(app.getImageIcon("nav_rewind.png"));               
 
141
                btNext = new JButton(app.getImageIcon("nav_fastforward.png"));                          
 
142
                                
 
143
                btFirst.addActionListener(this);
 
144
                btLast.addActionListener(this);         
 
145
                btPrev.addActionListener(this); 
 
146
                btNext.addActionListener(this);                         
 
147
                
 
148
                JPanel leftPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));       
 
149
                leftPanel.add(btFirst);
 
150
                leftPanel.add(btPrev);
 
151
                leftPanel.add(lbSteps);                 
 
152
                leftPanel.add(btNext);
 
153
                leftPanel.add(btLast);
 
154
                
 
155
                playPanel = new JPanel();
 
156
                playPanel.setVisible(showPlayButton);
 
157
                playPanel.add(Box.createRigidArea(new Dimension(20,10)));
 
158
                btPlay = new JButton();
 
159
                btPlay.setIcon(new ImageIcon(app.getPlayImage()));
 
160
                btPlay.addActionListener(this);         
 
161
                                                                                        
 
162
                spDelay.addChangeListener(new ChangeListener() {
 
163
                        public void stateChanged(ChangeEvent e) {
 
164
                                try {
 
165
                                        playDelay = Double.parseDouble(spDelay.getValue().toString());
 
166
                                } catch (Exception ex) {
 
167
                                        playDelay = 2;
 
168
                                }
 
169
                        }                       
 
170
                });
 
171
                                        
 
172
                playPanel.add(btPlay);
 
173
                playPanel.add(spDelay); 
 
174
                playPanel.add(new JLabel("s"));         
 
175
                
 
176
                                
 
177
                btOpenWindow = new JButton();
 
178
                btOpenWindow.setIcon(app.getImageIcon("table.gif"));                    
 
179
                btOpenWindow.addActionListener(new ActionListener() {
 
180
                        public void actionPerformed(ActionEvent e) {
 
181
                                //app.getGuiManager().showConstructionProtocol();
 
182
                                if(!app.getGuiManager().showView(Application.VIEW_CONSTRUCTION_PROTOCOL))
 
183
                                        app.getGuiManager().setShowView(true, Application.VIEW_CONSTRUCTION_PROTOCOL);
 
184
                        }                               
 
185
                });
 
186
                
 
187
                // add panels together to center
 
188
                setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));            
 
189
                add(leftPanel);
 
190
                add(playPanel);
 
191
                add(btOpenWindow);
 
192
                add(Box.createRigidArea(new Dimension(20,10)));
 
193
                                                                
 
194
                setLabels();
 
195
                setPlayDelay(playDelay);
 
196
                update();
 
197
        }
 
198
        
 
199
        public void setLabels() {
 
200
                if (btPlay != null)
 
201
                        btPlay.setText(app.getPlain("Play"));
 
202
                if (btOpenWindow != null)
 
203
                        btOpenWindow.setToolTipText(app.getPlainTooltip("ConstructionProtocol"));
 
204
        }
 
205
        
 
206
        /**
 
207
         * Updates the texts that show the current construction step and
 
208
         * the number of construction steps.    
 
209
         */
 
210
        public void update() {  
 
211
                int currentStep = prot.getCurrentStepNumber();
 
212
                int stepNumber  = prot.getLastStepNumber();
 
213
                lbSteps.setText(currentStep + " / " + stepNumber);      
 
214
        }
 
215
        
 
216
        /**
 
217
         * Registers this navigation bar at its protocol
 
218
         * to be informed about updates.
 
219
         */
 
220
        public void register() {
 
221
                prot.registerNavigationBar(this);
 
222
                update();
 
223
        }
 
224
        
 
225
        /**
 
226
         * Unregisters this navigation bar from its protocol.
 
227
         */
 
228
        public void unregister() {
 
229
                prot.unregisterNavigationBar(this);
 
230
        }
 
231
 
 
232
        public void actionPerformed(ActionEvent e) {
 
233
                Object source = e.getSource();
 
234
                
 
235
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));              
 
236
                
 
237
                if (source == btFirst) {
 
238
                        prot.firstStep();               
 
239
                } 
 
240
                else if (source == btLast) {                    
 
241
                        prot.lastStep();
 
242
                }
 
243
                else if (source == btPrev) {
 
244
                        prot.previousStep();
 
245
                }
 
246
                else if (source == btNext) {
 
247
                        prot.nextStep();
 
248
                }
 
249
                else if (source == btPlay) {                                            
 
250
                        if (isPlaying) {                                
 
251
                                player.stopAnimation();
 
252
                        } else {                                                                        
 
253
                                player = new AutomaticPlayer(playDelay);
 
254
                                player.startAnimation();
 
255
                        }                                                                       
 
256
                }       
 
257
                        
 
258
                if (prot.isVisible()) 
 
259
                        prot.scrollToConstructionStep();
 
260
                                
 
261
                setCursor(Cursor.getDefaultCursor());           
 
262
        }
 
263
        
 
264
        private void setComponentsEnabled(boolean flag) {
 
265
                Component comps[] = getComponents();
 
266
                for (int i=0; i < comps.length; i++) {
 
267
                        comps[i].setEnabled(flag);
 
268
                }
 
269
                btPlay.setEnabled(true);        
 
270
                lbSteps.setEnabled(true);
 
271
        }       
 
272
        
 
273
        /**
 
274
         * Steps through the construction automatically.
 
275
         */
 
276
        private class AutomaticPlayer implements ActionListener {             
 
277
        private Timer timer; // for animation                     
 
278
        
 
279
        /**
 
280
         * Creates a new player to step through the construction
 
281
         * automatically.
 
282
         * @param delay in seconds between steps
 
283
         */
 
284
        public AutomaticPlayer(double delay) {
 
285
                 timer = new Timer((int) (delay * 1000), this);                                         
 
286
        }      
 
287
 
 
288
        public synchronized void startAnimation() {    
 
289
                // dispatch events to play button
 
290
                        app.startDispatchingEventsTo(btPlay);
 
291
                        isPlaying = true;
 
292
                        btPlay.setIcon(new ImageIcon(app.getPauseImage()));
 
293
                        btPlay.setText(app.getPlain("Pause"));
 
294
                        setComponentsEnabled(false);
 
295
                        app.setWaitCursor();
 
296
                        
 
297
                        if (prot.getCurrentStepNumber() == prot.getLastStepNumber()) {
 
298
                        prot.firstStep();
 
299
                }
 
300
                        
 
301
            timer.start();
 
302
        }
 
303
 
 
304
        public synchronized void stopAnimation() {
 
305
            timer.stop();                   
 
306
            
 
307
            // unblock application events
 
308
                        app.stopDispatchingEvents();
 
309
                        isPlaying = false;
 
310
                        btPlay.setIcon(new ImageIcon(app.getPlayImage()));
 
311
                        btPlay.setText(app.getPlain("Play"));
 
312
                        setComponentsEnabled(true);
 
313
                        app.setDefaultCursor();
 
314
        }
 
315
 
 
316
        public synchronized void actionPerformed(ActionEvent e) {                               
 
317
                prot.nextStep();                
 
318
                if (prot.getCurrentStepNumber() == prot.getLastStepNumber()) {
 
319
                        stopAnimation();
 
320
                }
 
321
        }       
 
322
    }
 
323
 
 
324
        public void settingsChanged(AbstractSettings settings) {
 
325
                ConstructionProtocolSettings cps = (ConstructionProtocolSettings)settings;
 
326
                setPlayButtonVisible(cps.showPlayButton());
 
327
                setPlayDelay(cps.getPlayDelay());
 
328
                setConsProtButtonVisible(cps.showConstructionProtocol());
 
329
                update();
 
330
                
 
331
        }       
 
332
}