/** Performs the action of loading a session from a file. */
  public void actionPerformed(ActionEvent e) {
    DataModel dataModel = getDataEditor().getSelectedDataModel();

    if (!(dataModel instanceof DataSet)) {
      JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set.");
      return;
    }

    this.dataSet = (DataSet) dataModel;

    SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1);
    JSpinner jSpinner = new JSpinner(spinnerNumberModel);
    jSpinner.setPreferredSize(jSpinner.getPreferredSize());

    spinnerNumberModel.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpinnerNumberModel model = (SpinnerNumberModel) e.getSource();
            setNumLags(model.getNumber().intValue());
          }
        });

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    b1.add(new JLabel("Number of time lags: "));
    b1.add(Box.createHorizontalGlue());
    b1.add(Box.createHorizontalStrut(15));
    b1.add(jSpinner);
    b1.setBorder(new EmptyBorder(10, 10, 10, 10));
    b.add(b1);

    panel.add(b, BorderLayout.CENTER);

    EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true);
    DesktopController.getInstance().addEditorWindow(editorWindow);
    editorWindow.setVisible(true);

    editorWindow.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameClosed(InternalFrameEvent e) {
            EditorWindow window = (EditorWindow) e.getSource();

            if (!window.isCanceled()) {
              if (dataSet.isContinuous()) {
                createContinuousTimeSeriesData();
              } else if (dataSet.isDiscrete()) {
                createDiscreteTimeSeriesData();
              } else {
                JOptionPane.showMessageDialog(
                    JOptionUtils.centeringComp(),
                    "Data set must be either continuous or discrete.");
              }
            }
          }
        });
  }
  public void init() {
    setup("Circumference of a Circle");
    SpinnerNumberModel snm = (SpinnerNumberModel) (n.getModel());
    snm.setMinimum(new Integer(3));

    north.setLayout(new BorderLayout());
    north.add("West", choice);
    JPanel east = new JPanel();
    east.add(new JLabel(" n="));
    east.add(n);
    north.add("East", east);

    south.remove(choice);

    contentpane.add("North", north);

    contentpane.add("Center", graph = new CircleCircumferenceGraph(this, N));
    if (getParameter("originX") != null) {
      graph.originX = Double.parseDouble(getParameter("originX"));
    }
    if (getParameter("originY") != null) {
      graph.originY = Double.parseDouble(getParameter("originY"));
    }
    if (getParameter("zoom") != null) {
      graph.zoom += Integer.parseInt(getParameter("zoom"));
    }

    stat2.setVisible(true);

    // choice = new Choice();
    choice.addItem("Inscribed Polygon");
    choice.addItem("Circumscribed Polygon");
    choice.addItem("Show Both");
    choice.addItem("Show Sequences");
    // choice.addItem("Newton-Cotes Rule");
    choice.setSelectedItem(getParameter("type"));

    graph.repaint();
    splash = new SplashPanel(new CircleCircumferenceGraph(this, N));
    splash.graph.originX = graph.originX;
    splash.graph.originY = graph.originY;
    splash.graph.zoom = graph.zoom;
    getContentPane().add(splash);
  }
  /** Update date spinner to synchronize with the other spinners */
  private void updateDate() {
    // Get current month and year in int
    int month = ((SpinnerListModel) jspMonth.getModel()).getList().indexOf(jspMonth.getValue());
    int year = ((Integer) spinnerYear.getValue()).intValue();

    // Set a new maximum number of days for the new month and year
    SpinnerNumberModel numberModel = (SpinnerNumberModel) jspDay.getModel();
    numberModel.setMaximum(new Integer(maxDaysInMonth(year, month)));

    // Set a new current day if it exceeds the maximum
    if (((Integer) (numberModel.getValue())).intValue() > maxDaysInMonth(year, month))
      numberModel.setValue(new Integer(maxDaysInMonth(year, month)));

    // Get the current day
    int day = ((Integer) jspDay.getValue()).intValue();

    // Set a new date in the date spinner
    jspDate.setValue(new GregorianCalendar(year, month, day).getTime());
  }
  /** Builds the panel. */
  public void setup() {
    SpinnerNumberModel model =
        new SpinnerNumberModel(this.params.getInt("numTimeLags", 1), 0, Integer.MAX_VALUE, 1);
    JSpinner jSpinner = new JSpinner(model);
    jSpinner.setPreferredSize(jSpinner.getPreferredSize());

    model.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpinnerNumberModel model = (SpinnerNumberModel) e.getSource();
            params.set("numTimeLags", model.getNumber().intValue());
          }
        });

    Box b1 = Box.createHorizontalBox();
    b1.add(new JLabel("Number of lags: "));
    b1.add(Box.createHorizontalGlue());
    b1.add(Box.createHorizontalStrut(15));
    b1.add(jSpinner);
    b1.setBorder(new EmptyBorder(10, 10, 10, 10));
    add(b1, BorderLayout.CENTER);
  }
Пример #5
0
  public LineBorderEditor() {

    initialize();

    color = new ColorHolder();
    setCaption(getEditorLocaleString("Line"));
    assignValueToParameters();

    rounded = new JCheckBox(getEditorLocaleString("Rounded_corners"));
    rounded.setSelected(roundedCorners);
    rounded.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            roundedCorners = rounded.isSelected();
            fireChange();
          }
        });

    thickModel = new SpinnerNumberModel(thickness, MIN_THICK, MAX_THICK, 1);
    SpinPane thickPane = new SpinPane(thickModel, getEditorLocaleString("Thickness"));
    thickModel.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            thickness = thickModel.getNumber().intValue();
            fireChange();
          }
        });

    JButton bColor = new JButton(getEditorLocaleString("Color"));
    ColorChooseAction colorChooseAction =
        new ColorChooseAction(color, getEditorLocaleString("Color"), this);
    colorChooseAction.addPropertyChangeListener(this);
    bColor.addActionListener(colorChooseAction);

    setLayout(new BorderLayout());
    JPanel pane = new JPanel(new GridLayout(1, 2));
    pane.add(getCenteredPane(rounded));
    pane.add(getCenteredPane(thickPane));
    JPanel paneTotal = new JPanel(new GridLayout(2, 1));
    paneTotal.add(pane);
    paneTotal.add(getCenteredPane(bColor));
    add(paneTotal, BorderLayout.NORTH);

    refreshInterface();
  }
Пример #6
0
  public LingDisplay(final Ling.StoredGraphs storedGraphs) {
    this.storedGraphs = storedGraphs;

    if (storedGraphs.getNumGraphs() == 0) {
      workbench = new GraphWorkbench();
    } else {
      workbench = new GraphWorkbench(storedGraphs.getGraph(0));
    }

    subsetIndices = getStableIndices(storedGraphs);

    final SpinnerNumberModel model =
        new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1);
    model.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            int index = model.getNumber().intValue();
            workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
          }
        });

    spinner = new JSpinner();
    subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"});
    subsetCombo.setSelectedItem("Show Stable");
    spinner.setModel(model);
    totalLabel = new JLabel(" of " + subsetIndices.size());

    subsetCombo.setMaximumSize(subsetCombo.getPreferredSize());
    subsetCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resetDisplay();
          }
        });

    spinner.setPreferredSize(new Dimension(50, 20));
    spinner.setMaximumSize(spinner.getPreferredSize());
    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    //        b1.add(Box.createHorizontalGlue());
    //        b1.add(Box.createHorizontalStrut(10));
    b1.add(subsetCombo);
    b1.add(Box.createHorizontalGlue());
    b1.add(new JLabel("DAG "));
    b1.add(spinner);
    b1.add(totalLabel);

    b.add(b1);

    Box b2 = Box.createHorizontalBox();
    JPanel graphPanel = new JPanel();
    graphPanel.setLayout(new BorderLayout());
    JScrollPane jScrollPane = new JScrollPane(workbench);
    //        jScrollPane.setPreferredSize(new Dimension(400, 400));
    graphPanel.add(jScrollPane);
    //        graphPanel.setBorder(new TitledBorder("DAG"));
    b2.add(graphPanel);
    b.add(b2);

    setLayout(new BorderLayout());
    //        add(menuBar(), BorderLayout.NORTH);
    add(b, BorderLayout.CENTER);
  }
Пример #7
0
  private void resetDisplay() {
    String option = (String) subsetCombo.getSelectedItem();

    if ("Show All".equals(option)) {
      final List<Integer> _subsetIndices = getAllIndices(getStoredGraphs());
      subsetIndices.clear();
      subsetIndices.addAll(_subsetIndices);

      int min = subsetIndices.size() == 0 ? 0 : 1;
      final SpinnerNumberModel model = new SpinnerNumberModel(min, min, subsetIndices.size(), 1);
      model.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              int index = model.getNumber().intValue();
              workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
            }
          });

      spinner.setModel(model);
      totalLabel.setText(" of " + _subsetIndices.size());

      if (subsetIndices.isEmpty()) {
        workbench.setGraph(new EdgeListGraph());
      } else {
        workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0)));
      }
    } else if ("Show Stable".equals(option)) {
      final List<Integer> _subsetIndices = getStableIndices(getStoredGraphs());
      subsetIndices.clear();
      subsetIndices.addAll(_subsetIndices);

      int min = subsetIndices.size() == 0 ? 0 : 1;
      final SpinnerNumberModel model = new SpinnerNumberModel(min, min, subsetIndices.size(), 1);
      model.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              int index = model.getNumber().intValue();
              workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
            }
          });

      spinner.setModel(model);
      totalLabel.setText(" of " + _subsetIndices.size());

      if (subsetIndices.isEmpty()) {
        workbench.setGraph(new EdgeListGraph());
      } else {
        workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0)));
      }
    } else if ("Show Unstable".equals(option)) {
      final List<Integer> _subsetIndices = getUnstableIndices(getStoredGraphs());
      subsetIndices.clear();
      subsetIndices.addAll(_subsetIndices);

      int min = subsetIndices.size() == 0 ? 0 : 1;
      final SpinnerNumberModel model = new SpinnerNumberModel(min, min, subsetIndices.size(), 1);
      model.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              int index = model.getNumber().intValue();
              workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
            }
          });

      spinner.setModel(model);
      totalLabel.setText(" of " + _subsetIndices.size());

      if (subsetIndices.isEmpty()) {
        workbench.setGraph(new EdgeListGraph());
      } else {
        workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0)));
      }
    }
  }
Пример #8
0
 public void refreshInterface() {
   assignValueToParameters();
   rounded.setSelected(roundedCorners);
   thickModel.setValue(new Integer(thickness));
 }