Author: laylaoesper
Date: 2010-08-03 12:46:58 -0700 (Tue, 03 Aug 2010)
New Revision: 21145
Modified:
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/CreateCloudAction.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SingleWordCluster.java
Log:
Add multi attribute ability.
Modified: csplugins/trunk/soc/layla/SemanticSummary/jars/SemanticSummary.jar
===================================================================
(Binary files differ)
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
2010-08-03 19:21:39 UTC (rev 21144)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
2010-08-03 19:46:58 UTC (rev 21145)
@@ -57,7 +57,8 @@
//VARIABLES
private String cloudName;
- private String attributeName;
+ //private String attributeName;
+ private ArrayList<String> attributeNames;
private String displayStyle;
private SemanticSummaryParameters networkParams; //parent network
@@ -126,10 +127,13 @@
this.cloudWords = new ArrayList<CloudWordInfo>();
this.netWeightFactor = this.getDefaultNetWeight();
- this.attributeName = this.getDefaultAttName();
+ //this.attributeName = this.getDefaultAttName();
this.clusterCutoff = this.getDefaultClusterCutoff();
this.maxWords = this.getDefaultMaxWords();
this.displayStyle = this.getDefaultDisplayStyle();
+
+ this.attributeNames = new ArrayList<String>();
+ this.attributeNames.add(this.getDefaultAttName());
}
/**
@@ -156,7 +160,7 @@
}
this.cloudName = props.get("CloudName");
- this.attributeName = props.get("AttributeName");
+ //this.attributeName = props.get("AttributeName");
this.displayStyle = props.get("DisplayStyle");
this.selectedNumNodes = new
Integer(props.get("SelectedNumNodes"));
this.networkNumNodes = new
Integer(props.get("NetworkNumNodes"));
@@ -197,12 +201,21 @@
if (val != null)
{this.maxWeight = new Double(props.get("MaxWeight"));}
+ //Rebuild attribute List
+ String value = props.get("AttributeName");
+ String[] attributes = value.split(WORDDELIMITER);
+ ArrayList<String> attributeList = new ArrayList<String>();
+ for (int i = 0; i < attributes.length; i++)
+ {
+ String curAttribute = attributes[i];
+ attributeList.add(curAttribute);
+ }
+ this.attributeNames = attributeList;
-
//Rebuild List of Nodes
- String value = props.get("SelectedNodes");
+ value = props.get("SelectedNodes");
String[] nodes = value.split(NODEDELIMITER);
ArrayList<String> nodeNameList = new ArrayList<String>();
for (int i = 0; i < nodes.length; i++)
@@ -271,60 +284,68 @@
continue;
}
- String nodeValue = this.getNodeAttributeVal(curNode);
- if (nodeValue == null) // problem with nodes or
attributes
- continue;
+ for (int i = 0; i < attributeNames.size(); i++)
+ {
+ String curAttribute = attributeNames.get(i);
+ String nodeValue =
this.getNodeAttributeVal(curNode, curAttribute);
- List<String> wordSet =
this.processNodeString(nodeValue);
- String lastWord = ""; //Used for calculating pair counts
+ //String nodeValue =
this.getNodeAttributeVal(curNode);
+ if (nodeValue == null) // problem with nodes or
attributes
+ continue;
+
+ List<String> wordSet =
this.processNodeString(nodeValue);
+ String lastWord = ""; //Used for calculating
pair counts
- //Iterate through all words
- Iterator<String> wordIter = wordSet.iterator();
- while(wordIter.hasNext())
- {
- String curWord = wordIter.next();
-
- //Check filters
- WordFilter filter = networkParams.getFilter();
- if (!filter.contains(curWord))
+ //Iterate through all words
+ Iterator<String> wordIter = wordSet.iterator();
+ while(wordIter.hasNext())
{
- //If this word has not been
encountered, or not encountered
- //in this node, add it to our mappings
and counts
- HashMap<String, List<String>>
curMapping = this.getStringNodeMapping();
+ String curWord = wordIter.next();
- //If we have not encountered this word,
add it to the mapping
- if (!curMapping.containsKey(curWord))
+ //Check filters
+ WordFilter filter =
networkParams.getFilter();
+ if (!filter.contains(curWord))
{
- curMapping.put(curWord, new
ArrayList<String>());
- networkCounts.put(curWord, 0);
- }
+ //If this word has not been
encountered, or not encountered
+ //in this node, add it to our
mappings and counts
+ HashMap<String, List<String>>
curMapping = this.getStringNodeMapping();
+
+ //If we have not encountered
this word, add it to the mapping
+ if
(!curMapping.containsKey(curWord))
+ {
+ curMapping.put(curWord,
new ArrayList<String>());
+
networkCounts.put(curWord, 0);
+ }
- //Add node to mapping, update counts
-
curMapping.get(curWord).add(curNode.toString());
- Integer num =
networkCounts.get(curWord);
- num = num + 1;
- networkCounts.put(curWord, num);
+ //Add node to mapping, update
counts
+
curMapping.get(curWord).add(curNode.toString());
+ Integer num =
networkCounts.get(curWord);
+ num = num + 1;
+ networkCounts.put(curWord, num);
- //Add to pair counts
- if (!lastWord.equals(""))
- {
- Integer curPairCount = 0;
- String pairName = lastWord + "
" + curWord;
+ //Add to pair counts
+ if (!lastWord.equals(""))
+ {
+ Integer curPairCount =
0;
+ String pairName =
lastWord + " " + curWord;
- if
(networkPairCounts.containsKey(pairName))
- curPairCount =
networkPairCounts.get(pairName);
+ if
(networkPairCounts.containsKey(pairName))
+ curPairCount =
networkPairCounts.get(pairName);
- curPairCount = curPairCount + 1;
- networkPairCounts.put(pairName,
curPairCount);
- }
+ curPairCount =
curPairCount + 1;
+
networkPairCounts.put(pairName, curPairCount);
+ }
- //Update curWord to be LastWord
- lastWord = curWord;
+ //Update curWord to be LastWord
+ lastWord = curWord;
- }//end filter if
- }// word iterator
+ }//end filter if
+ }// word iterator
+ }//end attribute iterator
}//end node iterator
+
+ networkNumNodes = networkNodes.size() * attributeNames.size();
countInitialized = true;
}
@@ -364,60 +385,69 @@
{
Component desktop = Cytoscape.getDesktop();
JOptionPane.showMessageDialog(desktop, "Node no
longer exists: " + curNodeID);
- return;
+ continue;
}
- String nodeValue = this.getNodeAttributeVal(curNode);
- if (nodeValue == null) // problem with nodes or
attributes
- return;
+ for (int i = 0; i < attributeNames.size(); i++)
+ {
+ String curAttribute = attributeNames.get(i);
+ String nodeValue =
this.getNodeAttributeVal(curNode, curAttribute);
- List<String> wordSet =
this.processNodeString(nodeValue);
- String lastWord = ""; //Used for calculating pair counts
+ //String nodeValue =
this.getNodeAttributeVal(curNode);
+
+ if (nodeValue == null) // problem with nodes or
attributes
+ continue;
+
+ List<String> wordSet =
this.processNodeString(nodeValue);
+ String lastWord = ""; //Used for calculating
pair counts
- //Iterate through all words
- Iterator<String> wordIter = wordSet.iterator();
- while(wordIter.hasNext())
- {
- String curWord = wordIter.next();
+ //Iterate through all words
+ Iterator<String> wordIter = wordSet.iterator();
+ while(wordIter.hasNext())
+ {
+ String curWord = wordIter.next();
- //Check filters
- WordFilter filter = networkParams.getFilter();
- if (!filter.contains(curWord))
- {
- //Add to selected Counts
+ //Check filters
+ WordFilter filter =
networkParams.getFilter();
+ if (!filter.contains(curWord))
+ {
+ //Add to selected Counts
- Integer curCount = 0;
+ Integer curCount = 0;
- if (selectedCounts.containsKey(curWord))
- curCount =
selectedCounts.get(curWord);
+ if
(selectedCounts.containsKey(curWord))
+ curCount =
selectedCounts.get(curWord);
- //Update Count
- curCount = curCount + 1;
+ //Update Count
+ curCount = curCount + 1;
- //Add updated count to HashMap
- selectedCounts.put(curWord, curCount);
+ //Add updated count to HashMap
+ selectedCounts.put(curWord,
curCount);
- //Add to pair counts
- if (!lastWord.equals(""))
- {
- Integer curPairCount = 0;
- String pairName = lastWord + "
" + curWord;
+ //Add to pair counts
+ if (!lastWord.equals(""))
+ {
+ Integer curPairCount =
0;
+ String pairName =
lastWord + " " + curWord;
- if
(selectedPairCounts.containsKey(pairName))
- curPairCount =
selectedPairCounts.get(pairName);
+ if
(selectedPairCounts.containsKey(pairName))
+ curPairCount =
selectedPairCounts.get(pairName);
- curPairCount = curPairCount + 1;
-
selectedPairCounts.put(pairName, curPairCount);
- }
+ curPairCount =
curPairCount + 1;
+
selectedPairCounts.put(pairName, curPairCount);
+ }
- //Update curWord to be LastWord
- lastWord = curWord;
+ //Update curWord to be LastWord
+ lastWord = curWord;
- }//end filter if
- }// word iterator
+ }//end filter if
+ }// word iterator
+ }// end attribute list
}//end node iterator
- selectedNumNodes = selectedNodes.size();
+ //selectedNumNodes = selectedNodes.size();
+ selectedNumNodes = selectedNodes.size() * attributeNames.size();
+
calculateWeights();
selInitialized = true;
@@ -595,6 +625,8 @@
pairRatios.put(curWord, ratio);
}
+
+ this.createFiles();
ratiosInitialized = true;
}
@@ -730,17 +762,37 @@
//Attribute
- Object attribute =
inputPanel.getCMBAttributes().getSelectedItem();
- if (attribute instanceof String)
- setAttributeName((String) attribute);
- else
+ //Object attribute =
inputPanel.getCMBAttributes().getSelectedItem();
+ Object[] attributes =
inputPanel.getAttributeList().getSelectedValues();
+ ArrayList<String> attributeList = new ArrayList<String>();
+
+ for (int i = 0; i < attributes.length; i++)
{
- setAttributeName(defaultAttName);
-
inputPanel.getCMBAttributes().setSelectedItem(attributeName);
- String message = "You must select a valid String
attribute or use the node ID.";
- JOptionPane.showMessageDialog(Cytoscape.getDesktop(),
message, "Parameter out of bounds", JOptionPane.WARNING_MESSAGE);
+ Object curAttribute = attributes[i];
+
+ if (curAttribute instanceof String)
+ {
+ attributeList.add((String) curAttribute);
+ //setAttributeName((String) attribute);
+ }
+ /*
+ else
+ {
+ //setAttributeName(defaultAttName);
+
//inputPanel.getCMBAttributes().setSelectedItem(attributeName);
+
+ ArrayList<String> attributeList = new
ArrayList<String>();
+ attributeList.add(defaultAttName);
+ this.setAttributeNames(attributeList);
+
//inputPanel.getCMBAttributes().setSelectedItem(defaultAttName);
+
inputPanel.getAttributeList().setSelectedIndex(0);
+ String message = "You must select a valid
String attribute or use the node ID.";
+
JOptionPane.showMessageDialog(Cytoscape.getDesktop(), message, "Parameter out
of bounds", JOptionPane.WARNING_MESSAGE);
+ }
+ */
+ this.setAttributeNames(attributeList);
}
-
+
//Max Words
JFormattedTextField maxWordsTextField =
inputPanel.getMaxWordsTextField();
@@ -796,7 +848,7 @@
StringBuffer paramVariables = new StringBuffer();
paramVariables.append("CloudName\t" + cloudName + "\n");
- paramVariables.append("AttributeName\t" + attributeName + "\n");
+ //paramVariables.append("AttributeName\t" + attributeName +
"\n");
paramVariables.append("DisplayStyle\t" + displayStyle + "\n");
//List of Nodes as a comma delimited list
@@ -805,9 +857,17 @@
{
output.append((selectedNodes.get(i)).toString() +
NODEDELIMITER);
}
-
paramVariables.append("SelectedNodes\t" + output.toString() +
"\n");
+
+ //List of attributes as a delimited list
+ output = new StringBuffer();
+ for (int i = 0; i < attributeNames.size(); i++)
+ {
+ output.append(attributeNames.get(i) + WORDDELIMITER);
+ }
+ paramVariables.append("AttributeName\t" + output.toString() +
"\n");
+
paramVariables.append("NetworkNumNodes\t" + networkNumNodes +
"\n");
paramVariables.append("SelectedNumNodes\t" + selectedNumNodes +
"\n");
paramVariables.append("NetWeightFactor\t" + netWeightFactor +
"\n");
@@ -946,8 +1006,74 @@
* This method takes in the ID of a node and returns the string that is
associated
* with that node and the current attribute of this CloudParameters.
* @param CyNode - node we are interested in
+ * @param String - name of the attribute we are interested in
* @return String - value stored in the current attribute for the given
node.
*/
+ private String getNodeAttributeVal(CyNode curNode, String attributeName)
+ {
+ //Retrieve value based on attribute
+ String nodeValue = "";
+
+ //if we should use the ID
+ if (attributeName.equals("nodeID"))
+ {
+ nodeValue = curNode.toString();
+ }
+
+ //Use a different attribute
+ else
+ {
+ CyAttributes cyNodeAttrs =
Cytoscape.getNodeAttributes();
+
+ if (cyNodeAttrs.getType(attributeName)==
CyAttributes.TYPE_STRING)
+ {
+ nodeValue =
cyNodeAttrs.getStringAttribute(curNode.getIdentifier(), attributeName);
+ }
+
+ else if (cyNodeAttrs.getType(attributeName) ==
CyAttributes.TYPE_SIMPLE_LIST)
+ {
+ List attribute =
cyNodeAttrs.getListAttribute(curNode.getIdentifier(), attributeName);
+
+ if (attribute == null)
+ return null;
+
+ else
+ {
+ for (Iterator iter =
attribute.iterator(); iter.hasNext();)
+ {
+ Object curObj = iter.next();
+ if (curObj instanceof String)
+ {
+ //Turn list into space
separated string
+ String curObjString =
(String)curObj;
+ nodeValue = nodeValue +
curObjString + " ";
+ }//
+ }
+ }
+ }
+ else
+ {
+ //Don't currently handle non string attributes
+ //This code should currently never be accessed
+ Component desktop = Cytoscape.getDesktop();
+
+ JOptionPane.showMessageDialog(desktop,
+ "Current implementation does not handle
non-String attributes.");
+ return null;
+ }//end else
+ }//end else
+
+ return nodeValue;
+ }//end method
+
+
+ /**
+ * This method takes in the ID of a node and returns the string that is
associated
+ * with that node and the current attribute of this CloudParameters.
+ * @param CyNode - node we are interested in
+ * @return String - value stored in the current attribute for the given
node.
+ */
+ /*
private String getNodeAttributeVal(CyNode curNode)
{
//Retrieve value based on attribute
@@ -1004,6 +1130,7 @@
return nodeValue;
}//end method
+ */
/**
* This method takes in a string from a node and processes it to lower
case, removes
@@ -1076,7 +1203,7 @@
cloudName = name;
}
-
+ /*
public String getAttributeName()
{
return attributeName;
@@ -1095,7 +1222,58 @@
attributeName = name;
}
+ */
+ public ArrayList<String> getAttributeNames()
+ {
+ return attributeNames;
+ }
+
+ public void setAttributeNames(ArrayList<String> names)
+ {
+ //Check if we need to reset flags
+ Boolean changed = false;
+ if (names.size() != attributeNames.size())
+ changed = true;
+ else
+ {
+ for (int i = 0; i < names.size(); i++)
+ {
+ String curAttribute = names.get(i);
+
+ if (!attributeNames.contains(curAttribute))
+ {
+ changed = true;
+ continue;
+ }
+ }
+ }
+
+ //Set flags
+ if (changed)
+ {
+ countInitialized = false;
+ selInitialized = false;
+ ratiosInitialized = false;
+ }
+
+ //Set to new value
+ attributeNames = names;
+ }
+
+ public void addAttributeName(String name)
+ {
+ if (!attributeNames.contains(name))
+ {
+ attributeNames.add(name);
+ countInitialized = false;
+ selInitialized = false;
+ ratiosInitialized = false;
+ }
+ }
+
+
+
public SemanticSummaryParameters getNetworkParams()
{
return networkParams;
@@ -1405,4 +1583,88 @@
useNetNormal = val;
}
+ //Testing code
+ public void createFiles()
+ {
+ try
+ {
+ PrintWriter out = new PrintWriter(new
FileWriter("C:\\Users\\Layla\\Desktop\\nodes_ratios.txt"));
+
+ Set<String> wordList = ratios.keySet();
+ for(Iterator<String> iter = wordList.iterator();
iter.hasNext();)
+ {
+ String curWord = iter.next();
+ Double curRatio = ratios.get(curWord);
+ out.println(curWord + " " + curRatio);
+ }
+ out.close();
+ }
+ catch (Exception e)
+ {
+ //DO Nothing
+ }
+
+ try
+ {
+ PrintWriter out = new PrintWriter(new
FileWriter("C:\\Users\\Layla\\Desktop\\nodes_counts.txt"));
+
+ Set<String> wordList = selectedCounts.keySet();
+ for(Iterator<String> iter = wordList.iterator();
iter.hasNext();)
+ {
+ String curWord = iter.next();
+ Integer curCount = selectedCounts.get(curWord);
+ out.println(curWord + " " + curCount);
+ }
+ out.close();
+ }
+ catch (Exception e)
+ {
+ //DO Nothing
+ }
+
+ try
+ {
+ PrintWriter out = new PrintWriter(new
FileWriter("C:\\Users\\Layla\\Desktop\\edges_ratios.txt"));
+
+ Set<String> wordList = pairRatios.keySet();
+ for(Iterator<String> iter = wordList.iterator();
iter.hasNext();)
+ {
+ String curWord = iter.next();
+ Double curRatio = pairRatios.get(curWord);
+
+ String[] words = curWord.split(" ");
+ Double firstRatio = ratios.get(words[0]);
+ Double secondRatio = ratios.get(words[1]);
+
+ //Double condRatio = curRatio * firstRatio /
secondRatio;
+ Double condRatio = curRatio /( firstRatio *
secondRatio);
+
+ out.println(curWord + " " + condRatio);
+ }
+ out.close();
+ }
+ catch (Exception e)
+ {
+ //DO Nothing
+ }
+
+ try
+ {
+ PrintWriter out = new PrintWriter(new
FileWriter("C:\\Users\\Layla\\Desktop\\edges_counts.txt"));
+
+ Set<String> wordList = selectedPairCounts.keySet();
+ for(Iterator<String> iter = wordList.iterator();
iter.hasNext();)
+ {
+ String curWord = iter.next();
+ Integer curCount =
selectedPairCounts.get(curWord);
+ out.println(curWord + " " + curCount);
+ }
+ out.close();
+ }
+ catch (Exception e)
+ {
+ //DO Nothing
+ }
+ }
+
}
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CreateCloudAction.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CreateCloudAction.java
2010-08-03 19:21:39 UTC (rev 21144)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CreateCloudAction.java
2010-08-03 19:46:58 UTC (rev 21145)
@@ -115,7 +115,8 @@
cloudParams.setCloudNum(params.getCloudCount());
cloudParams.setCloudName(params.getNextCloudName());
cloudParams.setNetworkParams(params);
- cloudParams.setNetworkNumNodes(network.getNodeCount());
+ //cloudParams.setNetworkNumNodes(network.getNodeCount());
+ cloudParams.setNetworkNumNodes(network.getNodeCount() *
cloudParams.getAttributeNames().size());
//Get list of node ID's
Set<CyNode> nodes = network.getSelectedNodes();
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
2010-08-03 19:21:39 UTC (rev 21144)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
2010-08-03 19:46:58 UTC (rev 21145)
@@ -34,6 +34,8 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DecimalFormat;
@@ -55,9 +57,11 @@
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
+import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ChangeListener;
@@ -65,6 +69,7 @@
import cytoscape.Cytoscape;
import cytoscape.data.CyAttributes;
+import cytoscape.util.swing.CheckBoxJList;
/**
* The SemanticSummaryInputPanel class defines the panel that appears for
@@ -91,7 +96,6 @@
private JTextField addWordTextField;
//JComboBox
- private JComboBox cmbAttributes;
private JComboBox cmbRemoval;
private JComboBox cmbStyle;
private JComboBox cmbDelimiterRemoval;
@@ -118,6 +122,10 @@
//SliderBar
private SliderBarPanel sliderPanel;
+ //Checkbox list
+ private CheckBoxJList attributeList;
+ private JPopupMenu attributeSelectionPopupMenu;
+
//String Constants for Separators in remove word combo box
private static final String addedSeparator = "--Added Words--";
private static final String flaggedSeparator = "--Flagged Words--";
@@ -290,15 +298,30 @@
JPanel attributePanel = new JPanel();
attributePanel.setLayout(new GridBagLayout());
- //JLabel nodeAttributeLabel = new JLabel("Node ID/Attribute: ");
-
- WidestStringComboBoxModel wscbm = new
WidestStringComboBoxModel();
- cmbAttributes = new JComboBox(wscbm);
- cmbAttributes.addPopupMenuListener(new
WidestStringComboBoxPopupMenuListener());
- cmbAttributes.setEditable(false);
- Dimension d = cmbAttributes.getPreferredSize();
- cmbAttributes.setPreferredSize(new Dimension(15, d.height));
- cmbAttributes.setToolTipText("Define which node value to use for
semantic analysis");
+ //Testing of stuff
+ attributeList = new CheckBoxJList();
+ DefaultListModel model = new DefaultListModel();
+ attributeList.setModel(model);
+ model.addElement("test1");
+ model.addElement("test2");
+ JScrollPane scrollPane = new JScrollPane();
+ scrollPane.setPreferredSize(new Dimension(300, 200));
+ scrollPane.setViewportView(attributeList);
+
+
+ attributeSelectionPopupMenu = new JPopupMenu();
+ attributeSelectionPopupMenu.add(scrollPane);
+
+ JButton attributeButton = new JButton("Select Attributes");
+ attributeButton.setToolTipText("Define which nodes values to use
for semantic analysis");
+ attributeButton.addMouseListener(new MouseAdapter()
+ {
+ public void mouseClicked(MouseEvent e)
+ {
+ attributeSelectionPopupMenu.show(e.getComponent(),
0,e.getComponent().getPreferredSize().height);
+ }
+ }
+ );
GridBagConstraints gridBagConstraints = new
GridBagConstraints();
@@ -315,8 +338,7 @@
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new Insets(5, 0, 0, 0);
- attributePanel.add(cmbAttributes, gridBagConstraints);
-
+ attributePanel.add(attributeButton, gridBagConstraints);
refreshAttributeCMB();
@@ -810,8 +832,7 @@
*/
public void loadCurrentCloud(CloudParameters params)
{
- //sliderPanel.setNetNormValue(params.getNetWeightFactor());
- cmbAttributes.setSelectedItem(params.getAttributeName());
+ attributeList.setSelectedItems(params.getAttributeNames());
maxWordsTextField.setValue(params.getMaxWords());
clusterCutoffTextField.setValue(params.getClusterCutoff());
cmbStyle.setSelectedItem(params.getDisplayStyle());
@@ -871,7 +892,7 @@
{
CloudParameters params =
SemanticSummaryManager.getInstance().getCurCloud();
- cmbAttributes.setSelectedItem(params.getDefaultAttName());
+ attributeList.setSelectedIndex(0);
maxWordsTextField.setValue(params.getDefaultMaxWords());
clusterCutoffTextField.setValue(params.getDefaultClusterCutoff());
cmbStyle.setSelectedItem(params.getDefaultDisplayStyle());
@@ -1072,19 +1093,18 @@
*/
private void updateCMBAttributes()
{
- DefaultComboBoxModel cmb;
-
- cmb = ((DefaultComboBoxModel)cmbAttributes.getModel());
- cmb.removeAllElements();
- cmb.addElement(SemanticSummaryManager.getInstance().
+ //Updated GUI
+ DefaultListModel listModel;
+ listModel = ((DefaultListModel)attributeList.getModel());
+ listModel.removeAllElements();
+ listModel.addElement(SemanticSummaryManager.getInstance().
getNullCloudParameters().getDefaultAttName());
- Vector<Object>av;
- av = getCyAttributesList("node");
+ Vector<Object> av = getCyAttributesList("node");
for (int i=0; i < av.size(); i++)
{
- cmb.addElement(av.elementAt(i));
+ listModel.addElement(av.elementAt(i));
}
}
@@ -1096,14 +1116,17 @@
{
updateCMBAttributes();
CloudParameters curCloud =
SemanticSummaryManager.getInstance().getCurCloud();
- String curAttribute;
+
+ //Updated GUI
+ ArrayList<String> curAttList;
if (curCloud ==
SemanticSummaryManager.getInstance().getNullCloudParameters())
- curAttribute = curCloud.getDefaultAttName();
+ curAttList = curCloud.getAttributeNames();
else
- curAttribute = curCloud.getAttributeName();
+ //curAttribute = curCloud.getAttributeName();
+ curAttList = curCloud.getAttributeNames();
- cmbAttributes.setSelectedItem(curAttribute);
- cmbAttributes.repaint();
+ attributeList.setSelectedItems(curAttList);
+ attributeList.repaint();
}
/**
@@ -1510,10 +1533,6 @@
return cloudList;
}
- public JComboBox getCMBAttributes()
- {
- return cmbAttributes;
- }
public JComboBox getCMBRemoval()
{
@@ -1571,7 +1590,17 @@
return sliderPanel;
}
+ public CheckBoxJList getAttributeList()
+ {
+ return attributeList;
+ }
+ public JPopupMenu getAttributePopupMenu()
+ {
+ return attributeSelectionPopupMenu;
+ }
+
+
/**
* Private Class to ensure that text fields are being set properly
*/
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SingleWordCluster.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SingleWordCluster.java
2010-08-03 19:21:39 UTC (rev 21144)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SingleWordCluster.java
2010-08-03 19:46:58 UTC (rev 21145)
@@ -23,6 +23,7 @@
package cytoscape.csplugins.semanticsummary;
import java.util.ArrayList;
+import java.util.Iterator;
/**
* The SingleWordCluster class contains information about a single set of
@@ -122,12 +123,51 @@
}
+ /**
+ * Calculates the largest value for font size in cluster.
+ */
+ public Integer getLargestFont()
+ {
+ Integer largest = 0;
+ for (Iterator<String> iter = wordList.iterator();
iter.hasNext();)
+ {
+ String curWord = iter.next();
+ Integer curSize = params.calculateFontSize(curWord);
+ if (largest < curSize)
+ {
+ largest = curSize;
+ }
+ }
+ return largest;
+ }
/**
+ * Calculates a weighted sum for all words.
+ */
+ public Double calculateWeightedSum()
+ {
+ Double sum = 0.0;
+ Double k = 2.0;
+ for (Iterator<String> iter = wordList.iterator();
iter.hasNext();)
+ {
+ String curWord = iter.next();
+ Integer curSize = params.calculateFontSize(curWord);
+
+ sum = sum + Math.pow(curSize, k);
+ }
+ //Take kth Root
+ sum = Math.pow(sum, 1/k);
+
+ return sum;
+ }
+
+
+ /**
* Compares two SingleWordClusters based on the totalSum of the font
sizes,
* and then breaks ties based upon alphabetical sorting of the words
* in the list.
*/
+ /*
public int compareTo(SingleWordCluster o)
{
//Integer thisCount = this.getTotalSum();
@@ -149,7 +189,66 @@
return thisWord.compareTo(compareWord);
}
}
+ */
+ /**
+ * Largest word first, then total, then alphabetical
+ */
+ /*
+ public int compareTo(SingleWordCluster o)
+ {
+ Integer thisLargest = this.getLargestFont();
+ Integer compareLargest = o.getLargestFont();
+
+ if (thisLargest < compareLargest)
+ {return -1;}
+ else if (thisLargest > compareLargest)
+ {return 1;}
+ else
+ {
+ //In case of ties, break by total
+ Integer thisCount = this.getTotalSum();
+ Integer compareCount = o.getTotalSum();
+
+ if (thisCount < compareCount)
+ {return -1;}
+ else if (thisCount > compareCount)
+ {return 1;}
+ else
+ {
+
+ //In case of ties, break alphabetically by
first word
+ String thisWord = this.getWordList().get(0);
+ String compareWord = this.getWordList().get(0);
+
+ return thisWord.compareTo(compareWord);
+ }
+ }
+ }
+ */
+ //Weighted sum
+ public int compareTo(SingleWordCluster o)
+ {
+ //Integer thisCount = this.getTotalSum();
+ //Integer compareCount = o.getTotalSum();
+
+ Double thisCount = this.calculateWeightedSum();
+ Double compareCount = o.calculateWeightedSum();
+
+ if (thisCount < compareCount)
+ {return -1;}
+ else if (thisCount > compareCount)
+ {return 1;}
+ else
+ {
+ //In case of ties, break alphabetically by first word
+ String thisWord = this.getWordList().get(0);
+ String compareWord = this.getWordList().get(0);
+
+ return thisWord.compareTo(compareWord);
+ }
+ }
+
//Getters and Setters
public ArrayList<String> getWordList()
--
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.