List of usage examples for javax.swing SpinnerNumberModel setStepSize
public void setStepSize(Number stepSize)
getNextValue
and getPreviousValue
methods. From source file:Main.java
public static void main(String args[]) { SpinnerNumberModel model = new SpinnerNumberModel(0.0, -1000.0, 1000.0, 0.1); JSpinner s = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(s); s.setEditor(editor);// w ww. jav a 2s . c om JTextField stepText = new JTextField(10); JButton bStepSet = new JButton("Set Step"); bStepSet.addActionListener(e -> { Double val = Double.parseDouble(stepText.getText().trim()); model.setStepSize(val); }); JFrame f = new JFrame(); Container c = f.getContentPane(); c.add(s); JPanel southPanel = new JPanel(); southPanel.add(stepText); southPanel.add(bStepSet); c.add(southPanel, BorderLayout.SOUTH); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:ch.epfl.lis.gnwgui.Simulation.java
/** * Constructor/*from w ww . java 2 s .c o m*/ */ public Simulation(Frame aFrame, NetworkElement item) { super(aFrame); item_ = item; GnwSettings settings = GnwSettings.getInstance(); // Model model_.setModel(new DefaultComboBoxModel( new String[] { "Deterministic (ODEs)", "Stochastic (SDEs)", "Run both (ODEs and SDEs)" })); if (settings.getSimulateODE() && !settings.getSimulateSDE()) model_.setSelectedIndex(0); else if (!settings.getSimulateODE() && settings.getSimulateSDE()) model_.setSelectedIndex(1); else if (settings.getSimulateODE() && settings.getSimulateSDE()) model_.setSelectedIndex(2); // Experiments wtSS_.setSelected(true); wtSS_.setEnabled(false); knockoutSS_.setSelected(settings.generateSsKnockouts()); knockdownSS_.setSelected(settings.generateSsKnockdowns()); multifactorialSS_.setSelected(settings.generateSsMultifactorial()); dualKnockoutSS_.setSelected(settings.generateSsDualKnockouts()); knockoutTS_.setSelected(settings.generateTsKnockouts()); knockdownTS_.setSelected(settings.generateTsKnockdowns()); multifactorialTS_.setSelected(settings.generateTsMultifactorial()); dualKnockoutTS_.setSelected(settings.generateTsDualKnockouts()); timeSeriesAsDream4_.setSelected(settings.generateTsDREAM4TimeSeries()); // Set model of "number of time series" spinner SpinnerNumberModel model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(10000); model.setStepSize(1); model.setValue(settings.getNumTimeSeries()); numTimeSeries_.setModel(model); // Set model of "duration" spinner model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(100000); model.setStepSize(10); model.setValue((int) settings.getMaxtTimeSeries()); tmax_.setModel(model); // Set model of "number of points per time series" spinner model = new SpinnerNumberModel(); model.setMinimum(3); model.setMaximum(100000); model.setStepSize(10); double dt = settings.getDt(); double maxt = settings.getMaxtTimeSeries(); int numMeasuredPoints = (int) Math.round(maxt / dt) + 1; if (dt * (numMeasuredPoints - 1) != maxt) throw new RuntimeException( "Duration of time series (GnwSettings.maxtTimeSeries_) must be a multiple of the time step (GnwSettings.dt_)"); model.setValue(numMeasuredPoints); numPointsPerTimeSeries_.setModel(model); perturbationNew_.setSelected(!settings.getLoadPerturbations()); perturbationLoad_.setSelected(settings.getLoadPerturbations()); // Noise // Diffusion multiplier (SDE only) model = new SpinnerNumberModel(); model.setMinimum(0.0); model.setMaximum(10.); model.setStepSize(0.01); model.setValue(settings.getNoiseCoefficientSDE()); sdeDiffusionCoeff_.setModel(model); noNoise_.setSelected(!settings.getAddMicroarrayNoise() && !settings.getAddNormalNoise() && !settings.getAddLognormalNoise()); useMicroarrayNoise_.setSelected(settings.getAddMicroarrayNoise()); useLogNormalNoise_.setSelected(settings.getAddNormalNoise() || settings.getAddLognormalNoise()); addGaussianNoise_.setSelected(settings.getAddNormalNoise()); addLogNormalNoise_.setSelected(settings.getAddLognormalNoise()); // Set model of "Gaussian noise std" spinner model = new SpinnerNumberModel(); model.setMinimum(0.000001); model.setMaximum(10.); model.setStepSize(0.01); model.setValue(settings.getNormalStdev()); gaussianNoise_.setModel(model); // Set model of "log-normal noise std" spinner model = new SpinnerNumberModel(); model.setMinimum(0.000001); model.setMaximum(10.); model.setStepSize(0.01); model.setValue(settings.getLognormalStdev()); logNormalNoise_.setModel(model); normalizeNoise_.setSelected(settings.getNormalizeAfterAddingNoise()); // Set the text field with the user path userPath_.setText(GnwSettings.getInstance().getOutputDirectory()); setModelAction(); setExperimentAction(); setNoiseAction(); String title1, title2; title1 = title2 = ""; if (item_ instanceof StructureElement) { ImodNetwork network = ((StructureElement) item_).getNetwork(); title1 = item_.getLabel(); title2 = network.getSize() + " nodes, " + network.getNumEdges() + " edges"; } else if (item_ instanceof DynamicalModelElement) { GeneNetwork geneNetwork = ((DynamicalModelElement) item_).getGeneNetwork(); title1 = item_.getLabel(); title2 = geneNetwork.getSize() + " genes, " + geneNetwork.getNumEdges() + " interactions"; } setHeaderInfo(title1 + " (" + title2 + ")"); // Set tool tips for all elements of the window addTooltips(); /** * ACTIONS */ model_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setModelAction(); } }); dream4Settings_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setDream4Settings(); } }); browse_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { IODialog dialog = new IODialog(new Frame(""), "Select Target Folder", GnwSettings.getInstance().getOutputDirectory(), IODialog.LOAD); dialog.selectOnlyFolder(true); dialog.display(); if (dialog.getSelection() != null) userPath_.setText(dialog.getSelection()); } }); runButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { enterAction(); } }); cancelButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { GnwSettings.getInstance().stopBenchmarkGeneration(true); escapeAction(); } }); knockoutSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); knockdownSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); multifactorialSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); dualKnockoutSS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); knockoutTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); knockdownTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); multifactorialTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); dualKnockoutTS_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); timeSeriesAsDream4_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setExperimentAction(); } }); noNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); useMicroarrayNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); useLogNormalNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); addGaussianNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); addLogNormalNoise_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { setNoiseAction(); } }); }