upgraded idmclib version to 0.2.0
[iDMC.git] / src / java / org / tsho / dmc2 / ui / AbstractPlotFrame.java
blob2ada2789cdf20d415dd36dcdf86b994239187353
1 /*
2 * iDMC the interactive Dynamical Model Calculator simulates and performs
3 * graphical and numerical analysis of systems of differential and
4 * difference equations.
6 * Copyright (C) 2004 Marji Lines and Alfredo Medio.
8 * Written by Daniele Pizzoni <auouo@tin.it>.
9 * Extended by Alexei Grigoriev <alexei_grigoriev@libero.it>.
13 * The software program was developed within a research project financed
14 * by the Italian Ministry of Universities, the Universities of Udine and
15 * Ca'Foscari of Venice, the Friuli-Venezia Giulia Region.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or any
20 * later version.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
27 package org.tsho.dmc2.ui;
29 import java.awt.BorderLayout;
30 import java.awt.Color;
31 import java.awt.Component;
32 import java.awt.Dimension;
33 import java.awt.GridBagConstraints;
34 import java.awt.GridBagLayout;
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
37 import java.awt.event.ItemEvent;
38 import java.awt.event.ItemListener;
39 import java.awt.event.KeyEvent;
40 import java.awt.event.WindowEvent;
42 import javax.swing.AbstractAction;
43 import javax.swing.AbstractButton;
44 import javax.swing.Box;
45 import javax.swing.BoxLayout;
46 import javax.swing.ButtonGroup;
47 import javax.swing.JCheckBoxMenuItem;
48 import javax.swing.JComponent;
49 import javax.swing.JFrame;
50 import javax.swing.JLabel;
51 import javax.swing.JMenu;
52 import javax.swing.JMenuItem;
53 import javax.swing.JOptionPane;
54 import javax.swing.JProgressBar;
55 import javax.swing.JRadioButtonMenuItem;
56 import javax.swing.JScrollPane;
57 import javax.swing.JSplitPane;
58 import javax.swing.JToolBar;
59 import javax.swing.WindowConstants;
61 import org.tsho.dmc2.ModelDefaults;
62 import org.tsho.dmc2.core.CoreStatusEvent;
63 import org.tsho.dmc2.core.CoreStatusListener;
64 import org.tsho.dmc2.core.dlua.Lua;
65 import org.tsho.dmc2.core.model.Model;
66 import org.tsho.dmc2.managers.AbstractManager;
67 import org.tsho.dmc2.managers.ManagerListener;
68 import org.tsho.dmc2.sm.ComponentStateMachine;
69 import org.tsho.dmc2.sm.ManagerInput;
70 import org.tsho.dmc2.sm.UserActionInput;
71 import org.tsho.dmc2.ui.components.DmcAction;
74 public abstract class AbstractPlotFrame extends JFrame
75 implements CoreStatusListener,
76 ManagerListener {
78 protected JProgressBar progressBar;
79 protected JLabel statusLabel;
80 private String progressString;
81 private long progressCount;
83 protected JComponent chart;
84 protected JScrollPane chartScrollPane;
85 protected JSplitPane splitPane;
87 protected Model model;
89 protected String defaultsSection = null;
91 private TransparencyAction transparencyAction;
92 // private JMenuItem transprcyMenuItem = null;
93 // private JMenuItem transprcyFactorMenuItem = null;
94 protected boolean transparencyDefault = false;
96 /* Plot menu items */
97 private JMenu chartSizeSubMenu;
98 private JMenuItem chartSizeMenuItem;
99 private JMenuItem gridLinesMenuItem;
100 private JMenuItem connectDotsMenuItem;
101 private JMenuItem bigDotsMenuItem;
102 private JMenuItem crossHairMenuITem;
105 protected ComponentStateMachine stateMachine;
106 private AbstractManager manager;
108 private AbstractPlotFrame() {
111 protected AbstractPlotFrame(final Model model, final String title) {
113 this.model = model;
115 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
116 setTitle(title);
119 protected void init(
120 final AbstractManager manager,
121 final ComponentStateMachine machine,
122 final JComponent controlForm) {
124 this.manager = manager;
125 this.stateMachine = machine;
127 createSplitPane(manager, controlForm);
128 createMenubar();
129 createToolbar();
130 createStatusBar();
132 // addInternalFrameListener(new InternalFrameAdapter() {
133 // public void frameClosed(final InternalFrameEvent e) {
134 // manager.stopRendering();
135 // }
136 // });
138 pack();
139 setSize(800, 600); // TODO set this as a property
141 setVisible(true);
143 // TODO fill window someway!
144 //resizeChart(chartScrollPane.getBounds().getSize());
145 //resizeChart(chartScrollPane.getViewport().getExtentSize().getSize());
146 //chartScrollPane.revalidate();
147 //validate();
148 //repaint();
152 * Abstract members
154 abstract protected void createMenubar();
155 abstract protected void createToolbar();
159 * CoreStatusListener
161 public void sendCoreStatus(final CoreStatusEvent event) {
162 /* let the manager intercept the START and FINISHED types */
164 if ((event.getType() & CoreStatusEvent.STARTED) != 0) {
165 progressBar.setVisible(true);
168 if ((event.getType() & CoreStatusEvent.FINISHED) != 0) {
169 progressBar.setVisible(false);
172 if ((event.getType() & CoreStatusEvent.STRING) != 0) {
173 progressString(event.getStatusString());
176 if ((event.getType() & CoreStatusEvent.PERCENT) != 0) {
177 progressPercent(event.getPercent());
180 if ((event.getType() & CoreStatusEvent.COUNT) != 0) {
181 progressCount(event.getCount());
187 * Status bar
189 private void createStatusBar() {
190 JToolBar toolBar = new JToolBar();
191 toolBar.setFloatable(false);
193 GridBagLayout gridbag = new GridBagLayout();
194 GridBagConstraints c = new GridBagConstraints();
195 toolBar.setLayout(gridbag);
197 progressBar = new JProgressBar();
198 progressBar.setStringPainted(true);
199 progressBar.setString("");
200 progressBar.setMaximum(99);
201 progressBar.setVisible(false);
203 //statusLabel = new JTextField("");
204 statusLabel = new JLabel("");
205 //statusLabel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
206 c.fill = GridBagConstraints.HORIZONTAL;
207 c.weightx = 80;
208 gridbag.setConstraints(statusLabel, c);
209 toolBar.add(statusLabel);
211 c.fill = GridBagConstraints.HORIZONTAL;
212 c.weightx = 20;
213 gridbag.setConstraints(progressBar, c);
214 toolBar.add(progressBar);
216 getContentPane().add(toolBar, BorderLayout.SOUTH);
219 public void progressPercent(final int p) {
220 progressBar.setValue(p);
223 public void progressString(final String s) {
224 progressString = s;
225 updateProgressBar();
228 public void progressCount(final long c) {
229 if (c <= 0) {
230 progressCount = 0;
232 else {
233 progressCount = c;
236 updateProgressBar();
239 private void updateProgressBar() {
240 if (progressCount > 0) {
241 // progressBar.setString(progressString + " - " + progressCount);
242 statusLabel.setText(progressString + " " + progressCount);
244 else {
245 // progressBar.setString(progressString);
246 statusLabel.setText(progressString);
251 * Invalid data dialog
253 public void showInvalidDataDialog(String message) {
254 JOptionPane.showMessageDialog(this, message, "Invalid data.", JOptionPane.ERROR_MESSAGE);
257 protected void showInvalidDataDialog() {
258 JOptionPane.showMessageDialog(this, "Invalid data insterted.", "Invalid data.", JOptionPane.ERROR_MESSAGE);
263 * create frame
265 protected void createSplitPane(AbstractManager manager, JComponent controlForm) {
266 JComponent controlsScrollPane;
267 Dimension dim = new Dimension(500, 500);
271 chart = manager.getChartPanel();
272 resizeChart(dim);
274 chartScrollPane = createChartScrollPane(chart);
276 controlsScrollPane = new JScrollPane(
277 controlForm,
278 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
279 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
281 splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
282 controlsScrollPane,
283 chartScrollPane);
285 splitPane.setOneTouchExpandable(true);
286 splitPane.setDividerLocation((int)controlsScrollPane.getPreferredSize().getWidth() + 10);
288 getContentPane().add(splitPane, BorderLayout.CENTER);
290 // chartScrollPane.revalidate();
292 repaint();
295 private JScrollPane createChartScrollPane(JComponent chart) {
296 Box hBox;
297 Box vBox;
299 vBox = new Box(BoxLayout.Y_AXIS);
300 vBox.setBackground(Color.black);
301 vBox.add(Box.createVerticalGlue());
302 vBox.add(chart);
303 vBox.add(Box.createVerticalGlue());
305 hBox = new Box(BoxLayout.X_AXIS);
306 hBox.add(Box.createHorizontalGlue());
307 hBox.add(vBox);
308 hBox.add(Box.createHorizontalGlue());
310 return new JScrollPane(hBox,
311 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
312 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
315 protected void resizeChart(Dimension dim) {
316 chart.setPreferredSize(dim);
317 chart.setMinimumSize(dim);
318 chart.setMaximumSize(dim);
321 public void setFixedSize(boolean flag) {
322 if (flag == true) {
323 splitPane.remove(chart);
324 // resizeChart(new Dimension (500, 500));
325 chartScrollPane = createChartScrollPane(chart);
326 splitPane.setRightComponent(chartScrollPane);
328 else {
329 splitPane.remove(chartScrollPane);
330 splitPane.setRightComponent(chart);
331 resizeChart(new Dimension (-1,-1));
337 * Common user Actions
340 // public abstract class PlotAction extends AbstractAction {
341 // final protected static String VISIBILITY_KEY = "visible";
343 // public PlotAction() {
344 // super();
346 // putValue(VISIBILITY_KEY, new Boolean(true));
347 // }
349 // public void setVisible(final boolean visible) {
351 // Boolean oldValue = (Boolean) this.getValue(VISIBILITY_KEY);
353 // if (visible == oldValue.booleanValue()) {
354 // return;
355 // }
357 // Boolean b = new Boolean(visible);
358 // putValue(VISIBILITY_KEY, b);
360 // firePropertyChange(VISIBILITY_KEY, oldValue, b);
361 // }
363 // public boolean isVisible() {
364 // return ((Boolean) getValue(VISIBILITY_KEY)).booleanValue();
365 // }
366 // }
369 protected class StartAction extends AbstractAction {
370 public StartAction() {
371 super();
373 putValue(NAME, "Start");
374 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
375 putValue(SHORT_DESCRIPTION, "reset ranges & start");
378 public void actionPerformed(final ActionEvent e) {
379 stateMachine.parseInput(UserActionInput.start);
383 protected class StopAction extends AbstractAction {
384 public StopAction() {
385 super();
386 putValue(NAME, "Stop");
387 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
388 putValue(SHORT_DESCRIPTION, "stop any calculation");
391 public void actionPerformed(final ActionEvent e) {
392 manager.stopRendering();
396 protected class ContinueAction extends DmcAction {
397 public ContinueAction() {
398 super();
399 putValue(NAME, "Continue");
400 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
401 putValue(SHORT_DESCRIPTION, "continue adding iterations");
402 //putValue(ACTION_COMMAND_KEY, UserActionInput.continua.toString());
405 public void actionPerformed(final ActionEvent e) {
406 stateMachine.parseInput(UserActionInput.continua);
410 protected class RedrawAction extends DmcAction {
411 public RedrawAction() {
412 super();
413 putValue(NAME, "Redraw");
414 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
415 putValue(SHORT_DESCRIPTION, "redraw with current ranges");
418 public void actionPerformed(final ActionEvent e) {
419 stateMachine.parseInput(UserActionInput.redraw);
423 protected class ClearAction extends AbstractAction {
424 public ClearAction() {
425 super();
426 putValue(NAME, "Clear");
427 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_C));
428 putValue(SHORT_DESCRIPTION, "clear");
431 public void actionPerformed(final ActionEvent e) {
432 stateMachine.parseInput(UserActionInput.clear);
436 protected class ResetAction extends DmcAction {
437 public ResetAction() {
438 super();
439 putValue(NAME, "Reset");
440 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
441 putValue(SHORT_DESCRIPTION, "quit this session and release the start button or menu");
443 public void actionPerformed(final ActionEvent e) {
444 stateMachine.parseInput(UserActionInput.reset);
449 protected abstract class TransparencyAction
450 extends AbstractAction {
452 protected TransparencyAction() {
453 super();
454 putValue(NAME, "Transparency");
455 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
456 putValue(SHORT_DESCRIPTION, "use a transparent ink");
460 protected abstract class TransparencyFactorAction
461 extends AbstractAction
462 implements ItemListener {
464 protected TransparencyFactorAction() {
465 super();
466 putValue(NAME, "Transparency factor...");
467 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_F));
468 putValue(SHORT_DESCRIPTION, "set the paint transparency factor");
471 public void itemStateChanged(final ItemEvent e) {
472 if (e.getStateChange() == ItemEvent.SELECTED) {
473 setEnabled(true);
474 return;
476 else if (e.getStateChange() == ItemEvent.DESELECTED) {
477 setEnabled(false);
478 return;
480 //Modification: line below commented
481 //assert (false);
484 protected Float showDialog(
485 final Component component, final float defaultValue) {
487 String result;
488 float value;
490 result = JOptionPane.showInputDialog(
491 component,
492 "Transparency (between 0 and 1):",
493 Float.toString(defaultValue));
495 if (result != null) {
496 value = Float.parseFloat(result);
497 if (value >= 0 && value <= 1) {
498 return new Float(value);
502 return null;
507 protected JMenuItem createCloseMenuItem() {
508 JMenuItem menuItem;
510 menuItem = new JMenuItem("Close");
511 menuItem.setMnemonic(KeyEvent.VK_C);
512 menuItem.addActionListener(new ActionListener()
514 public void actionPerformed(final ActionEvent e) {
515 stateMachine.parseInput(UserActionInput.close);
516 processWindowEvent(
517 new WindowEvent(
518 AbstractPlotFrame.this,
519 WindowEvent.WINDOW_CLOSING));
520 // this is fo internal frames
521 // try {
522 // setClosed(true);
523 // }
524 // catch (PropertyVetoException e1) {
525 // // TODO Auto-generated catch block
526 // e1.printStackTrace();
527 // }
532 return menuItem;
536 * Plot menu
538 protected JMenu createPlotMenu() {
539 JMenu menu;
540 JMenuItem menuItem;
541 ButtonGroup group;
543 menu = new JMenu("Plot");
544 menu.setMnemonic(KeyEvent.VK_P);
547 * Size
550 chartSizeSubMenu = new JMenu("Size");
552 // menuItem = new JCheckBoxMenuItem("Fixed Size");
553 // menuItem.setMnemonic(KeyEvent.VK_F);
554 // menu.add(menuItem);
555 // menuItem.setSelected(true);
556 // menuItem.addActionListener(new ActionListener() {
557 // public void actionPerformed(final ActionEvent e) {
558 // boolean flag = ((AbstractButton) e.getSource()).isSelected();
559 // setFixedSize(flag);
560 // chartSizeSubMenu.setEnabled(flag);
561 // chart.revalidate();
562 // }
563 // });
564 // chartSizeMenuItem = menuItem;
567 group = new ButtonGroup();
568 menuItem = new JRadioButtonMenuItem("500x500");
569 menuItem.setSelected(true);
570 menuItem.setMnemonic(KeyEvent.VK_6);
571 group.add(menuItem);
572 chartSizeSubMenu.add(menuItem);
573 menuItem.addActionListener(new ActionListener() {
574 public void actionPerformed(final ActionEvent e) {
575 resizeChart(new Dimension(500, 500));
576 chart.revalidate();
580 menuItem = new JRadioButtonMenuItem("600x600");
581 menuItem.setMnemonic(KeyEvent.VK_8);
582 group.add(menuItem);
583 chartSizeSubMenu.add(menuItem);
584 menuItem.addActionListener(new ActionListener() {
585 public void actionPerformed(final ActionEvent e) {
586 resizeChart(new Dimension(600, 600));
587 chart.revalidate();
591 menuItem = new JMenuItem("Fit to window");
592 menuItem.setMnemonic(KeyEvent.VK_F);
593 chartSizeSubMenu.add(menuItem);
594 menuItem.addActionListener(new ActionListener() {
595 public void actionPerformed(final ActionEvent e) {
596 //resizeChart(chartScrollPane.getBounds().getSize());
597 resizeChart(chartScrollPane.getViewport().getExtentSize().getSize());
598 chart.revalidate();
604 menuItem = new JMenuItem("Custom size...");
605 //menuItem.setMnemonic(KeyEvent.VK_C);
606 menu.add(menuItem);
607 menuItem.addActionListener(new ActionListener() {
608 public void actionPerformed(ActionEvent e) {
609 Dimension d = chart.getPreferredSize();
610 WindowsSizePanel panel = new WindowsSizePanel(d.width, d.height);
611 int result = JOptionPane.showConfirmDialog(
612 null, panel,
613 "Change plot dimensions",
614 JOptionPane.OK_CANCEL_OPTION,
615 JOptionPane.PLAIN_MESSAGE);
616 if (result == JOptionPane.OK_OPTION) {
617 d.setSize(panel.getWidth(), panel.getHeight());
618 resizeChart(d);
619 chart.revalidate();
623 chartSizeSubMenu.add(menuItem);
625 stateMachine.addSensibleItem(chartSizeSubMenu);
626 menu.add(chartSizeSubMenu);
629 * Transparency
631 // TODO get rid of those orrible actions!
632 if (manager instanceof AbstractManager.Transparency) {
634 menu.addSeparator();
636 final AbstractManager.Transparency trManager =
637 (AbstractManager.Transparency) manager;
639 TransparencyFactorAction trfAction = new TransparencyFactorAction() {
640 public void actionPerformed(final ActionEvent e) {
641 Float result;
642 result = showDialog(AbstractPlotFrame.this, trManager.getAlphaValue());
643 if (result != null) {
644 trManager.setAlphaValue(result.floatValue());
649 transparencyAction = new TransparencyAction() {
650 public void actionPerformed(final ActionEvent e) {
651 boolean selected = ((AbstractButton)e.getSource()).isSelected();
652 trManager.setAlpha(selected);
656 // follow the default
657 trfAction.setEnabled(false);
659 menuItem = new JCheckBoxMenuItem(transparencyAction);
661 menuItem.addItemListener(trfAction);
662 menuItem.setSelected(transparencyDefault);
663 //transprcyMenuItem = menuItem;
664 menu.add(menuItem);
667 menuItem = new JMenuItem(trfAction);
668 // menuItem.setToolTipText(trfAction.getTooltipText());
669 menu.add(menuItem);
670 // menuItem.setEnabled(transparencyAction.isSelected());
671 //transprcyFactorMenuItem = menuItem;
674 // separator
675 if (manager instanceof AbstractManager.GridLines ||
676 manager instanceof AbstractManager.ConnectDots ||
677 manager instanceof AbstractManager.BigDots ||
678 manager instanceof AbstractManager.Crosshair) {
679 menu.addSeparator();
683 * Gridlines
685 if (manager instanceof AbstractManager.GridLines) {
686 menuItem = new JCheckBoxMenuItem("Gridlines");
687 menuItem.setMnemonic(KeyEvent.VK_G);
688 menu.add(menuItem);
689 menuItem.setSelected(((AbstractManager.GridLines)manager).isGridlines());
690 menuItem.addActionListener(new ActionListener() {
691 public void actionPerformed(ActionEvent e) {
692 ((AbstractManager.GridLines)manager).setGridlines(
693 ((JCheckBoxMenuItem)e.getSource()).isSelected());
696 //compState.setUpSensibleMenuItems(menuItem);
697 gridLinesMenuItem = menuItem;
701 * Big dots
703 if (manager instanceof AbstractManager.BigDots) {
704 menuItem = new JCheckBoxMenuItem("Big dots");
705 menuItem.setMnemonic(KeyEvent.VK_B);
706 menu.add(menuItem);
707 menuItem.setSelected(((AbstractManager.BigDots)manager).isBigDots());
708 menuItem.addActionListener(new ActionListener() {
709 public void actionPerformed(ActionEvent e) {
710 ((AbstractManager.BigDots)manager).setBigDots(
711 ((JCheckBoxMenuItem)e.getSource()).isSelected());
714 bigDotsMenuItem = menuItem;
718 * Connect dots
720 if (manager instanceof AbstractManager.ConnectDots) {
721 menuItem = new JCheckBoxMenuItem("Connect dots");
722 menuItem.setMnemonic(KeyEvent.VK_C);
723 menu.add(menuItem);
724 menuItem.setSelected(((AbstractManager.ConnectDots)manager).isConnectDots());
725 menuItem.addActionListener(new ActionListener() {
726 public void actionPerformed(ActionEvent e) {
727 ((AbstractManager.ConnectDots)manager).setConnectDots(
728 ((JCheckBoxMenuItem)e.getSource()).isSelected());
731 connectDotsMenuItem = menuItem;
735 * Crosshair
737 if (manager instanceof AbstractManager.Crosshair) {
738 menuItem = new JCheckBoxMenuItem("Crosshair");
739 menuItem.setMnemonic(KeyEvent.VK_B);
740 menu.add(menuItem);
741 menuItem.setSelected(((AbstractManager.Crosshair)manager).isCrosshair());
742 menuItem.addActionListener(new ActionListener() {
743 public void actionPerformed(ActionEvent e) {
744 ((AbstractManager.Crosshair)manager).setCrosshair(
745 ((JCheckBoxMenuItem)e.getSource()).isSelected());
748 crossHairMenuITem = menuItem;
751 return menu;
754 // protected void setTransparency(
755 // AbstractManager.Transparency manager, boolean flag) {
757 // transparencyAction.setSelected(flag);
758 // manager.setAlpha(flag);
759 // }
762 * Defaults menu
764 protected JMenu createDefaultsMenu() {
765 JMenu menu;
766 JMenuItem menuItem;
768 if (defaultsSection == null) return null;
770 menu = new JMenu("Insert defaults");
771 menu.setMnemonic(KeyEvent.VK_D);
773 int index = 1;
774 while (true) {
775 String description, name;
777 description = Lua.checkDefaults(
778 model, defaultsSection, index, ModelDefaults.DESCRIPTION_KEY);
780 if (description == null) break;
782 name = Lua.checkDefaults(
783 model, defaultsSection, index, ModelDefaults.NAME_KEY);
784 if (name.equals("")) {
785 menuItem = new JMenuItem("default " + index);
787 else {
788 menuItem = new JMenuItem(name);
791 // TODO currently tooltips don't like \n.
792 // create tooltips with \n
793 // String toolTipText = "";
794 // VariableItems items = Lua.loadDefaults(model, defaultsSection, index);
795 // VariableItems.Iterator i;
797 // i = items.iterator();
798 // while (i.hasNext()) {
799 // System.out.println(i.nextLabel() + ": " + i.value());
800 // toolTipText = toolTipText + i.label() + ": " + i.value() +" \n";
801 // }
802 // System.out.println("tooltip:\n" + toolTipText);
803 // if (!toolTipText.equals("")) {
804 // menuItem.setToolTipText(toolTipText);
805 // }
807 if (!description.equals("")) {
808 menuItem.setToolTipText(description);
811 menuItem.setActionCommand(Integer.toString(index));
812 menuItem.addActionListener(new ActionListener() {
813 public void actionPerformed(ActionEvent e) {
814 String c = ((AbstractButton)e.getSource()).getActionCommand();
815 fillDefaults(Integer.parseInt(c));
819 menu.add(menuItem);
820 index++;
823 if (index == 1) return null;
824 return menu;
827 protected abstract void fillDefaults(int index);
830 * Notifies the starting (true) or ending (false) of the rendering thread
832 public void jobNotify(final boolean status) {
833 progressBar.setVisible(status);
834 if (status) {
835 stateMachine.parseInput(ManagerInput.start);
837 else {
838 stateMachine.parseInput(ManagerInput.end);
844 * @return Returns the model.
846 public Model getModel() {
847 return model;
850 * @return Returns the chartSizeMenuItem.
852 public JMenuItem getChartSizeMenuItem() {
853 return chartSizeMenuItem;
856 * @return Returns the chartSizeSubMenu.
858 public JMenu getChartSizeSubMenu() {
859 return chartSizeSubMenu;
862 * @return Returns the connectDotsMenuItem.
864 public JMenuItem getConnectDotsMenuItem() {
865 return connectDotsMenuItem;
868 * @return Returns the gridLinesMenuItem.
870 public JMenuItem getGridLinesMenuItem() {
871 return gridLinesMenuItem;
874 * @return
876 // protected JMenuItem getTransprcyMenuItem() {
877 // return transprcyMenuItem;
878 // }
881 * @return
883 public JMenuItem getBigDotsMenuItem() {
884 return bigDotsMenuItem;
887 // /**
888 // * @return
889 // */
890 // public JMenuItem getTransprcyFactorMenuItem() {
891 // return transprcyFactorMenuItem;
892 // }
895 * @return
897 public TransparencyAction getTransparencyAction() {
898 return transparencyAction;
902 * @return
904 public AbstractManager getManager() {
905 return manager;