Author: kono
Date: 2011-10-27 16:33:20 -0700 (Thu, 27 Oct 2011)
New Revision: 27321
Added:
csplugins/trunk/ucsd/kono/bingo3/lib/plugin-api-3.0.0-alpha8-SNAPSHOT-jar-with-dependencies.jar
Removed:
csplugins/trunk/ucsd/kono/bingo3/lib/Cytoscape3-api.jar
Modified:
csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java
csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/TheVisualStyle.java
Log:
Visual Style builder updated.
Deleted: csplugins/trunk/ucsd/kono/bingo3/lib/Cytoscape3-api.jar
===================================================================
(Binary files differ)
Added:
csplugins/trunk/ucsd/kono/bingo3/lib/plugin-api-3.0.0-alpha8-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Property changes on:
csplugins/trunk/ucsd/kono/bingo3/lib/plugin-api-3.0.0-alpha8-SNAPSHOT-jar-with-dependencies.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java
2011-10-27 23:24:39 UTC (rev 27320)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java
2011-10-27 23:33:20 UTC (rev 27321)
@@ -45,6 +45,7 @@
import java.util.Set;
import java.util.StringTokenizer;
+import javax.jws.soap.SOAPBinding.Style;
import javax.swing.JFrame;
import org.cytoscape.model.CyEdge;
@@ -58,10 +59,14 @@
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.CyNetworkViewFactory;
import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyle;
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskManager;
import org.cytoscape.work.TaskMonitor;
+import sun.management.VMManagement;
+
import BiNGO.ontology.Ontology;
/**
@@ -112,23 +117,22 @@
* scale for BigDecimal
*/
private static final int SCALE_RESULT = 100;
-
/**
* hasmap with key termID and value pvalue.
*/
private Map<Integer, String> testMap;
-
+
/**
* hasmap with key termID and value corrected pvalue.
*/
private Map correctionMap;
-
+
/**
* hashmap with key termID and value x.
*/
private Map mapSmallX;
-
+
/**
* hashmap with key termID and value n.
*/
@@ -157,10 +161,9 @@
* the ontology.
*/
private Ontology ontology;
-
+
private final CyPluginAdapter adapter;
-
/**
* Constructor for an overrepresentation visualization with correction.
*
@@ -186,12 +189,12 @@
* String with option what categories should be displayed.
*/
public DisplayBiNGOWindow(Map<Integer, String> testMap, Map
correctionMap, Map mapSmallX, Map mapSmallN,
- Map mapBigX, Map mapBigN, String alpha, Ontology
ontology, String clusterName,
- String categoriesString, final CyPluginAdapter adapter)
{
+ Map mapBigX, Map mapBigN, String alpha, Ontology
ontology, String clusterName, String categoriesString,
+ final CyPluginAdapter adapter) {
- if(adapter == null)
+ if (adapter == null)
throw new NullPointerException("Plugin Adapter is
null.");
-
+
this.adapter = adapter;
this.testMap = testMap;
this.correctionMap = correctionMap;
@@ -205,7 +208,6 @@
this.categoriesString = categoriesString;
}
-
/**
* Method that builds up the new CyNetwork and shows it to the user.
*/
@@ -213,66 +215,75 @@
// Create ontology DAG as CyNetwork
final CyNetwork network = buildNetwork();
adapter.getCyNetworkManager().addNetwork(network);
-
+
buildNodeAttributes(network);
buildEdgeAttributes(network);
-
-
+
// Create View
final TaskManager tm = adapter.getTaskManager();
tm.execute(new GenericTaskFactory(new CreateViewTask(network)));
-
-// final CyNetworkViewFactory viewFactory =
adapter.getCyNetworkViewFactory();
-// final CyNetworkView bingoCyNetworkView =
viewFactory.getNetworkView(network);
-//
-// // from MCODE plugin, MCODEResultsDialog class layout graph and
fit it to window
-// // randomize node positions before layout so that they don't
all layout in a line
-// // (so they don't fall into a local minimum for the
SpringEmbedder)
-// // If the SpringEmbedder implementation changes, this code may
need to
-// // be removed
-// final Collection<View<CyNode>> nodeViews =
bingoCyNetworkView.getNodeViews();
-// for (final View<CyNode> nv:nodeViews) {
-// nv.setXPosition(nv.getXPosition() * Math.random());
-// // height is small for many default drawn graphs, thus
+100
-// nv.setYPosition((nv.getYPosition() + 100) *
Math.random());
-// }
-//
-// // apply spring embedded layout...
-// SpringEmbeddedLayouter spring = new
SpringEmbeddedLayouter(bingoCyNetworkView);
-// // Configure JTask
-// JTaskConfig config = new JTaskConfig();
-//
-// // Show Cancel/Close Buttons
-// config.displayCancelButton(true);
-// config.displayStatus(true);
-//
-// // Execute Task via TaskManager
-// // This automatically pops-open a JTask Dialog Box.
-// // This method will block until the JTask Dialog Box is
disposed.
-// boolean success = TaskManager.executeTask(spring, config);
-// Cytoscape.getDesktop().toFront();
-// bingoCyNetworkView.fitContent();
-// // create visual style with ID dependent on clusterName
-// TheVisualStyle vs = new TheVisualStyle(clusterName, (new
Double(alpha)).doubleValue());
-// VisualStyle visualStyle = vs.createVisualStyle(network);
-// CytoscapeDesktop cytoscapedesktop = Cytoscape.getDesktop();
-// VisualMappingManager vmm = Cytoscape.getVisualMappingManager();
-// try {
-// vmm.getCalculatorCatalog().addVisualStyle(visualStyle);
-// // VisualStyle oldStyle =
vmm.setVisualStyle(visualStyle.getName());
-// bingoCyNetworkView.applyVizmapper(visualStyle);
-// //
bingoCyNetworkView.setVisualStyle(visualStyle.getName());
-// } catch (Exception e) {
-// JOptionPane.showMessageDialog(cytoscapedesktop,
-// "A visual style already exists for the
cluster name you specified." + "\n"
-// + "The existing style
will be overwritten.");
-//
vs.adaptVisualStyle(vmm.getCalculatorCatalog().getVisualStyle(visualStyle.getName()),
network);
-// // VisualStyle oldStyle =
vmm.setVisualStyle(visualStyle.getName());
-//
bingoCyNetworkView.applyVizmapper(vmm.getCalculatorCatalog().getVisualStyle(visualStyle.getName()));
-// //
bingoCyNetworkView.setVisualStyle(visualStyle.getName());
-// }
+ // final CyNetworkViewFactory viewFactory =
+ // adapter.getCyNetworkViewFactory();
+ // final CyNetworkView bingoCyNetworkView =
+ // viewFactory.getNetworkView(network);
+ //
+ // // from MCODE plugin, MCODEResultsDialog class layout graph
and fit
+ // it to window
+ // // randomize node positions before layout so that they don't
all
+ // layout in a line
+ // // (so they don't fall into a local minimum for the
SpringEmbedder)
+ // // If the SpringEmbedder implementation changes, this code
may need
+ // to
+ // // be removed
+ // final Collection<View<CyNode>> nodeViews =
+ // bingoCyNetworkView.getNodeViews();
+ // for (final View<CyNode> nv:nodeViews) {
+ // nv.setXPosition(nv.getXPosition() * Math.random());
+ // // height is small for many default drawn graphs, thus +100
+ // nv.setYPosition((nv.getYPosition() + 100) * Math.random());
+ // }
+ //
+ // // apply spring embedded layout...
+ // SpringEmbeddedLayouter spring = new
+ // SpringEmbeddedLayouter(bingoCyNetworkView);
+ // // Configure JTask
+ // JTaskConfig config = new JTaskConfig();
+ //
+ // // Show Cancel/Close Buttons
+ // config.displayCancelButton(true);
+ // config.displayStatus(true);
+ //
+ // // Execute Task via TaskManager
+ // // This automatically pops-open a JTask Dialog Box.
+ // // This method will block until the JTask Dialog Box is
disposed.
+ // boolean success = TaskManager.executeTask(spring, config);
+ // Cytoscape.getDesktop().toFront();
+ // bingoCyNetworkView.fitContent();
+ // // create visual style with ID dependent on clusterName
+ // TheVisualStyle vs = new TheVisualStyle(clusterName, (new
+ // Double(alpha)).doubleValue());
+ // VisualStyle visualStyle = vs.createVisualStyle(network);
+ // CytoscapeDesktop cytoscapedesktop = Cytoscape.getDesktop();
+ // VisualMappingManager vmm =
Cytoscape.getVisualMappingManager();
+ // try {
+ // vmm.getCalculatorCatalog().addVisualStyle(visualStyle);
+ // // VisualStyle oldStyle =
vmm.setVisualStyle(visualStyle.getName());
+ // bingoCyNetworkView.applyVizmapper(visualStyle);
+ // // bingoCyNetworkView.setVisualStyle(visualStyle.getName());
+ // } catch (Exception e) {
+ // JOptionPane.showMessageDialog(cytoscapedesktop,
+ // "A visual style already exists for the cluster name you
specified." +
+ // "\n"
+ // + "The existing style will be overwritten.");
+ //
vs.adaptVisualStyle(vmm.getCalculatorCatalog().getVisualStyle(visualStyle.getName()),
+ // network);
+ // // VisualStyle oldStyle =
vmm.setVisualStyle(visualStyle.getName());
+ //
bingoCyNetworkView.applyVizmapper(vmm.getCalculatorCatalog().getVisualStyle(visualStyle.getName()));
+ // // bingoCyNetworkView.setVisualStyle(visualStyle.getName());
+ // }
+
// add color scale panel
JFrame window = new JFrame(clusterName + " Color Scale");
String alpha1 = SignificantFigures.sci_format(alpha, 3);
@@ -290,10 +301,10 @@
window.setVisible(true);
window.setResizable(false);
}
-
+
private final class CreateViewTask extends AbstractTask {
private final CyNetwork network;
-
+
CreateViewTask(final CyNetwork network) {
this.network = network;
}
@@ -306,25 +317,52 @@
final CyNetworkViewFactory viewFactory =
adapter.getCyNetworkViewFactory();
final CyNetworkViewManager networkViewManager =
adapter.getCyNetworkViewManager();
- try {
- final CyNetworkView view =
viewFactory.getNetworkView(network, false);
- networkViewManager.addNetworkView(view);
-
- // Apply layout only when it is necessary.
- final CyLayoutAlgorithm layout =
adapter.getCyLayouts().getLayout("force-directed");
- layout.setNetworkView(view);
-
insertTasksAfterCurrentTask(layout.getTaskIterator());
-
- } catch (Exception e) {
- throw new Exception("Could not create network
view for network: "
- +
network.getCyRow().get(CyTableEntry.NAME, String.class), e);
- }
+
+ final CyNetworkView view =
viewFactory.getNetworkView(network, false);
+ networkViewManager.addNetworkView(view);
+
+ // Apply layout only when it is necessary.
+ final CyLayoutAlgorithm layout =
adapter.getCyLayouts().getLayout("force-directed");
+ layout.setNetworkView(view);
+ insertTasksAfterCurrentTask(layout.getTaskIterator());
+
+ System.out.println("====DONE#");
+ System.out.println("==========Create View START
=========: " + view);
+ TheVisualStyle vs = new TheVisualStyle(adapter,
clusterName, Double.parseDouble(alpha));
+ final VisualMappingManager vmm =
adapter.getVisualMappingManager();
+ final VisualStyle newStyle =
vs.createVisualStyle(view.getModel());
+
vmm.setVisualStyle(vs.createVisualStyle(view.getModel()), view);
+ newStyle.apply(view);
+ System.out.println("==========Create View Done!!");
+
+
taskMonitor.setProgress(1.0);
taskMonitor.setStatusMessage("Network view successfully
create for: "
+
network.getCyRow().get(CyTableEntry.NAME, String.class));
}
+
+ }
+
+ private final class ApplyStyleTask extends AbstractTask {
+
+ private final CyNetworkView view;
+ ApplyStyleTask(final CyNetworkView view) {
+ this.view = view;
+ }
+
+ @Override
+ public void run(TaskMonitor arg0) throws Exception {
+ System.out.println("==========Create View START
========= !!");
+ TheVisualStyle vs = new TheVisualStyle(adapter,
clusterName, Double.parseDouble(alpha));
+ final VisualMappingManager vmm =
adapter.getVisualMappingManager();
+ final VisualStyle newStyle =
vs.createVisualStyle(view.getModel());
+ vmm.setVisualStyle(newStyle, view);
+ newStyle.apply(view);
+ System.out.println("==========Create View Done!!");
+ }
+
}
/**
@@ -334,26 +372,28 @@
*/
public CyNetwork buildNetwork() {
final Set<Integer> set;
-
+
if (testMap != null)
set = new HashSet<Integer>(testMap.keySet());
else
set = new HashSet<Integer>(mapSmallX.keySet());
-
+
// put the edges in a set of Strings
final Set<String> sifSet = new HashSet<String>();
-
- // some GO labels might have multiple termIds, which need to be
canonicalized.
- // (for safety, has also been taken care of in
BiNGOOntologyFlatFilereader)
+
+ // some GO labels might have multiple termIds, which need to be
+ // canonicalized.
+ // (for safety, has also been taken care of in
+ // BiNGOOntologyFlatFilereader)
Map nameMap = new HashMap();
final CyNetworkFactory networkFactory =
adapter.getCyNetworkFactory();
final CyNetwork network = networkFactory.getInstance();
network.getCyRow().set(CyTableEntry.NAME, clusterName);
- //CyNetwork network = Cytoscape.createNetwork(clusterName);
+ // CyNetwork network = Cytoscape.createNetwork(clusterName);
- for(final Integer termID: set) {
-// final int termID = Integer.parseInt(value);
+ for (final Integer termID : set) {
+ // final int termID = Integer.parseInt(value);
// ifs for determining GO coverage of graphs.
if (categoriesString.equals(CATEGORY_ALL)
||
(categoriesString.equals(CATEGORY_BEFORE_CORRECTION) && new
BigDecimal(testMap.get(
@@ -387,14 +427,13 @@
// canonicalize nodes.
Map termIdMap = makeTermIdMap(nameMap);
-
// canonicalize edges and build network.
- Map<String, CyNode> nodeMap = new HashMap<String, CyNode>();
- for(final String writeString: sifSet) {
+ Map<String, CyNode> nodeMap = new HashMap<String, CyNode>();
+ for (final String writeString : sifSet) {
final StringTokenizer st = new
StringTokenizer(writeString);
final String firstTermId =
termIdMap.get(st.nextToken()).toString();
CyNode node1 = nodeMap.get(firstTermId);
- if(node1 == null) {
+ if (node1 == null) {
node1 = network.addNode();
node1.getCyRow().set(CyTableEntry.NAME,
firstTermId);
nodeMap.put(firstTermId, node1);
@@ -403,17 +442,17 @@
if (st.hasMoreTokens()) {
st.nextToken(); // Skip
final String secondTermId =
termIdMap.get(st.nextToken()).toString();
-
+
CyNode node2 = nodeMap.get(secondTermId);
- if(node2 == null) {
+ if (node2 == null) {
node2 = network.addNode();
node2.getCyRow().set(CyTableEntry.NAME,
secondTermId);
nodeMap.put(secondTermId, node2);
}
-
+
final CyEdge edge = network.addEdge(node1,
node2, true);
edge.getCyRow().set(CyEdge.INTERACTION, "pp");
- edge.getCyRow().set(CyTableEntry.NAME,
firstTermId +" (pp) " + secondTermId);
+ edge.getCyRow().set(CyTableEntry.NAME,
firstTermId + " (pp) " + secondTermId);
}
}
nodeMap.clear();
@@ -435,7 +474,7 @@
final Set<String> set = new HashSet<String>(nameMap.keySet());
final Map resultMap = new HashMap();
- for(final String val: set) {
+ for (final String val : set) {
// first substring null deleted at beginning of every
string
String valueIDs =
nameMap.get(val).toString().substring(5);
StringTokenizer st = new StringTokenizer(valueIDs);
@@ -452,11 +491,11 @@
* Method that creates the node attributes (size, color, ...).
*/
public void buildNodeAttributes(CyNetwork network) {
-
+
createNodeColumn(network);
-
+
final List<CyNode> nodeList = network.getNodeList();
- for(final CyNode node: nodeList) {
+ for (final CyNode node : nodeList) {
String termID = node.getCyRow().get(CyTableEntry.NAME,
String.class);
String shape;
String description;
@@ -536,7 +575,7 @@
} catch (Exception e) {
size = DEFAULT_SIZE;
}
-
+
node.getCyRow().set("pValue_" + clusterName, pValue);
node.getCyRow().set("adjustedPValue_" + clusterName,
adj_pValue);
node.getCyRow().set("x_" + clusterName, smallX);
@@ -550,14 +589,14 @@
node.getCyRow().set("nodeFontSize_" + clusterName, 14);
}
}
-
+
private void createNodeColumn(final CyNetwork network) {
final CyTable nodeTable = network.getDefaultNodeTable();
- for(final String colName: NODE_COL_NAMES) {
- if(nodeTable.getColumn(colName) == null) {
- if(colName.equals("nodeFillColor") ||
colName.equals("nodeSize"))
+ for (final String colName : NODE_COL_NAMES) {
+ if (nodeTable.getColumn(colName) == null) {
+ if (colName.equals("nodeFillColor") ||
colName.equals("nodeSize"))
nodeTable.createColumn(colName + "_" +
clusterName, Double.class, false);
- else if(colName.equals("nodeFontSize"))
+ else if (colName.equals("nodeFontSize"))
nodeTable.createColumn(colName + "_" +
clusterName, Integer.class, false);
else
nodeTable.createColumn(colName + "_" +
clusterName, String.class, false);
@@ -572,9 +611,9 @@
public void buildEdgeAttributes(final CyNetwork network) {
final CyTable edgeTable = network.getDefaultEdgeTable();
edgeTable.createColumn("edgeType_" + clusterName, String.class,
false);
-
+
final List<CyEdge> edgeList = network.getEdgeList();
- for(final CyEdge edge: edgeList)
+ for (final CyEdge edge : edgeList)
edge.getCyRow().set("edgeType_" + clusterName, "black");
}
}
Modified: csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/TheVisualStyle.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/TheVisualStyle.java
2011-10-27 23:24:39 UTC (rev 27320)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/TheVisualStyle.java
2011-10-27 23:33:20 UTC (rev 27321)
@@ -34,12 +34,24 @@
**/
import java.awt.Color;
+import java.awt.Paint;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import org.cytoscape.model.CyNetwork;
-import org.cytoscape.view.presentation.property.values.NodeShape;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.plugin.CyPluginAdapter;
+import org.cytoscape.view.presentation.property.LineTypeVisualProperty;
+import org.cytoscape.view.presentation.property.NodeShapeVisualProperty;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
+import org.cytoscape.view.vizmap.VisualMappingFunction;
+import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
import org.cytoscape.view.vizmap.mappings.BoundaryRangeValues;
import org.cytoscape.view.vizmap.mappings.ContinuousMapping;
+import org.cytoscape.view.vizmap.mappings.PassthroughMapping;
/**
* *****************************************************************
@@ -71,87 +83,75 @@
private final String NODE_LABEL;
private final String NODE_SIZE;
private final String EDGE_COLOR;
+
+ private final CyPluginAdapter adapter;
- public TheVisualStyle(final String networkName, double alpha) {
+ public TheVisualStyle(final CyPluginAdapter adapter, final String
networkName, double alpha) {
+ this.adapter = adapter;
this.networkName = networkName;
this.alpha = alpha;
this.bingoVSName = "BiNGO Style for " + networkName;
this.NODE_COLOR = "nodeFillColor_" + networkName;
this.NODE_LABEL = "description_" + networkName;
this.NODE_SIZE = "nodeSize_" + networkName;
- this.EDGE_COLOR = "edgeType_" + networkName;
+ this.EDGE_COLOR = "edgeType_" + networkName;
}
- public void adaptVisualStyle(VisualStyle style, CyNetwork network) {
-//
-// // Node default appearence definitions
-// style.getNodeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.NODE_SHAPE,
NodeShape.ELLIPSE);
+ public void adaptVisualStyle(final VisualStyle style, final CyNetwork
network) {
+
+ // Node default appearence definitions
+ style.setDefaultValue(RichVisualLexicon.NODE_SHAPE,
NodeShapeVisualProperty.ELLIPSE);
+ //FIXME
// style.getDependency().set(Definition.NODE_SIZE_LOCKED, true);
-// style.getNodeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.NODE_FONT_SIZE, 14);
-// style.getNodeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.NODE_LINE_WIDTH, 2);
-// style.getNodeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.NODE_BORDER_COLOR,
Color.DARK_GRAY);
-// style.getNodeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.NODE_OPACITY, 210);
-// style.getNodeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.NODE_BORDER_OPACITY, 120);
-//
-// // Edge default appearence definitions
+
+ style.setDefaultValue(RichVisualLexicon.NODE_LABEL_FONT_SIZE,
14);
+ style.setDefaultValue(RichVisualLexicon.NODE_WIDTH, 40d);
+ style.setDefaultValue(RichVisualLexicon.NODE_HEIGHT, 40d);
+ style.setDefaultValue(RichVisualLexicon.NODE_BORDER_WIDTH, 2d);
+ style.setDefaultValue(RichVisualLexicon.NODE_BORDER_PAINT,
Color.DARK_GRAY);
+ style.setDefaultValue(RichVisualLexicon.NODE_TRANSPARENCY, 210);
+ //FIXME
+//
style.getNodeAppearanceCalculator().getDefaultAppearance().set(VisualPropertyType.NODE_BORDER_OPACITY,
120);
+
+ // Edge default appearence definitions
+ //FIXME
// style.getEdgeAppearanceCalculator().getDefaultAppearance().set(
// VisualPropertyType.EDGE_TGTARROW_SHAPE,
ArrowShape.DELTA);
// style.getEdgeAppearanceCalculator().getDefaultAppearance().set(
// VisualPropertyType.EDGE_TGTARROW_COLOR,
Color.DARK_GRAY);
// style.getEdgeAppearanceCalculator().getDefaultAppearance().set(
// VisualPropertyType.EDGE_SRCARROW_SHAPE,
ArrowShape.NONE);
-// style.getEdgeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.EDGE_LINE_STYLE,
LineStyle.SOLID);
-// style.getEdgeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.EDGE_LINE_WIDTH, 4.0f);
-// style.getEdgeAppearanceCalculator().getDefaultAppearance().set(
-// VisualPropertyType.EDGE_COLOR, Color.DARK_GRAY);
-// style.getGlobalAppearanceCalculator().setDefaultBackgroundColor(
-// Color.white);
-//
-// // Display NODE_LABEL as a label
-// //TODO: Replace when 2.8 released.
-//// final PassThroughMapping<String, String> m = new
PassThroughMapping<String, String>(
-//// String.class, NODE_LABEL);
-// final PassThroughMapping m2 = new PassThroughMapping("",
NODE_LABEL);
-// final Calculator nlc = new BasicCalculator("Node Description_"
-// + networkName, m2,
VisualPropertyType.NODE_LABEL);
-// style.getNodeAppearanceCalculator().setCalculator(nlc);
-//
-// // Gradient node color mapping
-// //TODO: Replace when 2.8 released.
-//// final ContinuousMapping<Double, Color> colorMapping = new
ContinuousMapping<Double, Color>(
-//// Color.class, NODE_COLOR);
-// final ContinuousMapping colorMapping = new ContinuousMapping(
-// NADA, ObjectMapping.NODE_MAPPING);
-// colorMapping.setControllingAttributeName(NODE_COLOR, network,
false);
-// //TODO: Add generics parameter when 2.8 released.
-// final BoundaryRangeValues colbrVal1 = new BoundaryRangeValues();
-// double cols = -(Math.log(alpha) / Math.log(10));
-// colbrVal1.lesserValue = NADA;
-// colbrVal1.equalValue = COL_MIN;
-// colbrVal1.greaterValue = COL_MIN;
-// colorMapping.addPoint(cols, colbrVal1);
-//
-// //TODO: Add generics parameter when 2.8 released.
-// final BoundaryRangeValues colbrVal2 = new BoundaryRangeValues();
-// cols = -(Math.log(alpha) / Math.log(10)) + 5.0;
-// colbrVal2.lesserValue = COL_MAX;
-// colbrVal2.equalValue = COL_MAX;
-// colbrVal2.greaterValue = COL_MAX;
-// colorMapping.addPoint(cols, colbrVal2);
-//
-// final Calculator colorCalculator = new BasicCalculator(
-// "Bingo Node Color_" + networkName, colorMapping,
-// VisualPropertyType.NODE_FILL_COLOR);
-//
style.getNodeAppearanceCalculator().setCalculator(colorCalculator);
-//
+
+ style.setDefaultValue(RichVisualLexicon.EDGE_LINE_TYPE,
LineTypeVisualProperty.SOLID);
+ style.setDefaultValue(RichVisualLexicon.EDGE_WIDTH, 4d);
+
style.setDefaultValue(RichVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT,
Color.DARK_GRAY);
+
style.setDefaultValue(RichVisualLexicon.NETWORK_BACKGROUND_PAINT, Color.WHITE);
+
+ // Display NODE_LABEL as a label
+ final VisualMappingFunctionFactory passthroughF =
adapter.getVisualMappingFunctionPassthroughFactory();
+ final VisualMappingFunction<String, String> labelMapping =
passthroughF.createVisualMappingFunction(
+ NODE_LABEL, String.class, RichVisualLexicon.NODE_LABEL);
+ style.addVisualMappingFunction(labelMapping);
+
+ // Gradient node color mapping
+ final VisualMappingFunctionFactory continuousF =
adapter.getVisualMappingFunctionContinuousFactory();
+ final VisualMappingFunction<Double, Paint> nodeColorMapping =
continuousF.createVisualMappingFunction(
+ NODE_COLOR, Double.class,
RichVisualLexicon.NODE_FILL_COLOR);
+ style.addVisualMappingFunction(nodeColorMapping);
+
+ double cols1 = -(Math.log(alpha) / Math.log(10));
+ final BoundaryRangeValues<Paint> colbrVal1 = new
BoundaryRangeValues<Paint>(NADA, COL_MIN, COL_MIN);
+
+ double cols2 = -(Math.log(alpha) / Math.log(10)) + 5.0;
+ final BoundaryRangeValues<Paint> colbrVal2 = new
BoundaryRangeValues<Paint>(COL_MAX, COL_MAX, COL_MAX);
+
+ // FIXME This section should be called, but never happens.
+ if (nodeColorMapping instanceof ContinuousMapping) {
+ System.out.println("##### This is ContinuousMapping");
+ ((ContinuousMapping<Double, Paint>)
nodeColorMapping).addPoint(cols1, colbrVal1);
+ ((ContinuousMapping<Double, Paint>)
nodeColorMapping).addPoint(cols2, colbrVal2);
+ }
+
// // Node Size Mapping
// //TODO: Update when 2.8 released.
// final ContinuousMapping wMapping = new ContinuousMapping(
@@ -182,31 +182,12 @@
//
style.getNodeAppearanceCalculator().setCalculator(nodeSizeCalculator);
}
- public VisualStyle createVisualStyle(CyNetwork network) {
-
-// /*final VisualMappingManager vmm =
Cytoscape.getVisualMappingManager();
-//
-// // gets the currently active visual style
-// final VisualStyle currentStyle = vmm.getVisualStyle();
-//
-// // methods to access the node, edge, and global appearance
calculators
-// final NodeAppearanceCalculator nodeAppCalc = new
NodeAppearanceCalculator(
-// currentStyle.getNodeAppearanceCalculator());
-// final EdgeAppearanceCalculator edgeAppCalc = new
EdgeAppearanceCalculator(
-// currentStyle.getEdgeAppearanceCalculator());
-// final GlobalAppearanceCalculator globalAppCalc = new
GlobalAppearanceCalculator(
-// currentStyle.getGlobalAppearanceCalculator());
-//
-// // create the visual style
-// final VisualStyle visualStyle = new VisualStyle(bingoVSName,
nodeAppCalc,
-// edgeAppCalc, globalAppCalc);
-// */
-// final VisualStyle visualStyle = new VisualStyle(bingoVSName);
-//
-// // update with BiNGO specific style
-// adaptVisualStyle(visualStyle, network);
-//
-// return visualStyle;
- return null;
+ public VisualStyle createVisualStyle(final CyNetwork network) {
+ final VisualStyleFactory vsFactory =
adapter.getVisualStyleFactory();
+ final VisualMappingManager vmm =
adapter.getVisualMappingManager();
+ final VisualStyle visualStyle =
vsFactory.getInstance(bingoVSName);
+ adaptVisualStyle(visualStyle, network);
+ vmm.addVisualStyle(visualStyle);
+ return visualStyle;
}
}
--
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.