Author: laylaoesper
Date: 2010-07-30 09:39:32 -0700 (Fri, 30 Jul 2010)
New Revision: 21085
Modified:
csplugins/trunk/soc/layla/SemanticSummary/build.xml
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/SemanticSummaryPlugin.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/CloudParametersUnitTest.java
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/SemanticSummaryClusterBuilderUnitTest.java
Log:
Add comments to build file, fix JUnit tests for new wordSize computations.
Also, fix name of checkbox to use network normalization.
Modified: csplugins/trunk/soc/layla/SemanticSummary/build.xml
===================================================================
--- csplugins/trunk/soc/layla/SemanticSummary/build.xml 2010-07-29 23:25:35 UTC
(rev 21084)
+++ csplugins/trunk/soc/layla/SemanticSummary/build.xml 2010-07-30 16:39:32 UTC
(rev 21085)
@@ -20,6 +20,24 @@
<!-- Contains all external documentation -->
<property name="doc.dir" value="${basedir}/doc"/>
+ <!--
+ **********************************
+ * TO DEFINE PATH TO CYTOSCAPE: *
+ **********************************
+ -Ensure to set the value for property name ="cytoscape.dir" to the
location
+ of cytoscape on the computer which is compiling this plugin. The
cytoscape jars
+ are required for the compilation of the WordCloud plugin.
+
+ EXAMPLES:
+
+ Apple:
+ <property name="cytoscape.dir"
value="/Applications/Cytoscape_v2.7.0"/>
+ Linux:
+ <property name="cytoscape.dir"
value="/usr/local/Cytoscape_v2.7.0"/>
+ Windows:
+ <property name="cytoscape.dir" value="C:/Program
Files/Cytoscape-v2.7.0"/>
+ -->
+
<!-- Define the Cytoscape directories -->
<property name="cytoscape.dir" value="C:/Program
Files/Cytoscape_v2.7.0"/>
<property name="cytoscape.lib.dir" value="${cytoscape.dir}/lib"/>
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-07-29 23:25:35 UTC (rev 21084)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
2010-07-30 16:39:32 UTC (rev 21085)
@@ -23,6 +23,9 @@
package cytoscape.csplugins.semanticsummary;
import java.awt.Component;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -592,42 +595,14 @@
pairRatios.put(curWord, ratio);
}
-
+
ratiosInitialized = true;
}
/**
- * Calculates the proper font size for words in the selected nodes.
- */
- //Comment out for now, while I create a new method
- /*
- public void calculateFontSizes()
- {
- if (!ratiosInitialized)
- this.updateRatios();
-
- //Clear old fonts
- this.cloudWords = new ArrayList<CloudWordInfo>();
-
- Set<String> words = ratios.keySet();
- Iterator<String> iter = words.iterator();
- while(iter.hasNext())
- {
- String curWord = (String)iter.next();
- Integer fontSize = calculateFontSize(curWord);
- CloudWordInfo curInfo = new CloudWordInfo(curWord,
fontSize);
- curInfo.setCloudParameters(this);
- cloudWords.add(curInfo);
- }//end while loop
-
- //Sort cloudWords in reverse order by fontsize
- Collections.sort(cloudWords);
- Collections.reverse(cloudWords);
- }
- */
- /**
* Creates a cloud clustering object and clusters based on the parameter
* in this CloudParameters.
+ * @throws
*/
public void calculateFontSizes()
{
@@ -678,38 +653,7 @@
return 0;
Double ratio = ratios.get(aWord);
-
-
- /* Weighted, minimum value
- Double newRatio = ratio * meanWeight / meanRatio;
-
- //Weighted Average
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return (minFont + (maxFont - minFont)/2);
-
- Double slope = (maxFont - minFont)/(maxWeight - minWeight);
- Double yIntercept = maxFont - (slope*maxWeight); //maxRatio
maps to maxFont
-
- //Round up to nearest Integer
- //Double temp = Math.ceil((slope*newRatio) + yIntercept);
- long temp = Math.round((slope*newRatio) + yIntercept);
-
- //Integer fontSize = temp.intValue();
- Integer fontSize = Math.round(temp);
-
- if (fontSize < 12)
- {
- fontSize = 12;
- }
- */
-
-
-
-
+
//Zeroed mapping
//Get zeroed values for calculations
Double zeroedMinWeight = minWeight - minWeight;
@@ -742,8 +686,6 @@
//Integer fontSize = temp.intValue();
Integer fontSize = Math.round(temp);
-
-
/*
//Original
//Map the interval minRatio to maxRatio to the new interval
@@ -766,214 +708,6 @@
Integer fontSize = Math.round(temp);
*/
- /*
- //Average constant
- //Map the interval minRatio to maxRatio to the new interval
- //minFont to maxFont using a linear transformation
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return (minFont + (maxFont - minFont)/2);
-
- Double slope = (meanFont - minFont)/(meanRatio - minRatio);
- Double yIntercept = meanFont - (slope*meanRatio); //maxRatio
maps to maxFont
-
- //Round up to nearest Integer
- //Double temp = Math.ceil((slope*ratio) + yIntercept);
- long temp = Math.round((slope*ratio) + yIntercept);
-
- //Integer fontSize = temp.intValue();
- Integer fontSize = Math.round(temp);
- */
-
- /*
- * Parabola
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return (minFont + (maxFont - minFont)/2);
-
- Double temp = 0.0;
- temp = minFont * (ratio - meanRatio) * (ratio -
maxRatio)/((minRatio - meanRatio) * (minRatio - maxRatio));
- temp += meanFont * (ratio - minRatio) * (ratio -
maxRatio)/((meanRatio - minRatio) * (meanRatio - maxRatio));
- temp += maxFont * (ratio - minRatio) * (ratio -
meanRatio)/((maxRatio - minRatio) * (maxRatio - meanRatio));
-
- long roundedTemp = Math.round(temp);
- Integer fontSize = Math.round(roundedTemp);
- */
-
- /*
- * Use mean - both directions
- //Map the interval minRatio to meanRatio to the new interval
- //minFont to meanFont using a linear transformation
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return meanFont;
-
- Double lowerSlope = (meanFont - minFont)/(meanRatio - minRatio);
- Double lowerYIntercept = meanFont - (lowerSlope*meanRatio);
//maxRatio maps to maxFont
-
- Double higherSlope = (maxFont - meanFont)/(maxRatio -
meanRatio);
- Double higherYIntercept = maxFont - (higherSlope*maxRatio);
-
- long temp = 0;
- if (ratio < meanRatio)
- {
- temp = Math.round((lowerSlope*ratio) + lowerYIntercept);
- }
- else
- {
- temp = Math.round((higherSlope*ratio) +
higherYIntercept);
- }
-
- //Integer fontSize = temp.intValue();
- Integer fontSize = Math.round(temp);
- */
-
- /*
- * Logrithmic
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return meanFont;
-
- Double weight = (Math.log(ratio) -
Math.log(minRatio))/(Math.log(maxRatio) - Math.log(minRatio));
- long temp = minFont + Math.round((maxFont - minFont)*weight);
- Integer fontSize = Math.round(temp);
- */
-
- /*
- * Use Median rather than mean
- //Map the interval minRatio to meanRatio to the new interval
- //minFont to meanFont using a linear transformation
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Find median of the ratios
- ArrayList<Double> listRatios = new ArrayList<Double>();
- Set<String> wordsForRatio = ratios.keySet();
- for(Iterator<String> iter = wordsForRatio.iterator();
iter.hasNext();)
- {
- String curWord = iter.next();
- Double curRatio = ratios.get(curWord);
- listRatios.add(curRatio);
- }
-
- Collections.sort(listRatios);
- int size = listRatios.size();
- int median = size/2;
-
- Double medianRatio = listRatios.get(median);
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return meanFont;
-
- Double lowerSlope = (meanFont - minFont)/(medianRatio -
minRatio);
- Double lowerYIntercept = meanFont - (lowerSlope*medianRatio);
//maxRatio maps to maxFont
-
- Double higherSlope = (maxFont - meanFont)/(maxRatio -
medianRatio);
- Double higherYIntercept = maxFont - (higherSlope*maxRatio);
-
- long temp = 0;
- if (ratio < medianRatio)
- {
- temp = Math.round((lowerSlope*ratio) + lowerYIntercept);
- }
- else
- {
- temp = Math.round((higherSlope*ratio) +
higherYIntercept);
- }
-
- //Integer fontSize = temp.intValue();
- Integer fontSize = Math.round(temp);
- */
-
-
- /*// Mean Logrithmic
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return meanFont;
-
- Double weight = (Math.log(ratio) -
Math.log(minRatio))/(Math.log(meanRatio) - Math.log(minRatio));
- long temp = minFont + Math.round((meanFont - minFont)*weight);
- Integer fontSize = Math.round(temp);
- */
-
- /*
- // Two directional Mean Logrithmic
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return meanFont;
-
- long temp = 0;
- if (ratio < meanRatio)
- {
- Double lowerWeight = (Math.log(ratio) -
Math.log(minRatio))/(Math.log(meanRatio) - Math.log(minRatio));
- temp = minFont + Math.round((meanFont -
minFont)*lowerWeight);
- }
- else
- {
- Double upperWeight = (Math.log(ratio) -
Math.log(meanRatio))/(Math.log(maxRatio) - Math.log(meanRatio));
- temp = meanFont + Math.round((maxFont -
meanFont)*upperWeight);
- }
-
- Integer fontSize = Math.round(temp);
- */
-
- /*
- //Double logistic function
- // Two directional Mean Logrithmic
- Integer maxFont = networkParams.getMaxFont();
- Integer minFont = networkParams.getMinFont();
- Integer meanFont = minFont + (maxFont - minFont)/2;
-
- //Check if maxRatio and minRatio are the same
- if (maxRatio.equals(minRatio))
- return meanFont;
-
- double sgnTemp = ratio - meanRatio;
- int sgn = 0;
- if (sgnTemp > 0)
- {
- sgn = 1;
- }
- else
- {
- sgn = -1;
- }
-
- int steep = 1;
-
- Double inside = Math.pow((ratio - meanRatio)/steep, 2);
-
- Double doubleTemp = sgn * (1 - Math.exp(- inside));
- long longTemp = Math.round(doubleTemp);
- Integer fontSize = Math.round(longTemp);
- */
-
return fontSize;
}
@@ -1670,4 +1404,5 @@
{
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-29 23:25:35 UTC (rev 21084)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
2010-07-30 16:39:32 UTC (rev 21085)
@@ -388,7 +388,7 @@
netNormalizationPanel.setLayout(new GridBagLayout());
//Checkbox
- useNetworkCounts = new JCheckBox("Use word counts from entire
network");
+ useNetworkCounts = new JCheckBox("Normalize word size using
selection/network ratios");
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);
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
2010-07-29 23:25:35 UTC (rev 21084)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
2010-07-30 16:39:32 UTC (rev 21085)
@@ -455,6 +455,7 @@
}//end loop through all props files
+
//Set current network and Initialize the panel
appropriately
SemanticSummaryManager.getInstance().setupCurrentNetwork();
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/CloudParametersUnitTest.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/CloudParametersUnitTest.java
2010-07-29 23:25:35 UTC (rev 21084)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/CloudParametersUnitTest.java
2010-07-30 16:39:32 UTC (rev 21085)
@@ -263,6 +263,9 @@
assertFalse(cloudParams.getSelInitialized());
assertFalse(cloudParams.getRatiosInitialized());
+ //Change ratio to 0
+ cloudParams.setNetWeightFactor(0.0);
+
cloudParams.calculateFontSizes();
ArrayList<CloudWordInfo> cloudWords =
cloudParams.getCloudWordInfoList();
@@ -276,6 +279,22 @@
assertTrue(cloudParams.getCountInitialized());
assertTrue(cloudParams.getSelInitialized());
assertTrue(cloudParams.getRatiosInitialized());
+
+ //change ratio to 1
+ cloudParams.setNetWeightFactor(1.0);
+
+ //Test flags
+ assertTrue(cloudParams.getCountInitialized());
+ assertTrue(cloudParams.getSelInitialized());
+ assertFalse(cloudParams.getRatiosInitialized());
+
+ cloudParams.calculateFontSizes();
+ cloudWords = cloudParams.getCloudWordInfoList();
+
+ //Check that the last entriy has min size
+ assertEquals(cloudWords.get(cloudWords.size() -
1).getFontSize(),
+ new Integer(parentParams.getMinFont()));
+
}
}
Modified:
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/SemanticSummaryClusterBuilderUnitTest.java
===================================================================
---
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/SemanticSummaryClusterBuilderUnitTest.java
2010-07-29 23:25:35 UTC (rev 21084)
+++
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/test/SemanticSummaryClusterBuilderUnitTest.java
2010-07-30 16:39:32 UTC (rev 21085)
@@ -17,6 +17,7 @@
import cytoscape.csplugins.semanticsummary.CloudParameters;
import cytoscape.csplugins.semanticsummary.CloudWordInfo;
import cytoscape.csplugins.semanticsummary.SemanticSummaryClusterBuilder;
+import cytoscape.csplugins.semanticsummary.SemanticSummaryManager;
import cytoscape.csplugins.semanticsummary.SemanticSummaryParameters;
import cytoscape.csplugins.semanticsummary.SingleWordCluster;
import cytoscape.csplugins.semanticsummary.WordClusters;
@@ -137,7 +138,7 @@
String firstWord = first.getWord();
int firstCluster = first.getCluster();
Color firstColor = first.getTextColor();
- assertTrue(firstSize == 56);
+ assertTrue(firstSize ==
SemanticSummaryManager.getInstance().getNullSemanticSummary().getMaxFont());
assertTrue(firstWord.equals("regulation"));
assertTrue(firstCluster == 0);
assertTrue(firstColor.equals(Color.BLACK));
@@ -148,7 +149,7 @@
String lastWord = last.getWord();
int lastCluster = last.getCluster();
Color lastColor = last.getTextColor();
- assertTrue(lastFontSize == 12);
+ assertTrue(lastFontSize ==
SemanticSummaryManager.getInstance().getNullSemanticSummary().getMinFont());
assertTrue(lastWord.equals("death"));
assertTrue(lastCluster == 6);
assertTrue(lastColor.equals(Color.GRAY));
--
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.