1 /*
2 * Created on Sep 30, 2003
3 * Copyright (c) 2003. All rights reserved.
4 */
5 package portaview.view;
6
7 import java.awt.BorderLayout;
8 import java.awt.event.ActionEvent;
9 import java.awt.event.ActionListener;
10
11 import javax.swing.ImageIcon;
12 import javax.swing.JButton;
13 import javax.swing.JPanel;
14
15 import portaview.AbstractViewer;
16 import portaview.Displayer;
17 import portaview.Registry;
18 import portaview.model.SlideSettings;
19
20 /***
21 * Represents the button bar that controls the images.
22 *
23 * @author <a href="mailto:wwlee1@uiuc.edu">William Lee</a>
24 * @version $Id: ImageControlBar.java,v 1.13 2003/12/10 06:18:57 wlee Exp $
25 */
26 public class ImageControlBar extends JPanel
27 {
28 private AbstractViewer viewer = null;
29 private static int CL_WIDTH = 100;
30 private static int CL_HEIGHT = 40;
31 private JButton prevButton = null;
32 private JButton pauseButton = null;
33 private JButton playButton = null;
34 private JButton nextButton = null;
35 private JButton settingsButton = null;
36
37 /***
38 * Mode for the preview.
39 */
40 public static int PREVIEW = 0;
41
42 /***
43 * Mode for display.
44 */
45 public static int DISPLAY = 1;
46
47 public ImageControlBar(int mode, AbstractViewer av)
48 {
49 super();
50 setLayout(new BorderLayout());
51 JPanel buttonPanel = new JPanel();
52 this.viewer = av;
53 // Create a button that enters or leaves full-screen mode
54 JButton btn = null;
55 if (mode == DISPLAY)
56 {
57 btn = new JButton("Switch to Manager View");
58 btn.addActionListener(new ActionListener()
59 {
60 public void actionPerformed(ActionEvent e)
61 {
62 Displayer disp = (Displayer) (viewer);
63 disp.setVisible(false);
64 Registry.getMainApplication().setDisplayActive(false);
65 }
66 });
67 buttonPanel.add(btn);
68 }
69
70 prevButton = new JButton(createImageIcon("backward.gif"));
71 prevButton.setToolTipText("Previous Picture");
72 prevButton.addActionListener(new ActionListener()
73 {
74 public void actionPerformed(ActionEvent e)
75 {
76 viewer.prevSlide();
77 }
78 });
79 buttonPanel.add(prevButton);
80 pauseButton = new JButton(createImageIcon("pause.gif"));
81 pauseButton.setToolTipText("Pause");
82 pauseButton.addActionListener(new ActionListener()
83 {
84 public void actionPerformed(ActionEvent e)
85 {
86 viewer.pause();
87 }
88 });
89 buttonPanel.add(pauseButton);
90 playButton = new JButton(createImageIcon("play.gif"));
91 playButton.setToolTipText("Play");
92 playButton.addActionListener(new ActionListener()
93 {
94 public void actionPerformed(ActionEvent e)
95 {
96 viewer.play();
97 }
98 });
99 buttonPanel.add(playButton);
100 nextButton = new JButton(createImageIcon("forward.gif"));
101 nextButton.setToolTipText("Next Picture");
102 nextButton.addActionListener(new ActionListener()
103 {
104 public void actionPerformed(ActionEvent e)
105 {
106 viewer.nextSlide();
107 }
108 });
109 buttonPanel.add(nextButton);
110 if (mode != DISPLAY)
111 {
112 settingsButton = new JButton("Border and Play Speed Settings...");
113 buttonPanel.add(settingsButton);
114 settingsButton.addActionListener(new ActionListener()
115 {
116
117 public void actionPerformed(ActionEvent e)
118 {
119 SettingsDialog sd =
120 new SettingsDialog(
121 Registry.getMainApplication(),
122 Registry
123 .getMainApplication()
124 .getPreview()
125 .getModel());
126 sd.pack();
127 sd.show();
128 }
129 });
130 }
131 add(buttonPanel, BorderLayout.CENTER);
132 }
133
134 /***
135 * Creates the image icon based on the path.
136 * @param imgName the name of the image.
137 * @return the image icon.
138 */
139 protected ImageIcon createImageIcon(String imgName)
140 {
141 java.net.URL imgURL =
142 ImageControlBar.class.getResource("/portaview/images/" + imgName);
143 if (imgURL == null)
144 return null;
145 return new ImageIcon(imgURL);
146 }
147
148 /***
149 * Returns a new instance of ImageControlBar for the preview panel.
150 * @param av The controller that this bar can link its buttons to.
151 * @return the ImageControlBar for the preview panel.
152 */
153 public static ImageControlBar getPreviewBar(AbstractViewer av)
154 {
155 return new ImageControlBar(PREVIEW, av);
156 }
157
158 /***
159 * Returns a new instance of ImageControlBar for the display panel
160 * @param av The controller that this bar can link its buttons to.
161 * @return the ImageControlBar for the display (full-screen) panel.
162 */
163 public static ImageControlBar getDisplayBar(AbstractViewer av)
164 {
165 return new ImageControlBar(DISPLAY, av);
166 }
167
168 /***
169 * Sets the label for the slide settings.
170 * @param ss slide settings
171 */
172 public void setImageCount(SlideSettings ss)
173 {
174
175 }
176 /***
177 * @return the next button.
178 */
179 public JButton getNextButton()
180 {
181 return nextButton;
182 }
183
184 /***
185 * @return the pause button
186 */
187 public JButton getPauseButton()
188 {
189 return pauseButton;
190 }
191
192 /***
193 * @return the play button
194 */
195 public JButton getPlayButton()
196 {
197 return playButton;
198 }
199
200 /***
201 * @return the previous button
202 */
203 public JButton getPrevButton()
204 {
205 return prevButton;
206 }
207
208 /***
209 * Sets next button.
210 * @param button to set.
211 */
212 public void setNextButton(JButton button)
213 {
214 nextButton = button;
215 }
216
217 /***
218 * Sets pause button.
219 * @param button to set.
220 */
221 public void setPauseButton(JButton button)
222 {
223 pauseButton = button;
224 }
225
226 /***
227 * Sets play button.
228 * @param button to set.
229 */
230 public void setPlayButton(JButton button)
231 {
232 playButton = button;
233 }
234
235 /***
236 * Sets play button.
237 * @param button to set.
238 */
239 public void setPrevButton(JButton button)
240 {
241 prevButton = button;
242 }
243
244 /***
245 * @return the settings button
246 */
247 public JButton getSettingsButton()
248 {
249 return settingsButton;
250 }
251
252 /***
253 * Sets the settings button
254 * @param button button to set.
255 */
256 public void setSettingsButton(JButton button)
257 {
258 settingsButton = button;
259 }
260
261 }
This page was automatically generated by Maven