Commit 4fb202c53ec9114089a50811f338bc5f309813ac

Implemented layout switching.
src/org/acsa/PersistentModel.java
(6 / 6)
  
55
66public final class PersistentModel extends Model {
77 private BufferedImage image;
8 private Scheme mode;
8 private Scheme scheme;
99
1010 public BufferedImage getImage
1111 () {
1818 touch();
1919 }
2020
21 public Scheme getMode
21 public Scheme getScheme
2222 () {
23 return mode;
23 return scheme;
2424 }
2525
26 public void setMode
26 public void setScheme
2727 (final Scheme mode) {
28 this.mode = mode;
28 this.scheme = mode;
2929 touch();
3030 }
3131
3939 final int value = random.nextInt(256);
4040 image.setRGB(index % image.getWidth(), index / image.getWidth(), value << 16 | value << 8 | value);
4141 }
42 mode = Scheme.UNIONOIDA;
42 scheme = Scheme.UNIONOIDA;
4343 }
4444}
src/org/acsa/interfaces/console/ConsoleMediator.java
(1 / 1)
  
99 @Override
1010 public ConsoleView getView
1111 () {
12 return (ConsoleView )super.getView(); // safe
12 return (ConsoleView )super.getView(); // This cast is safe.
1313 }
1414
1515 public ConsoleMediator
src/org/acsa/interfaces/swing/SwingMediator.java
(5 / 3)
  
3535 @Override
3636 public SwingView getView
3737 () {
38 return (SwingView )super.getView(); // safe
38 return (SwingView )super.getView(); // This cast is safe.
3939 }
4040
4141 public SwingViewModel getViewModel
114114 @Override
115115 public void actionPerformed
116116 (final ActionEvent event) {
117 getModel().setMode((Scheme )getView().getModePopupMenu().getSelectedItem()); // safe
117 getModel().setScheme((Scheme )getView().getModePopupMenu().getSelectedItem()); // This cast is also safe.
118118 }
119119 });
120120 getView().getAnalyzeButton().addActionListener(new ActionListener() {
232232 final BufferedImage image = getModel().getImage();
233233 final double zoom = getViewModel().getZoom();
234234 getView().getImageLabel().setIcon(new ImageIcon(image.getScaledInstance((int )Math.round(zoom * image.getWidth()), (int )Math.round(zoom * image.getHeight()), Image.SCALE_SMOOTH)));
235 getView().getModePopupMenu().setSelectedItem(getModel().getMode());
235 final Scheme mode = getModel().getScheme();
236 getView().getModePopupMenu().setSelectedItem(mode);
237 getView().getParameterCardLayout().show(getView().getParameterPanel(), mode.toString());
236238 }
237239}
src/org/acsa/interfaces/swing/SwingView.java
(178 / 105)
  
11package org.acsa.interfaces.swing;
22
33import java.awt.BorderLayout;
4import java.awt.CardLayout;
45import java.awt.ComponentOrientation;
56import java.awt.Dimension;
67import java.awt.EventQueue;
99import java.util.ConcurrentModificationException;
1010import java.util.Locale;
1111import javax.swing.BorderFactory;
12import javax.swing.Box;
1213import javax.swing.JButton;
1314import javax.swing.JComboBox;
1415import javax.swing.JEditorPane;
2828import javax.swing.SwingConstants;
2929
3030import org.acsa.Project;
31import org.acsa.Scheme;
3132import org.acsa.View;
3233import org.acsa.interfaces.swing.utilities.ConstraintFactory;
3334import org.acsa.utilitites.MediaTypes;
4949 private final JEditorPane propertyEditorPane;
5050 private final JScrollPane propertyScrollPane;
5151 private final JPanel configurationPanel;
52 private final JPanel modePanel;
53 private final JComboBox<Object> modePopupMenu;
52 private final JPanel schemePanel;
53 private final JComboBox<Object> modePopupMenu; // Generics don't work properly with JComponents.
54 private final CardLayout parameterCardLayout;
5455 private final JPanel parameterPanel;
55 private final JLabel _00_Label;
56 private final JSlider _00_Slider;
57 private final SpinnerNumberModel _00_Model;
58 private final JSpinner _00_Spinner;
59 private final JLabel _01_Label;
60 private final JSlider _01_Slider;
61 private final SpinnerNumberModel _01_Model;
62 private final JSpinner _01_Spinner;
63 private final JLabel _02_Label;
64 private final JSlider _02_Slider;
65 private final SpinnerNumberModel _02_Model;
66 private final JSpinner _02_Spinner;
67 private final JLabel _03_Label;
68 private final JSlider _03_Slider;
69 private final SpinnerNumberModel _03_Model;
70 private final JSpinner _03_Spinner;
56 private final JPanel _00_Panel;
57 private final JLabel _000_Label;
58 private final JSlider _000_Slider;
59 private final SpinnerNumberModel _000_Model;
60 private final JSpinner _000_Spinner;
61 private final JLabel _001_Label;
62 private final JSlider _001_Slider;
63 private final SpinnerNumberModel _001_Model;
64 private final JSpinner _001_Spinner;
65 private final JLabel _002_Label;
66 private final JSlider _002_Slider;
67 private final SpinnerNumberModel _002_Model;
68 private final JSpinner _002_Spinner;
69 private final JLabel _003_Label;
70 private final JSlider _003_Slider;
71 private final SpinnerNumberModel _003_Model;
72 private final JSpinner _003_Spinner;
73 private final JPanel _01_Panel;
74 private final JLabel _010_Label;
75 private final JSlider _010_Slider;
76 private final SpinnerNumberModel _010_Model;
77 private final JSpinner _010_Spinner;
78 private final JPanel _02_Panel;
7179 private final JButton analyzeButton;
7280 private final JPanel resultPanel;
7381 private final JEditorPane resultEditorPane;
172172 return configurationPanel;
173173 }
174174
175 public JPanel getModePanel
175 public JPanel getSchemePanel
176176 () {
177 return modePanel;
177 return schemePanel;
178178 }
179179
180180 public JComboBox<Object> getModePopupMenu
182182 return modePopupMenu;
183183 }
184184
185 public CardLayout getParameterCardLayout() {
186 return parameterCardLayout;
187 }
188
185189 public JPanel getParameterPanel
186190 () {
187191 return parameterPanel;
188192 }
189193
190 public JLabel get_00_Label
194 public JPanel get_00_Panel
191195 () {
192 return _00_Label;
196 return _00_Panel;
193197 }
194198
195 public JSlider get_00_Slider
199 public JLabel get_000_Label
196200 () {
197 return _00_Slider;
201 return _000_Label;
198202 }
199203
200 public SpinnerNumberModel get_00_Mode
204 public JSlider get_000_Slider
201205 () {
202 return _00_Model;
206 return _000_Slider;
203207 }
204208
205 public JSpinner get_00_Spinner
209 public SpinnerNumberModel get_000_Model
206210 () {
207 return _00_Spinner;
211 return _000_Model;
208212 }
209213
210 public JLabel get_01_Label
214 public JSpinner get_000_Spinner
211215 () {
212 return _01_Label;
216 return _000_Spinner;
213217 }
214218
215 public JSlider get_01_Slider
219 public JLabel get_001_Label
216220 () {
217 return _01_Slider;
221 return _001_Label;
218222 }
219223
220 public SpinnerNumberModel get_01_Mode
224 public JSlider get_001_Slider
221225 () {
222 return _01_Model;
226 return _001_Slider;
223227 }
224228
225 public JSpinner get_01_Spinner
229 public SpinnerNumberModel get_001_Model
226230 () {
227 return _01_Spinner;
231 return _001_Model;
228232 }
229233
230 public JLabel get_02_Label
234 public JSpinner get_001_Spinner
231235 () {
232 return _02_Label;
236 return _001_Spinner;
233237 }
234238
235 public JSlider get_02_Slider
239 public JLabel get_002_Label
236240 () {
237 return _02_Slider;
241 return _002_Label;
238242 }
239243
240 public SpinnerNumberModel get_02_Mode
244 public JSlider get_002_Slider
241245 () {
242 return _02_Model;
246 return _002_Slider;
243247 }
244248
245 public JSpinner get_02_Spinner
249 public SpinnerNumberModel get_002_Model
246250 () {
247 return _02_Spinner;
251 return _002_Model;
248252 }
249253
250 public JLabel get_03_Label
254 public JSpinner get_002_Spinner
251255 () {
252 return _03_Label;
256 return _002_Spinner;
253257 }
254258
255 public JSlider get_03_Slider
259 public JLabel get_003_Label
256260 () {
257 return _03_Slider;
261 return _003_Label;
258262 }
259263
260 public SpinnerNumberModel get_03_Mode
264 public JSlider get_003_Slider
261265 () {
262 return _03_Model;
266 return _003_Slider;
263267 }
264268
265 public JSpinner get_03_Spinner
269 public SpinnerNumberModel get_003_Model
266270 () {
267 return _03_Spinner;
271 return _003_Model;
268272 }
269273
274 public JSpinner get_003_Spinner
275 () {
276 return _003_Spinner;
277 }
278
279 public JPanel get_01_Panel
280 () {
281 return _01_Panel;
282 }
283
284 public JLabel get_010_Label
285 () {
286 return _010_Label;
287 }
288
289 public JSlider get_010_Slider
290 () {
291 return _010_Slider;
292 }
293
294 public SpinnerNumberModel get_010_Model
295 () {
296 return _010_Model;
297 }
298
299 public JSpinner get_010_Spinner
300 () {
301 return _010_Spinner;
302 }
303
304 public JPanel get_02_Panel
305 () {
306 return _02_Panel;
307 }
308
270309 public JButton getAnalyzeButton
271310 () {
272311 return analyzeButton;
381381 return showPanel;
382382 }
383383
384 public JButton get_3_Button
384 public JButton get_10_Button
385385 () {
386386 return _10_Button;
387387 }
388388
389 public JButton get_4_Button
389 public JButton get_11_Button
390390 () {
391391 return _11_Button;
392392 }
393393
394 public JButton get_5_Button
394 public JButton get_12_Button
395395 () {
396396 return _12_Button;
397397 }
398398
399 public JButton get_6_Button
399 public JButton get_13_Button
400400 () {
401401 return _13_Button;
402402 }
449449 propertyPanel.setBorder(BorderFactory.createTitledBorder("Properties"));
450450 propertyPanel.add(propertyScrollPane, BorderLayout.CENTER);
451451 configurationPanel = new JPanel(new BorderLayout()); {
452 modePanel = new JPanel(new BorderLayout()); {
452 schemePanel = new JPanel(new BorderLayout()); {
453453 modePopupMenu = new JComboBox<Object>(new String[] {"(No Mode)"});
454454 modePopupMenu.setToolTipText("Select the analysis method.");
455455 }
456 modePanel.setBorder(BorderFactory.createTitledBorder("Mode"));
457 modePanel.add(modePopupMenu, BorderLayout.CENTER);
458 parameterPanel = new JPanel(new GridBagLayout()); {
459 final String _00_ToolTipText = "Specify the parameter for something.";
460 _00_Label = new JLabel("Something");
461 _00_Slider = new JSlider(SwingConstants.HORIZONTAL);
462 _00_Slider.setToolTipText(_00_ToolTipText);
463 _00_Model = new SpinnerNumberModel(0, null, 999, 1);
464 _00_Spinner = new JSpinner(_00_Model);
465 _00_Spinner.setToolTipText(_00_ToolTipText);
466 _00_Model.setMaximum(null);
467 final String _01_ToolTipText = "Specify the parameter for something.";
468 _01_Label = new JLabel("Something");
469 _01_Slider = new JSlider(SwingConstants.HORIZONTAL);
470 _01_Slider.setToolTipText(_01_ToolTipText);
471 _01_Model = new SpinnerNumberModel(0, null, 999, 1);
472 _01_Spinner = new JSpinner(_01_Model);
473 _01_Spinner.setToolTipText(_01_ToolTipText);
474 _01_Model.setMaximum(null);
475 final String _02_ToolTipText = "Specify the parameter for something.";
476 _02_Label = new JLabel("Something");
477 _02_Slider = new JSlider(SwingConstants.HORIZONTAL);
478 _02_Slider.setToolTipText(_02_ToolTipText);
479 _02_Model = new SpinnerNumberModel(0, null, 999, 1);
480 _02_Spinner = new JSpinner(_02_Model);
481 _02_Spinner.setToolTipText(_02_ToolTipText);
482 _02_Model.setMaximum(null);
483 final String _03_ToolTipText = "Specify the parameter for something.";
484 _03_Label = new JLabel("Something");
485 _03_Slider = new JSlider(SwingConstants.HORIZONTAL);
486 _03_Slider.setToolTipText(_03_ToolTipText);
487 _03_Model = new SpinnerNumberModel(0, null, 999, 1);
488 _03_Spinner = new JSpinner(_03_Model);
489 _03_Spinner.setToolTipText(_03_ToolTipText);
490 _03_Model.setMaximum(null);
456 schemePanel.setBorder(BorderFactory.createTitledBorder("Scheme"));
457 schemePanel.add(modePopupMenu, BorderLayout.CENTER);
458 parameterCardLayout = new CardLayout();
459 parameterPanel = new JPanel(parameterCardLayout); {
460 _00_Panel = new JPanel(new GridBagLayout()); {
461 final String _000_ToolTipText = "Specify the parameter for something.";
462 _000_Label = new JLabel("Something");
463 _000_Slider = new JSlider(SwingConstants.HORIZONTAL);
464 _000_Slider.setToolTipText(_000_ToolTipText);
465 _000_Model = new SpinnerNumberModel(0, null, 999, 1);
466 _000_Spinner = new JSpinner(_000_Model);
467 _000_Spinner.setToolTipText(_000_ToolTipText);
468 _000_Model.setMaximum(null);
469 final String _001_ToolTipText = "Specify the parameter for something.";
470 _001_Label = new JLabel("Something");
471 _001_Slider = new JSlider(SwingConstants.HORIZONTAL);
472 _001_Slider.setToolTipText(_001_ToolTipText);
473 _001_Model = new SpinnerNumberModel(0, null, 999, 1);
474 _001_Spinner = new JSpinner(_001_Model);
475 _001_Spinner.setToolTipText(_001_ToolTipText);
476 _001_Model.setMaximum(null);
477 final String _002_ToolTipText = "Specify the parameter for something.";
478 _002_Label = new JLabel("Something");
479 _002_Slider = new JSlider(SwingConstants.HORIZONTAL);
480 _002_Slider.setToolTipText(_002_ToolTipText);
481 _002_Model = new SpinnerNumberModel(0, null, 999, 1);
482 _002_Spinner = new JSpinner(_002_Model);
483 _002_Spinner.setToolTipText(_002_ToolTipText);
484 _002_Model.setMaximum(null);
485 final String _003_ToolTipText = "Specify the parameter for something.";
486 _003_Label = new JLabel("Something");
487 _003_Slider = new JSlider(SwingConstants.HORIZONTAL);
488 _003_Slider.setToolTipText(_003_ToolTipText);
489 _003_Model = new SpinnerNumberModel(0, null, 999, 1);
490 _003_Spinner = new JSpinner(_003_Model);
491 _003_Spinner.setToolTipText(_003_ToolTipText);
492 _003_Model.setMaximum(null);
493 }
494 _00_Panel.add(_000_Label, ConstraintFactory.createWeightedGridBagConstraints(0, 0, 1, 0));
495 _00_Panel.add(_000_Slider, ConstraintFactory.createWeightedGridBagConstraints(0, 1, 1, 1));
496 _00_Panel.add(_000_Spinner, ConstraintFactory.createWeightedGridBagConstraints(0, 2, 1, 0));
497 _00_Panel.add(_001_Label, ConstraintFactory.createWeightedGridBagConstraints(1, 0, 1, 0));
498 _00_Panel.add(_001_Slider, ConstraintFactory.createWeightedGridBagConstraints(1, 1, 1, 1));
499 _00_Panel.add(_001_Spinner, ConstraintFactory.createWeightedGridBagConstraints(1, 2, 1, 0));
500 _00_Panel.add(_002_Label, ConstraintFactory.createWeightedGridBagConstraints(2, 0, 1, 0));
501 _00_Panel.add(_002_Slider, ConstraintFactory.createWeightedGridBagConstraints(2, 1, 1, 1));
502 _00_Panel.add(_002_Spinner, ConstraintFactory.createWeightedGridBagConstraints(2, 2, 1, 0));
503 _00_Panel.add(_003_Label, ConstraintFactory.createWeightedGridBagConstraints(3, 0, 1, 0));
504 _00_Panel.add(_003_Slider, ConstraintFactory.createWeightedGridBagConstraints(3, 1, 1, 1));
505 _00_Panel.add(_003_Spinner, ConstraintFactory.createWeightedGridBagConstraints(3, 2, 1, 0));
506 _00_Panel.add(Box.createGlue(), ConstraintFactory.createWeightedGridBagConstraints(4, 0, 1, 0));
507 _01_Panel = new JPanel(new GridBagLayout()); {
508 final String _000_ToolTipText = "Specify the parameter for something.";
509 _010_Label = new JLabel("Something");
510 _010_Slider = new JSlider(SwingConstants.HORIZONTAL);
511 _010_Slider.setToolTipText(_000_ToolTipText);
512 _010_Model = new SpinnerNumberModel(0, null, 999, 1);
513 _010_Spinner = new JSpinner(_000_Model);
514 _010_Spinner.setToolTipText(_000_ToolTipText);
515 _010_Model.setMaximum(null);
516 }
517 _01_Panel.add(_010_Label, ConstraintFactory.createWeightedGridBagConstraints(0, 0, 0, 0));
518 _01_Panel.add(_010_Slider, ConstraintFactory.createWeightedGridBagConstraints(0, 1, 0, 1));
519 _01_Panel.add(_010_Spinner, ConstraintFactory.createWeightedGridBagConstraints(0, 2, 0, 0));
520 _01_Panel.add(Box.createGlue(), ConstraintFactory.createWeightedGridBagConstraints(1, 0, 1, 0));
521 _02_Panel = new JPanel(new GridBagLayout());
522 _02_Panel.add(Box.createGlue(), ConstraintFactory.createWeightedGridBagConstraints(0, 0, 1, 0));
491523 }
492524 parameterPanel.setBorder(BorderFactory.createTitledBorder("Parameters"));
493 parameterPanel.add(_00_Label, ConstraintFactory.createWeightedGridBagConstraints(1, 0, 1, 0));
494 parameterPanel.add(_00_Slider, ConstraintFactory.createWeightedGridBagConstraints(1, 1, 1, 1));
495 parameterPanel.add(_00_Spinner, ConstraintFactory.createWeightedGridBagConstraints(1, 2, 1, 0));
496 parameterPanel.add(_01_Label, ConstraintFactory.createWeightedGridBagConstraints(2, 0, 1, 0));
497 parameterPanel.add(_01_Slider, ConstraintFactory.createWeightedGridBagConstraints(2, 1, 1, 1));
498 parameterPanel.add(_01_Spinner, ConstraintFactory.createWeightedGridBagConstraints(2, 2, 1, 0));
499 parameterPanel.add(_02_Label, ConstraintFactory.createWeightedGridBagConstraints(3, 0, 1, 0));
500 parameterPanel.add(_02_Slider, ConstraintFactory.createWeightedGridBagConstraints(3, 1, 1, 1));
501 parameterPanel.add(_02_Spinner, ConstraintFactory.createWeightedGridBagConstraints(3, 2, 1, 0));
502 parameterPanel.add(_03_Label, ConstraintFactory.createWeightedGridBagConstraints(4, 0, 1, 0));
503 parameterPanel.add(_03_Slider, ConstraintFactory.createWeightedGridBagConstraints(4, 1, 1, 1));
504 parameterPanel.add(_03_Spinner, ConstraintFactory.createWeightedGridBagConstraints(4, 2, 1, 0));
525 parameterPanel.add(_00_Panel, Scheme.UNIONOIDA.toString());
526 parameterPanel.add(_01_Panel, Scheme.AMPHIPODA.toString());
527 parameterPanel.add(_02_Panel, Scheme.SOMETHING_ELSEA.toString());
505528 analyzeButton = new JButton("Analyze Image");
506529 analyzeButton.setToolTipText("Analyze the imported image using the specified parameters.");
507530 }
508531 configurationPanel.setBorder(BorderFactory.createTitledBorder("Configuration"));
509 configurationPanel.add(modePanel, BorderLayout.PAGE_START);
532 configurationPanel.add(schemePanel, BorderLayout.PAGE_START);
510533 configurationPanel.add(parameterPanel, BorderLayout.CENTER);
511534 configurationPanel.add(analyzeButton, BorderLayout.PAGE_END);
512535 resultPanel = new JPanel(new BorderLayout()); {