/** 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 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(); }
/** 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); }
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); }
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))); } } }