Author: laylaoesper
Date: 2010-07-28 11:11:21 -0700 (Wed, 28 Jul 2010)
New Revision: 21051
Added:
csplugins/trunk/soc/layla/SemanticSummary/lib/prefuse.jar
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarActionListener.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarPanel.java
Modified:
csplugins/trunk/soc/layla/SemanticSummary/.classpath
csplugins/trunk/soc/layla/SemanticSummary/jars/SemanticSummary.jar
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPluginAction.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/UpdateCloudAction.java
Log:
Add slider bar for network normalization stuff.
Modified: csplugins/trunk/soc/layla/SemanticSummary/.classpath
===================================================================
--- csplugins/trunk/soc/layla/SemanticSummary/.classpath 2010-07-28
17:50:57 UTC (rev 21050)
+++ csplugins/trunk/soc/layla/SemanticSummary/.classpath 2010-07-28
18:11:21 UTC (rev 21051)
@@ -70,5 +70,6 @@
<classpathentry kind="var" path="CYTOSCAPE_HOME/lib/undo.support.jar"/>
<classpathentry kind="var"
path="CYTOSCAPE_HOME/lib/violinstrings-1.0.2.jar"/>
<classpathentry kind="var" path="CYTOSCAPE_HOME/lib/woodstox.jar"/>
+ <classpathentry kind="lib" path="C:/Program
Files/prefuse-beta/build/prefuse.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: csplugins/trunk/soc/layla/SemanticSummary/jars/SemanticSummary.jar
===================================================================
(Binary files differ)
Added: csplugins/trunk/soc/layla/SemanticSummary/lib/prefuse.jar
===================================================================
(Binary files differ)
Property changes on: csplugins/trunk/soc/layla/SemanticSummary/lib/prefuse.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
2010-07-28 17:50:57 UTC (rev 21050)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
2010-07-28 18:11:21 UTC (rev 21051)
@@ -34,6 +34,7 @@
import javax.swing.JFormattedTextField;
import javax.swing.JOptionPane;
+import javax.swing.JSlider;
import cytoscape.CyNode;
import cytoscape.Cytoscape;
@@ -84,6 +85,7 @@
private boolean countInitialized = false; //true when network counts
are initialized
private boolean selInitialized = false; //true when selected counts
initialized
private boolean ratiosInitialized = false; //true when ratios are
computed
+ private boolean useNetNormal = false; //true when network counts are
used
//String Delimeters
private static final String NODEDELIMITER = "CloudParamNodeDelimiter";
@@ -92,7 +94,7 @@
//Default Values for User Input
- private Double defaultNetWeight = 0.5;
+ private Double defaultNetWeight = 0.0;
private String defaultAttName = "nodeID";
private Integer defaultMaxWords = 250;
private Double defaultClusterCutoff = 1.0;
@@ -160,6 +162,13 @@
this.maxWords = new Integer(props.get("MaxWords"));
this.cloudNum = new Integer(props.get("CloudNum"));
+ //Backwards compatibale useNetNormal
+ String val = props.get("UseNetNormal");
+ if (val == null)
+ {this.useNetNormal = true;}
+ else
+ {this.useNetNormal =
Boolean.parseBoolean(props.get("UseNetNormal"));}
+
//Rebuild List of Nodes
String value = props.get("SelectedNodes");
String[] nodes = value.split(NODEDELIMITER);
@@ -598,6 +607,7 @@
SemanticSummaryManager.getInstance().getInputWindow();
//Network Weight Value
+ /*
JFormattedTextField netWeightTextField =
inputPanel.getNetWeightTextField();
Number value = (Number) netWeightTextField.getValue();
@@ -612,7 +622,17 @@
String message = "The network weight factor must be
greater than or equal to 0 and less than or equal to 1";
JOptionPane.showMessageDialog(Cytoscape.getDesktop(),
message, "Parameter out of bounds", JOptionPane.WARNING_MESSAGE);
}
+ */
+ //Network Weight Stuff
+ SliderBarPanel panel = inputPanel.getSliderBarPanel();
+ JSlider slider = panel.getSlider();
+ Double netNorm = slider.getValue()/panel.getPrecision();
+ this.setNetWeightFactor(netNorm);
+ Boolean selected =
inputPanel.getUseNetworkCounts().isSelected();
+ this.useNetNormal = selected;
+
+
//Attribute
Object attribute =
inputPanel.getCMBAttributes().getSelectedItem();
if (attribute instanceof String)
@@ -628,7 +648,7 @@
//Max Words
JFormattedTextField maxWordsTextField =
inputPanel.getMaxWordsTextField();
- value = (Number) maxWordsTextField.getValue();
+ Number value = (Number) maxWordsTextField.getValue();
if ((value != null) && (value.intValue() >= 0))
{
setMaxWords(value.intValue());
@@ -703,6 +723,7 @@
paramVariables.append("MaxRatio\t" + maxRatio + "\n");
paramVariables.append("MaxWords\t" + maxWords + "\n");
paramVariables.append("CloudNum\t" + cloudNum + "\n");
+ paramVariables.append("UseNetNormal\t" + useNetNormal + "\n");
//List of Nodes as a comma delimited list
StringBuffer output2 = new StringBuffer();
@@ -1232,4 +1253,14 @@
{
displayStyle = style;
}
+
+ public boolean getUseNetNormal()
+ {
+ return useNetNormal;
+ }
+
+ public void setUseNetNormal(boolean val)
+ {
+ useNetNormal = val;
+ }
}
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
2010-07-28 17:50:57 UTC (rev 21050)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
2010-07-28 18:11:21 UTC (rev 21051)
@@ -55,10 +55,12 @@
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
+import javax.swing.event.ChangeListener;
import javax.swing.text.MaskFormatter;
import cytoscape.Cytoscape;
@@ -85,7 +87,6 @@
//Text Fields
private JFormattedTextField maxWordsTextField;
- private JFormattedTextField netWeightTextField;
private JFormattedTextField clusterCutoffTextField;
private JTextField addWordTextField;
@@ -112,7 +113,11 @@
//Checkbox
private JCheckBox numExclusion;
+ private JCheckBox useNetworkCounts;
+ //SliderBar
+ private SliderBarPanel sliderPanel;
+
//String Constants for Separators in remove word combo box
private static final String addedSeparator = "--Added Words--";
private static final String flaggedSeparator = "--Flagged Words--";
@@ -333,7 +338,7 @@
CloudParameters params =
SemanticSummaryManager.getInstance().getCurCloud();
JPanel panel = new JPanel();
- panel.setLayout(new GridLayout(0,1));
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
//Max words input
JLabel maxWordsLabel = new JLabel("Max Num of Words");
@@ -353,23 +358,11 @@
maxWordsPanel.add(maxWordsLabel, BorderLayout.WEST);
maxWordsPanel.add(maxWordsTextField, BorderLayout.EAST);
- //Network Weight Factor
- JLabel netWeightLabel = new JLabel("Network Normalization");
- netWeightTextField = new JFormattedTextField(decFormat);
- netWeightTextField.setColumns(3);
- netWeightTextField.setValue(params.getDefaultNetWeight());
//Set to default initially
- netWeightTextField.addPropertyChangeListener(new
SemanticSummaryInputPanel.FormattedTextFieldAction());
- buf = new StringBuffer();
- buf.append("<html>" + "Determines how much weight to give the
whole network when normalizing the selected nodes" + "<br>");
- buf.append("<b>Acceptable Values:</b> greater than or equal to
0 and less than or equal to 1" + "</html>");
- netWeightTextField.setToolTipText(buf.toString());
+ //buf = new StringBuffer();
+ //buf.append("<html>" + "Determines how much weight to give the
whole network when normalizing the selected nodes" + "<br>");
+ //buf.append("<b>Acceptable Values:</b> greater than or equal
to 0 and less than or equal to 1" + "</html>");
- //Network Weight Factor Panel
- JPanel netWeightPanel = new JPanel();
- netWeightPanel.setLayout(new BorderLayout());
- netWeightPanel.add(netWeightLabel,BorderLayout.WEST);
- netWeightPanel.add(netWeightTextField,BorderLayout.EAST);
//Clustering Cutoff
JLabel clusterCutoffLabel = new JLabel("Word Aggregation
Cutoff");
@@ -390,11 +383,48 @@
clusterCutoffPanel.add(clusterCutoffTextField,
BorderLayout.EAST);
+ //New Network Normalization Panel
+ JPanel netNormalizationPanel = new JPanel();
+ netNormalizationPanel.setLayout(new GridBagLayout());
+
+ //Checkbox
+ useNetworkCounts = new JCheckBox("Use word counts from entire
network");
+ useNetworkCounts.setToolTipText("Enables word size to be
calculated using using counts over the entire network, rather than just
selected nodes");
+ useNetworkCounts.addActionListener(this);
+ useNetworkCounts.setSelected(false);
+ useNetworkCounts.setEnabled(false);
+
+ sliderPanel = new SliderBarPanel(0,1,"Network Normalization",
"Network Normalization", 10);
+ sliderPanel.setEnabled(false);
+ sliderPanel.setVisible(false);
+
+ buf = new StringBuffer();
+ buf.append("<html>" + "Determines how much weight to give the
whole network when normalizing the selected nodes" + "<br>");
+ buf.append("<b>Acceptable Values:</b> greater than or equal to
0 and less than or equal to 1" + "</html>");
+ sliderPanel.setToolTipText(buf.toString());
+
+ GridBagConstraints gridBagConstraints = new
GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+ gridBagConstraints.insets = new Insets(5,0,0,0);
+ netNormalizationPanel.add(useNetworkCounts, gridBagConstraints);
+
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.insets = new Insets(0,0,0,0);
+ netNormalizationPanel.add(sliderPanel, gridBagConstraints);
+
//Add components to main panel
panel.add(maxWordsPanel);
- panel.add(netWeightPanel);
panel.add(clusterCutoffPanel);
+ panel.add(netNormalizationPanel);
+
//Add to collapsible panel
collapsiblePanel.getContentPane().add(panel,
BorderLayout.NORTH);
@@ -775,13 +805,15 @@
*/
public void loadCurrentCloud(CloudParameters params)
{
- netWeightTextField.setValue(params.getNetWeightFactor());
+ //sliderPanel.setNetNormValue(params.getNetWeightFactor());
cmbAttributes.setSelectedItem(params.getAttributeName());
maxWordsTextField.setValue(params.getMaxWords());
clusterCutoffTextField.setValue(params.getClusterCutoff());
cmbStyle.setSelectedItem(params.getDisplayStyle());
addWordTextField.setText("");
+ this.setupNetworkNormalization(params);
+
//Get current network
SemanticSummaryParameters networkParams =
SemanticSummaryManager.getInstance().getCurNetwork();
@@ -790,12 +822,14 @@
addWordTextField.setEditable(false);
addWordButton.setEnabled(false);
numExclusion.setEnabled(false);
+ useNetworkCounts.setEnabled(false);
}
else
{
addWordTextField.setEditable(true);
addWordButton.setEnabled(true);
numExclusion.setEnabled(true);
+ useNetworkCounts.setEnabled(true);
}
SemanticSummaryManager.getInstance().setCurCloud(params);
@@ -832,12 +866,14 @@
{
CloudParameters params =
SemanticSummaryManager.getInstance().getCurCloud();
- netWeightTextField.setValue(params.getDefaultNetWeight());
cmbAttributes.setSelectedItem(params.getDefaultAttName());
maxWordsTextField.setValue(params.getDefaultMaxWords());
clusterCutoffTextField.setValue(params.getDefaultClusterCutoff());
cmbStyle.setSelectedItem(params.getDefaultDisplayStyle());
+ this.setupNetworkNormalization(params);
+ sliderPanel.setNetNormValue(params.getDefaultNetWeight());
+
this.refreshNetworkSettings();
this.updateUI();
}
@@ -1346,15 +1382,93 @@
//Reset flags
networkParams.networkChanged();
}
+
+ if (_box == useNetworkCounts)
+ {
+ Boolean selected =
useNetworkCounts.isSelected();
+ CloudParameters cloudParams =
SemanticSummaryManager.getInstance().getCurCloud();
+
+ if
(!cloudParams.equals(SemanticSummaryManager.getInstance().getNullCloudParameters()))
+
cloudParams.setUseNetNormal(selected);
+
+ //Enable or disable slider bar stuff and reset
network weights
+ if (selected)
+ {
+ sliderPanel.setVisible(true);
+ sliderPanel.setEnabled(true);
+
+ Double netNormalization =
cloudParams.getNetWeightFactor();
+
sliderPanel.setNetNormValue(netNormalization);
+ }
+ else
+ {
+ //Confirm continuation
+ Component parent =
Cytoscape.getDesktop();
+ int value = JOptionPane.NO_OPTION;
+
+ value =
JOptionPane.showConfirmDialog(parent,"Network normalization will now be set to
0. Do you want to continue?",
+ "Network Normalization",
+
JOptionPane.YES_NO_OPTION);
+
+ if (value == JOptionPane.YES_OPTION)
+ {
+ sliderPanel.setVisible(false);
+ sliderPanel.setEnabled(false);
+
+ //reset network param
+
cloudParams.setNetWeightFactor(0.0);
+
sliderPanel.setNetNormValue(0.0);
+
+ //Update cloud display
+ UpdateCloudAction action = new
UpdateCloudAction();
+ action.doRealAction();
+ }//end if yes option
+ else
+ {
+ //Reset Values
+ sliderPanel.setVisible(true);
+ sliderPanel.setEnabled(true);
+
+ Double netNormalization =
cloudParams.getNetWeightFactor();
+
sliderPanel.setNetNormValue(netNormalization);
+
+
useNetworkCounts.setSelected(true);
+
cloudParams.setUseNetNormal(true);
+ }
+ }//end collapse Network Normalization panel
+ }//end of useNetworkCounts
+ }//end checkboxes
+ }
+
+ /**
+ * Sets up the network normalization panel for the given cloud.
+ * @param CloudParameter to use
+ */
+ private void setupNetworkNormalization(CloudParameters params)
+ {
+ //Turn off slider listener
+ ChangeListener[] listeners =
sliderPanel.getSlider().getChangeListeners();
+ for (int i = 0; i < listeners.length; i++)
+ {
+
sliderPanel.getSlider().removeChangeListener(listeners[i]);
}
+
+ Boolean useNetNorm = params.getUseNetNormal();
+ useNetworkCounts.setSelected(useNetNorm);
+ sliderPanel.setVisible(useNetNorm);
+ sliderPanel.setEnabled(useNetNorm);
+ sliderPanel.setNetNormValue(params.getNetWeightFactor());
+ sliderPanel.setLabel(sliderPanel.getSlider().getValue());
+
+ //Turn back on slider listener
+ for (int i = 0; i < listeners.length; i++)
+ {
+ sliderPanel.getSlider().addChangeListener(listeners[i]);
+ }
}
//Getters and Setters
- public JFormattedTextField getNetWeightTextField()
- {
- return netWeightTextField;
- }
public JFormattedTextField getMaxWordsTextField()
{
@@ -1442,7 +1556,17 @@
return removeDelimiterButton;
}
+ public JCheckBox getUseNetworkCounts()
+ {
+ return useNetworkCounts;
+ }
+ public SliderBarPanel getSliderBarPanel()
+ {
+ return sliderPanel;
+ }
+
+
/**
* Private Class to ensure that text fields are being set properly
*/
@@ -1456,26 +1580,10 @@
String message = "The value you have entered is
invalid. \n";
boolean invalid = false;
+
- //Net Weight Text Field
- if (source == netWeightTextField)
- {
- Number value = (Number)
netWeightTextField.getValue();
- if ((value != null) && (value.doubleValue() >=
0.0) && (value.doubleValue() <= 1))
- {
- //All is well - leave it be
- }
- else
- {
- Double defaultNetWeight =
params.getDefaultNetWeight();
-
netWeightTextField.setValue(defaultNetWeight);
- message += "The network weight factor
must be greater than or equal to 0 and less than or equal to 1";
- invalid = true;
- }
- }// end Net Weight Factor
-
//Max Words
- else if (source == maxWordsTextField)
+ if (source == maxWordsTextField)
{
Number value = (Number)
maxWordsTextField.getValue();
if ((value != null) && (value.intValue() >= 0))
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPluginAction.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPluginAction.java
2010-07-28 17:50:57 UTC (rev 21050)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPluginAction.java
2010-07-28 18:11:21 UTC (rev 21051)
@@ -72,6 +72,12 @@
*/
public void actionPerformed(ActionEvent ae)
{
+
+ doRealAction();
+ }
+
+ public void doRealAction()
+ {
//Create Null Cloud in Manager
CloudParameters nullCloud =
SemanticSummaryManager.getInstance().getNullCloudParameters();
if (nullCloud == null)
Added:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarActionListener.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarActionListener.java
(rev 0)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarActionListener.java
2010-07-28 18:11:21 UTC (rev 21051)
@@ -0,0 +1,76 @@
+/*
+ File: SliderBarActionListener.java
+
+ Copyright 2010 - The Cytoscape Consortium (www.cytoscape.org)
+
+ Code written by: Layla Oesper
+ Authors: Layla Oesper, Ruth Isserlin, Daniele Merico
+
+ This library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this project. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package cytoscape.csplugins.semanticsummary;
+
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+import javax.swing.*;
+
+
+public class SliderBarActionListener implements ChangeListener {
+
+ private SliderBarPanel panel;
+
+ //attribute that the slider bar is specific to
+ private String attribute;
+
+ /**
+ * Class constructor
+ *
+ * @param panel
+ * @param params - cloud parameters for current cloud
+ * @param attrib - attribute that the slider bar is specific to (i.e.
network normalization)
+ */
+ public SliderBarActionListener(SliderBarPanel panel,String attrib) {
+ this.panel = panel;
+ attribute = attrib;
+ }
+
+ /**
+ * Go through the current cloud and update the display as the parameter
changes. Also, resets
+ * the list of selected nodes back to original.
+ *
+ * @param e
+ */
+ public void stateChanged(ChangeEvent e){
+
+ JSlider source = (JSlider)e.getSource();
+ Double value = source.getValue()/panel.getPrecision();
+
+ panel.setLabel(source.getValue());
+
+ //Change Cloud Parameters with new value and update cloud
+ CloudParameters curCloud =
SemanticSummaryManager.getInstance().getCurCloud();
+
+ if (curCloud !=
SemanticSummaryManager.getInstance().getNullCloudParameters() &&
+ curCloud != null)
+ {
+ curCloud.setNetWeightFactor(value);
+ }
+
+ //Update cloud
+ UpdateCloudAction action = new UpdateCloudAction();
+ action.doRealAction();
+ }
+}
+
Added:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarPanel.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarPanel.java
(rev 0)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SliderBarPanel.java
2010-07-28 18:11:21 UTC (rev 21051)
@@ -0,0 +1,197 @@
+/*
+ File: SliderBarPanel.java
+
+ Copyright 2010 - The Cytoscape Consortium (www.cytoscape.org)
+
+ Code written by: Layla Oesper
+ Authors: Layla Oesper, Ruth Isserlin, Daniele Merico
+
+ This library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this project. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package cytoscape.csplugins.semanticsummary;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+
+import javax.swing.*;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.awt.*;
+
+import giny.model.Node;
+
+import prefuse.data.query.NumberRangeModel;
+
+public class SliderBarPanel extends JPanel {
+
+ //height of panel
+ private final int DIM_HEIGHT = 72;
+ //width of panel
+ private final int DIM_WIDTH = 150;
+
+ //min and max values for the slider
+ private int min;
+ private int max;
+ private NumberRangeModel rangeModel;
+
+ //precision that the slider can be adjusted to
+ private double precision = 1000.0;
+ private int dec_precision = (int) Math.log10(precision);
+
+ private JLabel label;
+ private String sliderLabel;
+
+ private JSlider slider;
+
+ /**
+ * Class constructor
+ *
+ * @param min - slider mininmum value
+ * @param max - slider maximum value
+ * @param sliderLabel
+ * @param params - cloud parameters for current cloud
+ * @param attrib - attribute that the slider bar is specific to (i.e.
network normalization)
+ * @param desired_width
+ */
+ public SliderBarPanel(double min, double max, String sliderLabel,String
attrib, int desired_width) {
+ this.setPreferredSize(new Dimension(DIM_WIDTH, DIM_HEIGHT));
+ this.setLayout(new BorderLayout(0,0));
+ this.setOpaque(false);
+
+ if((min <= 1) && (max <= 1)){
+ this.min = (int)(min*precision);
+ this.max = (int)(max*precision);
+ }
+ else{
+ this.min = (int)min;
+ this.max = (int)max;
+ }
+ this.sliderLabel = sliderLabel;
+
+ label = new JLabel(sliderLabel);
+
+ Dimension currentsize = label.getPreferredSize();
+ currentsize.height = DIM_HEIGHT/12;
+ label.setPreferredSize(currentsize);
+ initPanel(attrib, desired_width);
+ }
+
+ /**
+ * Initialize panel based on cloudParameters and desired attribute
+ *
+ * @param attrib - attribute that the slider bar is specific to (i.e.
network normalization)
+ * @param desired_width
+ */
+ public void initPanel(String attrib, int desired_width){
+
+ slider = new JSlider(JSlider.HORIZONTAL,
+ min, max, min);
+
+ slider.addChangeListener(new SliderBarActionListener(this,attrib));
+
+ slider.setMajorTickSpacing((max-min)/5);
+ slider.setPaintTicks(true);
+
+ //Create the label table
+ Hashtable labelTable = new Hashtable();
+ labelTable.put( new Integer( min ), new JLabel(""+ min/precision));
+ labelTable.put( new Integer( max ), new JLabel("" + max/precision));
+ slider.setLabelTable( labelTable );
+
+ slider.setPaintLabels(true);
+
+ Dimension currentsize = slider.getPreferredSize();
+ currentsize.width = desired_width;
+ currentsize.height = (DIM_HEIGHT/12) * 11;
+ slider.setPreferredSize(currentsize);
+
+ this.setLayout(new GridLayout(2,1));
+
+ this.add(label, BorderLayout.NORTH);
+
+ this.add(slider, BorderLayout.SOUTH);
+
+ this.revalidate();
+ }
+
+ /**
+ * Translates the provided network normalization value to an integer that
this
+ * sliderBarPanel can handle and sets the pointer appropriately.
+ * @param val
+ * @return
+ */
+ public void setNetNormValue(Double val)
+ {
+ long value = Math.round(val * this.getPrecision());
+ int intValue = (int)value;
+
+ this.getSlider().setValue(intValue);
+ }
+
+
+ //Getters and Setters
+
+ public void setLabel(int current_value) {
+ label.setText(String.format( "<html>" + sliderLabel +
// "P-value Cutoff" or "Q-value Cutoff"
+ " → " +
// HTML entity right-arrow ( → )
+ "<font size=\"-2\"> %." + dec_precision + "f </font></html>",
// dec_precision is the number of decimals for given precision
+ (current_value/precision)
// the current P/Q-value cutoff
+ ) );
+
+ this.revalidate();
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ slider.setEnabled(enabled);
+ label.setEnabled(enabled);
+ }
+
+ public double getPrecision() {
+ return precision;
+ }
+
+ public double getMin() {
+ return min/precision;
+ }
+
+ public void setMin(double min) {
+ this.min = (int)(min * precision);
+ }
+
+ public double getMax() {
+ return max/precision;
+ }
+
+ public void setMax(double max) {
+ this.max = (int) (max*precision);
+ }
+
+ public NumberRangeModel getRangeModel() {
+ return rangeModel;
+ }
+
+ public void setRangeModel(NumberRangeModel rangeModel) {
+ this.rangeModel = rangeModel;
+ }
+
+ public JSlider getSlider()
+ {
+ return slider;
+ }
+}
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/UpdateCloudAction.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/UpdateCloudAction.java
2010-07-28 17:50:57 UTC (rev 21050)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/UpdateCloudAction.java
2010-07-28 18:11:21 UTC (rev 21051)
@@ -70,15 +70,24 @@
*/
public void actionPerformed(ActionEvent ae)
{
+ this.doRealAction();
+ }
+
+ /**
+ * Method that actually contains what actually needs to happen on this
action.
+ */
+ public void doRealAction()
+ {
//Initialize the Semantic Summary Panels/Bring to front
SemanticSummaryPluginAction init = new
SemanticSummaryPluginAction();
- init.actionPerformed(ae);
+ init.doRealAction();
//Retrieve current cloud and Network from Manager
SemanticSummaryParameters networkParams =
SemanticSummaryManager.
getInstance().getCurNetwork();
CloudParameters cloudParams =
SemanticSummaryManager.getInstance().getCurCloud();
+
//Retrieve current network and view
CyNetwork network = Cytoscape.getCurrentNetwork();
CyNetworkView view = Cytoscape.getCurrentNetworkView();
@@ -92,7 +101,7 @@
Boolean isDifferent = checkSelectionChange(cloudParams, nodes);
//If List is changed
- if (isDifferent)
+ if (isDifferent &&
!cloudParams.equals(SemanticSummaryManager.getInstance().getNullCloudParameters()))
{
//Ask to continue or revert
Component parent = Cytoscape.getDesktop();
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.