public void updateRegulatorsOptions() { Integer value = (Integer) numRegulators_.getModel().getValue(); if ((Integer) numRegulators_.getModel().getValue() > (Integer) subnetSize_.getModel().getValue()) value = (Integer) subnetSize_.getModel().getValue(); SpinnerNumberModel model = (SpinnerNumberModel) numRegulators_.getModel(); model.setMinimum(1); model.setMaximum((Integer) subnetSize_.getModel().getValue()); model.setStepSize(1); model.setValue(value); }
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); }
/** Constructor */ @SuppressWarnings("serial") public SubnetExtraction(Frame aFrame, GenericElement item) { super(aFrame); item_ = item; // Set model of "subnet size" spinner SpinnerNumberModel model = new SpinnerNumberModel(); model.setMinimum(1); model.setStepSize(1); int maxSize = (item instanceof StructureElement) ? ((StructureElement) item).getNetwork().getSize() : ((DynamicalModelElement) item).getGeneNetwork().getSize(); model.setMaximum(maxSize); int effectiveSize = (10 <= maxSize) ? 10 : maxSize; model.setValue(effectiveSize); subnetSize_.setModel(model); // Set model of "number of subnets" spinner model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(20); model.setStepSize(1); model.setValue(10); numberSubnets_.setModel(model); // Set model of "random among top" spinner model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(100); model.setStepSize(1); model.setValue(20); randomAmongTopSpinner_.setModel(model); // Set model of "From strongly connected components" model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum(maxSize); model.setStepSize(1); model.setValue(10); numStronglyConnected_.setModel(model); // Set model of "From strongly connected components" model = new SpinnerNumberModel(); model.setMinimum(1); model.setMaximum((Integer) subnetSize_.getModel().getValue()); model.setStepSize(1); model.setValue(10); numRegulators_.setModel(model); // add tooltips for all elements of the window addTooltips(); 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"; } setGeneralInformation(title1 + " (" + title2 + ")"); /** ACTIONS */ subnetRootNameDocument_ = subnetRootName_.getDocument(); subnetRootNameDocument_.addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent arg0) { runButton_.setEnabled(!subnetRootName_.getText().equals("")); } public void insertUpdate(DocumentEvent arg0) { runButton_.setEnabled(!subnetRootName_.getText().equals("")); } public void removeUpdate(DocumentEvent arg0) { runButton_.setEnabled(!subnetRootName_.getText().equals("")); } }); extractAllRegulators_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { disableExtractionOptions(); } }); randomVertex_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { updateSeedControls(); } }); selectionFromList_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { updateSeedControls(); } }); greedy_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { updateNeighborSelectionControls(); } }); randomAmongTop_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { updateNeighborSelectionControls(); } }); stronglyConnected_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { updateSeedControls(); } }); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { GnwSettings.getInstance().stopSubnetExtraction(true); escapeAction(); } }); runButton_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { run(); } }); subnetSize_.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { updateRegulatorsOptions(); } }); numRegulators_.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { updateRegulatorsOptions(); } }); useNumRegulators_.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { numRegulators_.setEnabled(useNumRegulators_.isSelected()); } }); // useNumRegulators_.addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent arg0) { // numRegulators_.setEnabled(useNumRegulators_.isSelected()); // } // }); subnetIdProposal(); setListVerticesID(); updateSeedControls(); updateNeighborSelectionControls(); useNumRegulators_.setSelected(false); numRegulators_.setEnabled(false); }
/** performs the creation of the dialog and all its components. */ protected void initGUI() { JPanel panel; SpinnerNumberModel model; JPanel panel2; getContentPane().setLayout(new BorderLayout()); panel = new JPanel(new GridLayout(6, 1)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); getContentPane().add(panel, BorderLayout.CENTER); // mean precision m_MeanPrecSpinner = new JSpinner(); m_MeanPrecSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); model = (SpinnerNumberModel) m_MeanPrecSpinner.getModel(); model.setMaximum(new Integer(20)); model.setMinimum(new Integer(0)); m_MeanPrecLabel = new JLabel("Mean Precision"); m_MeanPrecLabel.setDisplayedMnemonic('M'); m_MeanPrecLabel.setLabelFor(m_MeanPrecSpinner); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_MeanPrecLabel); panel2.add(m_MeanPrecSpinner); panel.add(panel2); // stddev precision m_StdDevPrecSpinner = new JSpinner(); m_StdDevPrecSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); model = (SpinnerNumberModel) m_StdDevPrecSpinner.getModel(); model.setMaximum(new Integer(20)); model.setMinimum(new Integer(0)); m_StdDevPrecLabel = new JLabel("StdDev. Precision"); m_StdDevPrecLabel.setDisplayedMnemonic('S'); m_StdDevPrecLabel.setLabelFor(m_StdDevPrecSpinner); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_StdDevPrecLabel); panel2.add(m_StdDevPrecSpinner); panel.add(panel2); // Format m_OutputFormatComboBox = new JComboBox(m_OutputFormatNames); m_OutputFormatComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { getData(); } }); m_OutputFormatLabel = new JLabel("Output Format"); m_OutputFormatLabel.setDisplayedMnemonic('F'); m_OutputFormatLabel.setLabelFor(m_OutputFormatComboBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_OutputFormatLabel); panel2.add(m_OutputFormatComboBox); panel.add(panel2); // Average m_ShowAverageCheckBox = new JCheckBox(""); m_ShowAverageCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); m_ShowAverageLabel = new JLabel("Show Average"); m_ShowAverageLabel.setDisplayedMnemonic('A'); m_ShowAverageLabel.setLabelFor(m_ShowAverageCheckBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_ShowAverageLabel); panel2.add(m_ShowAverageCheckBox); panel.add(panel2); // Remove filter classname m_RemoveFilterNameCheckBox = new JCheckBox(""); m_RemoveFilterNameCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); m_RemoveFilterNameLabel = new JLabel("Remove filter classnames"); m_RemoveFilterNameLabel.setDisplayedMnemonic('R'); m_RemoveFilterNameLabel.setLabelFor(m_RemoveFilterNameCheckBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_RemoveFilterNameLabel); panel2.add(m_RemoveFilterNameCheckBox); panel.add(panel2); // Advanced setup m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrixEditor = new GenericObjectEditor(true); m_ResultMatrixEditor.setClassType(ResultMatrix.class); m_ResultMatrixEditor.setValue(m_ResultMatrix); m_ResultMatrixEditor.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { // user selected different class? if (!m_ResultMatrix.getClass().equals(m_ResultMatrixEditor.getValue().getClass())) { // if it's the preferred class, then automaticallly use the Experimenter defaults if (m_ResultMatrixEditor .getValue() .getClass() .equals(ExperimenterDefaults.getOutputFormat().getClass())) { m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrixEditor.setValue(ExperimenterDefaults.getOutputFormat()); } else { m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue(); } setData(); } repaint(); } }); ((GenericObjectEditor.GOEPanel) m_ResultMatrixEditor.getCustomEditor()) .addOkListener( new ActionListener() { public void actionPerformed(ActionEvent e) { m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue(); setData(); } }); m_ResultMatrixPanel = new PropertyPanel(m_ResultMatrixEditor, false); m_ResultMatrixLabel = new JLabel("Advanced setup"); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_ResultMatrixLabel); panel2.add(m_ResultMatrixPanel); panel.add(panel2); // Buttons panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(panel, BorderLayout.SOUTH); m_CancelButton = new JButton("Cancel"); m_CancelButton.setMnemonic('C'); m_CancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { m_Result = CANCEL_OPTION; setVisible(false); } }); m_OkButton = new JButton("OK"); m_OkButton.setMnemonic('O'); m_OkButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { getData(); m_Result = APPROVE_OPTION; setVisible(false); } }); panel.add(m_OkButton); panel.add(m_CancelButton); // default button getRootPane().setDefaultButton(m_OkButton); // initial layout (to get widths and heights) pack(); // adjust dimensions m_MeanPrecLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_MeanPrecLabel.getHeight())); m_MeanPrecSpinner.setPreferredSize( new Dimension(m_MeanPrecSpinner.getWidth() * 3, m_MeanPrecSpinner.getHeight())); m_StdDevPrecLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_StdDevPrecLabel.getHeight())); m_StdDevPrecSpinner.setPreferredSize( new Dimension(m_StdDevPrecSpinner.getWidth() * 3, m_StdDevPrecSpinner.getHeight())); m_OutputFormatLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_OutputFormatLabel.getHeight())); m_ShowAverageLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ShowAverageLabel.getHeight())); m_ResultMatrixLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ResultMatrixLabel.getHeight())); m_ResultMatrixPanel.setPreferredSize( new Dimension( (int) (m_ResultMatrixPanel.getWidth() * 1.5), m_ResultMatrixPanel.getHeight())); // final layout pack(); }