Author: chinmoy
Date: 2009-08-05 16:24:20 -0700 (Wed, 05 Aug 2009)
New Revision: 17701
Added:
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/LevelColor.java
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyle.java
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyleManager.java
Log:
Added visual style classes and manager for phylogenetic trees
Added:
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/LevelColor.java
===================================================================
---
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/LevelColor.java
(rev 0)
+++
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/LevelColor.java
2009-08-05 23:24:20 UTC (rev 17701)
@@ -0,0 +1,110 @@
+package org.cytoscape.phylotree.visualstyle;
+
+import cytoscape.visual.VisualStyle;
+
+import cytoscape.CyNetwork;
+import cytoscape.visual.ArrowShape;
+import cytoscape.visual.EdgeAppearanceCalculator;
+import cytoscape.visual.GlobalAppearanceCalculator;
+import cytoscape.visual.NodeAppearanceCalculator;
+import cytoscape.visual.NodeShape;
+import cytoscape.visual.VisualPropertyType;
+import cytoscape.visual.calculators.BasicCalculator;
+import cytoscape.visual.calculators.Calculator;
+import cytoscape.visual.mappings.BoundaryRangeValues;
+import cytoscape.visual.mappings.ContinuousMapping;
+import cytoscape.visual.mappings.DiscreteMapping;
+import cytoscape.visual.mappings.Interpolator;
+import cytoscape.visual.mappings.LinearNumberToColorInterpolator;
+import cytoscape.visual.mappings.ObjectMapping;
+import cytoscape.visual.mappings.PassThroughMapping;
+import java.awt.Color;
+
+
+public class LevelColor implements PhyloVisualStyle {
+
+ public String getName()
+ {
+ return "LevelColor";
+ }
+
+ public VisualStyle createStyle(CyNetwork network)
+ {
+
+ NodeAppearanceCalculator nodeAppCalc = new
NodeAppearanceCalculator();
+ EdgeAppearanceCalculator edgeAppCalc = new
EdgeAppearanceCalculator();
+ GlobalAppearanceCalculator globalAppCalc = new
GlobalAppearanceCalculator();
+
+
+ // Passthrough Mapping - set node label
+ // PassThroughMapping pm = new PassThroughMapping(new String(),
"attr2");
+ PassThroughMapping pm = new PassThroughMapping(new String(),
"ID");
+ Calculator nlc = new BasicCalculator("Example Node Label
Calculator",pm, VisualPropertyType.NODE_LABEL);
+
+ nodeAppCalc.setCalculator(nlc);
+
+
+ // Discrete Mapping - set node shapes
+ DiscreteMapping disMapping = new DiscreteMapping(NodeShape.RECT,
+
ObjectMapping.NODE_MAPPING);
+ disMapping.setControllingAttributeName("ID", network, false);
+ disMapping.putMapValue(new Integer(1), NodeShape.DIAMOND);
+ disMapping.putMapValue(new Integer(2), NodeShape.ELLIPSE);
+ disMapping.putMapValue(new Integer(3), NodeShape.TRIANGLE);
+
+ Calculator shapeCalculator = new BasicCalculator("Example Node
Shape Calculator",
+
disMapping,VisualPropertyType.NODE_SHAPE);
+ nodeAppCalc.setCalculator(shapeCalculator);
+
+
+ // Continuous Mapping - set node color
+ ContinuousMapping continuousMapping = new
ContinuousMapping(Color.WHITE,
+
ObjectMapping.NODE_MAPPING);
+ continuousMapping.setControllingAttributeName("ID", network,
false);
+
+ Interpolator numToColor = new LinearNumberToColorInterpolator();
+ continuousMapping.setInterpolator(numToColor);
+
+ Color underColor = Color.GRAY;
+ Color minColor = Color.RED;
+ Color midColor = Color.WHITE;
+ Color maxColor = Color.GREEN;
+ Color overColor = Color.BLUE;
+
+ // Create boundary conditions less than,
equals, greater than
+ BoundaryRangeValues bv0 = new BoundaryRangeValues(underColor,
minColor, minColor);
+ BoundaryRangeValues bv1 = new BoundaryRangeValues(midColor,
midColor, midColor);
+ BoundaryRangeValues bv2 = new BoundaryRangeValues(maxColor,
maxColor, overColor);
+
+ // Set the attribute point values associated with the boundary values
+ continuousMapping.addPoint(0.0, bv0);
+ continuousMapping.addPoint(1.0, bv1);
+ continuousMapping.addPoint(2.0, bv2);
+
+ Calculator nodeColorCalculator = new BasicCalculator("Example
Node Color Calc",
+
continuousMapping,
+
VisualPropertyType.NODE_FILL_COLOR);
+ nodeAppCalc.setCalculator(nodeColorCalculator);
+
+
+ // Discrete Mapping - Set edge target arrow shape
+ DiscreteMapping arrowMapping = new
DiscreteMapping(ArrowShape.NONE,
+
ObjectMapping.EDGE_MAPPING);
+ arrowMapping.setControllingAttributeName("interaction",
network, false);
+ arrowMapping.putMapValue("pp", ArrowShape.ARROW);
+ arrowMapping.putMapValue("pd", ArrowShape.CIRCLE);
+
+ Calculator edgeArrowCalculator = new BasicCalculator("Example
Edge Arrow Shape Calculator",
+ arrowMapping,
VisualPropertyType.EDGE_TGTARROW_SHAPE);
+ edgeAppCalc.setCalculator(edgeArrowCalculator);
+
+
+ // Create the visual style
+ VisualStyle visualStyle = new VisualStyle("LevelColor",
nodeAppCalc, edgeAppCalc, globalAppCalc);
+
+ return visualStyle;
+ }
+
+
+
+}
Added:
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyle.java
===================================================================
---
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyle.java
(rev 0)
+++
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyle.java
2009-08-05 23:24:20 UTC (rev 17701)
@@ -0,0 +1,36 @@
+package org.cytoscape.phylotree.visualstyle;
+
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.view.CyNetworkView;
+import cytoscape.plugin.CytoscapePlugin;
+import cytoscape.visual.ArrowShape;
+import cytoscape.visual.CalculatorCatalog;
+import cytoscape.visual.EdgeAppearanceCalculator;
+import cytoscape.visual.GlobalAppearanceCalculator;
+import cytoscape.visual.NodeAppearanceCalculator;
+import cytoscape.visual.NodeShape;
+import cytoscape.visual.VisualMappingManager;
+import cytoscape.visual.VisualPropertyType;
+import cytoscape.visual.VisualStyle;
+import cytoscape.visual.calculators.BasicCalculator;
+import cytoscape.visual.calculators.Calculator;
+import cytoscape.visual.mappings.BoundaryRangeValues;
+import cytoscape.visual.mappings.ContinuousMapping;
+import cytoscape.visual.mappings.DiscreteMapping;
+import cytoscape.visual.mappings.Interpolator;
+import cytoscape.visual.mappings.LinearNumberToColorInterpolator;
+import cytoscape.visual.mappings.ObjectMapping;
+import cytoscape.visual.mappings.PassThroughMapping;
+import cytoscape.util.CytoscapeAction;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+
+
+public interface PhyloVisualStyle {
+
+ public String getName();
+ public VisualStyle createStyle(CyNetwork network);
+
+}
Added:
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyleManager.java
===================================================================
---
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyleManager.java
(rev 0)
+++
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/PhyloVisualStyleManager.java
2009-08-05 23:24:20 UTC (rev 17701)
@@ -0,0 +1,38 @@
+package org.cytoscape.phylotree.visualstyle;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.view.CyNetworkView;
+import cytoscape.visual.CalculatorCatalog;
+import cytoscape.visual.VisualMappingManager;
+import cytoscape.visual.VisualStyle;
+
+
+public class PhyloVisualStyleManager {
+
+ public void addVisualStyle(PhyloVisualStyle phyloVS)
+ {
+ // get the network and view
+ CyNetwork network = Cytoscape.getCurrentNetwork();
+ CyNetworkView networkView = Cytoscape.getCurrentNetworkView();
+
+ // get the VisualMappingManager and CalculatorCatalog
+ VisualMappingManager manager =
Cytoscape.getVisualMappingManager();
+ CalculatorCatalog catalog = manager.getCalculatorCatalog();
+
+ // check to see if a visual style with this name already exists
+ VisualStyle vs = catalog.getVisualStyle(phyloVS.getName());
+ if (vs == null) {
+ // if not, create it and add it to the catalog
+ vs = phyloVS.createStyle(network);
+ catalog.addVisualStyle(vs);
+ }
+
+ networkView.setVisualStyle(vs.getName()); // not strictly
necessary
+
+ // actually apply the visual style
+ manager.setVisualStyle(vs);
+ networkView.redrawGraph(true,true);
+ }
+
+}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---