Author: jm
Date: 2011-07-08 16:35:01 -0700 (Fri, 08 Jul 2011)
New Revision: 26127
Modified:
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewTaskFactory.java
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/util/BioPaxVisualStyleUtil.java
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
fixes #42: Ported BioPAX VisualStyle
Modified:
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
===================================================================
---
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
2011-07-08 23:28:30 UTC (rev 26126)
+++
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
2011-07-08 23:35:01 UTC (rev 26127)
@@ -19,6 +19,8 @@
import org.cytoscape.session.CyNetworkNaming;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.CyNetworkViewFactory;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyle;
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskMonitor;
import org.slf4j.Logger;
@@ -40,16 +42,18 @@
private final CyNetworkFactory networkFactory;
private final CyNetworkViewFactory viewFactory;
private final CyNetworkNaming naming;
+ private final VisualMappingManager mappingManager;
+ private final BioPaxVisualStyleUtil bioPaxVisualStyleUtil;
private final BioPaxContainerImpl bpContainer;
private final NetworkListener networkListener;
- private CyNetwork network;
-
private InputStream stream;
private String inputName;
+ private CyNetwork network;
+
/**
* Constructor
*
@@ -66,7 +70,7 @@
*
* @param model PaxTools BioPAX Model
*/
- public BioPaxNetworkViewReaderTask(InputStream stream, String
inputName, CyNetworkFactory networkFactory, CyNetworkViewFactory viewFactory,
CyNetworkNaming naming, BioPaxContainerImpl bpContainer, NetworkListener
networkListener) {
+ public BioPaxNetworkViewReaderTask(InputStream stream, String
inputName, CyNetworkFactory networkFactory, CyNetworkViewFactory viewFactory,
CyNetworkNaming naming, BioPaxContainerImpl bpContainer, NetworkListener
networkListener, VisualMappingManager mappingManager, BioPaxVisualStyleUtil
bioPaxVisualStyleUtil) {
this.stream = stream;
this.inputName = inputName;
this.networkFactory = networkFactory;
@@ -74,6 +78,8 @@
this.naming = naming;
this.bpContainer = bpContainer;
this.networkListener = networkListener;
+ this.mappingManager = mappingManager;
+ this.bioPaxVisualStyleUtil = bioPaxVisualStyleUtil;
}
public String getNetworkId() {
@@ -100,8 +106,6 @@
network = networkFactory.getInstance();
AttributeUtil.set(network, CyNetwork.NAME, networkName,
String.class);
- //view = viewFactory.getNetworkView(network);
-
// Map BioPAX Data to Cytoscape Nodes/Edges (run as task)
MapBioPaxToCytoscapeImpl mapper = new
MapBioPaxToCytoscapeImpl(network, taskMonitor);
mapper.doMapping(model);
@@ -186,31 +190,6 @@
BioPaxUtil.addNetworkModel(cyNetwork.getSUID(), model);
String modelString = (inputName!=null) ? inputName : "";
AttributeUtil.set(cyNetwork, BioPaxUtil.BIOPAX_MODEL_STRING,
modelString, String.class);
-
- // Set-up the BioPax Visual Style
- // TODO: VisualStyle
-// VisualStyle bioPaxVisualStyle =
BioPaxVisualStyleUtil.getBioPaxVisualStyle();
-// VisualMappingManager manager =
Cytoscape.getVisualMappingManager();
-// CyNetworkView view =
Cytoscape.getNetworkView(cyNetwork.getIdentifier());
-// // set tooltips
-// BioPaxVisualStyleUtil.setNodeToolTips(view);
-// // set style
-// view.setVisualStyle(bioPaxVisualStyle.getName());
-// manager.setVisualStyle(bioPaxVisualStyle);
-// view.applyVizmapper(bioPaxVisualStyle);
-
- // Set up BP UI
-// CytoscapeWrapper.initBioPaxPlugInUI();
-// bpContainer.showLegend();
-
- // add network listener
-// networkListener.registerNetwork(view);
-
- // add node's context menu
- // TODO: NodeViewTaskFactory?
-// BiopaxNodeCtxMenuListener nodeCtxMenuListener = new
BiopaxNodeCtxMenuListener();
-// view.addNodeContextMenuListener(nodeCtxMenuListener);
-
}
/**
@@ -248,6 +227,26 @@
public CyNetworkView buildCyNetworkView(CyNetwork network) {
CyNetworkView view = viewFactory.getNetworkView(network);
networkListener.registerNetwork(view);
+
+ // Set-up the BioPax Visual Style
+ VisualStyle bioPaxVisualStyle =
bioPaxVisualStyleUtil.getBioPaxVisualStyle();
+// // set tooltips
+// BioPaxVisualStyleUtil.setNodeToolTips(view);
+// // set style
+ mappingManager.setVisualStyle(bioPaxVisualStyle, view);
+
+ // Set up BP UI
+// CytoscapeWrapper.initBioPaxPlugInUI();
+// bpContainer.showLegend();
+
+ // add network listener
+// networkListener.registerNetwork(view);
+
+ // add node's context menu
+ // TODO: NodeViewTaskFactory?
+// BiopaxNodeCtxMenuListener nodeCtxMenuListener = new
BiopaxNodeCtxMenuListener();
+// view.addNodeContextMenuListener(nodeCtxMenuListener);
+
return view;
}
}
Modified:
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewTaskFactory.java
===================================================================
---
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewTaskFactory.java
2011-07-08 23:28:30 UTC (rev 26126)
+++
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewTaskFactory.java
2011-07-08 23:35:01 UTC (rev 26127)
@@ -4,11 +4,13 @@
import org.cytoscape.biopax.NetworkListener;
import org.cytoscape.biopax.internal.view.BioPaxContainerImpl;
+import org.cytoscape.biopax.util.BioPaxVisualStyleUtil;
import org.cytoscape.io.CyFileFilter;
import org.cytoscape.io.read.InputStreamTaskFactory;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.session.CyNetworkNaming;
import org.cytoscape.view.model.CyNetworkViewFactory;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.work.TaskIterator;
public class BioPaxNetworkViewTaskFactory implements InputStreamTaskFactory {
@@ -22,19 +24,23 @@
private InputStream inputStream;
private String inputName;
+ private VisualMappingManager mappingManager;
+ private BioPaxVisualStyleUtil bioPaxVisualStyleUtil;
- public BioPaxNetworkViewTaskFactory(CyFileFilter filter,
CyNetworkFactory networkFactory, CyNetworkViewFactory viewFactory,
CyNetworkNaming naming, BioPaxContainerImpl bpContainer, NetworkListener
networkListener) {
+ public BioPaxNetworkViewTaskFactory(CyFileFilter filter,
CyNetworkFactory networkFactory, CyNetworkViewFactory viewFactory,
CyNetworkNaming naming, BioPaxContainerImpl bpContainer, NetworkListener
networkListener, VisualMappingManager mappingManager, BioPaxVisualStyleUtil
bioPaxVisualStyleUtil) {
this.filter = filter;
this.networkFactory = networkFactory;
this.viewFactory = viewFactory;
this.naming = naming;
this.bpContainer = bpContainer;
this.networkListener = networkListener;
+ this.mappingManager = mappingManager;
+ this.bioPaxVisualStyleUtil = bioPaxVisualStyleUtil;
}
@Override
public TaskIterator getTaskIterator() {
- BioPaxNetworkViewReaderTask task = new
BioPaxNetworkViewReaderTask(inputStream, inputName, networkFactory,
viewFactory, naming, bpContainer, networkListener);
+ BioPaxNetworkViewReaderTask task = new
BioPaxNetworkViewReaderTask(inputStream, inputName, networkFactory,
viewFactory, naming, bpContainer, networkListener, mappingManager,
bioPaxVisualStyleUtil);
return new TaskIterator(task);
}
Modified:
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/util/BioPaxVisualStyleUtil.java
===================================================================
---
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/util/BioPaxVisualStyleUtil.java
2011-07-08 23:28:30 UTC (rev 26126)
+++
core3/biopax-impl/trunk/src/main/java/org/cytoscape/biopax/util/BioPaxVisualStyleUtil.java
2011-07-08 23:35:01 UTC (rev 26127)
@@ -32,10 +32,9 @@
package org.cytoscape.biopax.util;
import java.awt.Color;
-import java.util.Iterator;
+import java.awt.Paint;
import org.biopax.paxtools.model.BioPAXElement;
-import org.biopax.paxtools.model.level2.ControlType;
import org.biopax.paxtools.model.level2.complex;
import org.biopax.paxtools.model.level2.control;
import org.biopax.paxtools.model.level2.interaction;
@@ -44,34 +43,43 @@
import org.biopax.paxtools.model.level3.Control;
import org.biopax.paxtools.model.level3.Interaction;
import org.biopax.paxtools.model.level3.PhysicalEntity;
+import org.cytoscape.biopax.MapBioPaxToCytoscape;
import org.cytoscape.biopax.internal.BiopaxPlugin;
-import org.cytoscape.biopax.internal.MapBioPaxToCytoscapeImpl;
import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
+import org.cytoscape.view.presentation.property.NodeShapeVisualProperty;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
+import org.cytoscape.view.presentation.property.values.NodeShape;
+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.DiscreteMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Creates an "out-of-the-box" default Visual Mapper for rendering BioPAX
* networks.
- *
+ *
* @author Ethan Cerami
* @author Igor Rodchenkov (re-factoring using PaxTools API)
*/
public class BioPaxVisualStyleUtil {
- public static final Logger log =
LoggerFactory.getLogger(BioPaxVisualStyleUtil.class);
+ public static final Logger log = LoggerFactory
+ .getLogger(BioPaxVisualStyleUtil.class);
/**
* Verion Number String.
*/
- public static final String VERSION_POST_FIX = " v " +
BiopaxPlugin.VERSION_MAJOR_NUM + "_"
- +
BiopaxPlugin.VERSION_MINOR_NUM;
+ public static final String VERSION_POST_FIX = " v "
+ + BiopaxPlugin.VERSION_MAJOR_NUM + "_"
+ + BiopaxPlugin.VERSION_MINOR_NUM;
/**
* Name of BioPax Visual Style.
*/
- public static final String BIO_PAX_VISUAL_STYLE = "BioPAX" +
VERSION_POST_FIX;
+ public static final String BIO_PAX_VISUAL_STYLE = "BioPAX"
+ + VERSION_POST_FIX;
/**
* Node Label Attribute.
@@ -93,7 +101,8 @@
// taken from DNodeView
/**
- * size of physical entity node scale - (used to scale post
tranlational modification nodes)
+ * size of physical entity node scale - (used to scale post tranlational
+ * modification nodes)
*/
public static final double
BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_SIZE_SCALE = 3;
@@ -115,7 +124,8 @@
/**
* Node border color
*/
- private static final Color DEFAULT_NODE_BORDER_COLOR = new Color(0,
102, 102);
+ private static final Color DEFAULT_NODE_BORDER_COLOR = new Color(0, 102,
+ 102);
/**
* Complex node color
@@ -127,242 +137,250 @@
*/
private static final Color COMPLEX_NODE_BORDER_COLOR =
COMPLEX_NODE_COLOR;
-// /**
-// * Constructor.
-// * If an existing BioPAX Viz Mapper already exists, we use it.
-// * Otherwise, we create a new one.
-// *
-// * @return VisualStyle Object.
-// */
-// public static VisualStyle getBioPaxVisualStyle() {
-// VisualMappingManager manager =
Cytoscape.getVisualMappingManager();
-// CalculatorCatalog catalog = manager.getCalculatorCatalog();
-//
-// VisualStyle bioPaxVisualStyle =
catalog.getVisualStyle(BIO_PAX_VISUAL_STYLE);
-//
-// // If the BioPAX Visual Style already exists, use this one
instead.
-// // The user may have tweaked the out-of-the box mapping, and
we don't
-// // want to over-ride these tweaks.
-// if (bioPaxVisualStyle == null) {
-// bioPaxVisualStyle = new
VisualStyle(BIO_PAX_VISUAL_STYLE);
-//
-// NodeAppearanceCalculator nac =
bioPaxVisualStyle.getNodeAppearanceCalculator();
-//
bioPaxVisualStyle.getDependency().set(VisualPropertyDependency.Definition.NODE_SIZE_LOCKED,false);
-//
-// EdgeAppearanceCalculator eac =
bioPaxVisualStyle.getEdgeAppearanceCalculator();
-//
-// createNodeShape(nac);
-// createNodeSize(nac);
-// createNodeLabel(nac);
-// createNodeColor(nac);
-// createNodeBorderColor(nac);
-// createTargetArrows(eac);
-//
-// bioPaxVisualStyle.setNodeAppearanceCalculator(nac);
-// bioPaxVisualStyle.setEdgeAppearanceCalculator(eac);
-//
-// // The visual style must be added to the Global Catalog
-// // in order for it to be written out to vizmap.props
upon user exit
-// catalog.addVisualStyle(bioPaxVisualStyle);
-// }
-//
-// return bioPaxVisualStyle;
-// }
-//
-// private static void createNodeShape(NodeAppearanceCalculator nac) {
-// // create a discrete mapper, for mapping a biopax type to a
shape
-// DiscreteMapping discreteMapping = new
DiscreteMapping(NodeShape.RECT,
-// MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE,
ObjectMapping.NODE_MAPPING);
-//
-// // map all physical entities to circles
-// for (Class<? extends BioPAXElement> claz :
BioPaxUtil.getSubclassNames(PhysicalEntity.class, physicalEntity.class)) {
-// String name
=BioPaxUtil.getTypeInPlainEnglish(claz.getSimpleName());
-// discreteMapping.putMapValue(name, NodeShape.ELLIPSE);
-// }
-//
-// // hack for phosphorylated proteins
-// discreteMapping.putMapValue(BioPaxUtil.PROTEIN_PHOSPHORYLATED,
NodeShape.ELLIPSE);
-//
-// // map all interactions
-// // - control to triangles
-// // - others to square
-// for (Class<?> c :
BioPaxUtil.getSubclassNames(Interaction.class, interaction.class)) {
-// String entityName =
BioPaxUtil.getTypeInPlainEnglish(c.getSimpleName());
-// if (Control.class.isAssignableFrom(c) ||
control.class.isAssignableFrom(c)) {
-// discreteMapping.putMapValue(entityName,
NodeShape.TRIANGLE);
-// } else {
-// discreteMapping.putMapValue(entityName,
NodeShape.RECT);
-// }
-// }
-//
-// // create and set node shape calculator in node appearance
calculator
-// Calculator nodeShapeCalculator = new BasicCalculator("BioPAX
Node Shape" + VERSION_POST_FIX,
-//
discreteMapping,
-//
VisualPropertyType.NODE_SHAPE);
-// nac.setCalculator(nodeShapeCalculator);
-// }
-//
-// private static void createNodeSize(NodeAppearanceCalculator nac) {
-// // create a discrete mapper, for mapping biopax node type
-// // to a particular node size.
-// DiscreteMapping discreteMappingWidth = new DiscreteMapping(new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH),
-// MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE,
ObjectMapping.NODE_MAPPING);
-// DiscreteMapping discreteMappingHeight = new DiscreteMapping(new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT),
-// MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE,
ObjectMapping.NODE_MAPPING);
-//
-// // map all interactions to required size
-// for (Class c : BioPaxUtil.getSubclassNames(Interaction.class,
interaction.class)) {
-// String entityName = c.getSimpleName();
-//
discreteMappingWidth.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
-// new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH *
BIO_PAX_VISUAL_STYLE_INTERACTION_NODE_SIZE_SCALE));
-//
discreteMappingHeight.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
-// new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT *
BIO_PAX_VISUAL_STYLE_INTERACTION_NODE_SIZE_SCALE));
-// }
-//
-//
-// // map all complex to required size
-// for (Class c: BioPaxUtil.getSubclassNames(complex.class,
Complex.class)) {
-// String entityName = c.getSimpleName();
-//
discreteMappingWidth.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
-// new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH *
BIO_PAX_VISUAL_STYLE_COMPLEX_NODE_SIZE_SCALE));
-//
discreteMappingHeight.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
-// new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT *
BIO_PAX_VISUAL_STYLE_COMPLEX_NODE_SIZE_SCALE));
-// }
-//
-// /*
-// // hack for phosphorylated proteins - make them large so label
fits within node
-// // commented out by Ethan Cerami, November 15, 2006
-//
discreteMappingWidth.putMapValue(BioPaxUtil.PROTEIN_PHOSPHORYLATED,
-// new Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH
-// *
BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_SIZE_SCALE));
-//
discreteMappingHeight.putMapValue(BioPaxUtil.PROTEIN_PHOSPHORYLATED,
-// new Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT
-// *
BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_SIZE_SCALE));
-// */
-//
-// // create and set node height calculator in node appearance
calculator
-// Calculator nodeWidthCalculator = new BasicCalculator("BioPAX
Node Width" + VERSION_POST_FIX,
-//
discreteMappingWidth,
-//
VisualPropertyType.NODE_WIDTH);
-// nac.setCalculator(nodeWidthCalculator);
-//
nac.getDefaultAppearance().set(cytoscape.visual.VisualPropertyType.NODE_WIDTH,
-// new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH));
-//
-// Calculator nodeHeightCalculator = new BasicCalculator("BioPAX
Node Height"
-// +
VERSION_POST_FIX,
-//
discreteMappingHeight,
-//
VisualPropertyType.NODE_HEIGHT);
-// nac.setCalculator(nodeHeightCalculator);
-//
nac.getDefaultAppearance().set(cytoscape.visual.VisualPropertyType.NODE_HEIGHT,
-// new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT));
-// }
-//
-// private static void createNodeLabel(NodeAppearanceCalculator nac) {
-// // create pass through mapper for node labels
-// PassThroughMapping passThroughMapping = new
PassThroughMapping("",
-//
ObjectMapping.NODE_MAPPING);
-//
passThroughMapping.setControllingAttributeName(BIOPAX_NODE_LABEL, null, false);
-//
-// // create and set node label calculator in node appearance
calculator
-// Calculator nodeLabelCalculator = new BasicCalculator("BioPAX
Node Label" + VERSION_POST_FIX,
-//
passThroughMapping,
-//
VisualPropertyType.NODE_LABEL);
-// nac.setCalculator(nodeLabelCalculator);
-// }
-//
-// private static void createNodeColor(NodeAppearanceCalculator nac) {
-// // create a discrete mapper, for mapping biopax node type
-// // to a particular node color
-// DiscreteMapping discreteMapping = new
DiscreteMapping(DEFAULT_NODE_COLOR,
-// MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE,
ObjectMapping.NODE_MAPPING);
-//
-// // map all complex to black
-// discreteMapping.putMapValue("Complex", COMPLEX_NODE_COLOR);
-//
-// // create and set node label calculator in node appearance
calculator
-// Calculator nodeColorCalculator = new BasicCalculator("BioPAX
Node Color" + VERSION_POST_FIX,
-//
discreteMapping,
-//
VisualPropertyType.NODE_FILL_COLOR);
-// nac.setCalculator(nodeColorCalculator);
-//
-// // set default color
-//
nac.getDefaultAppearance().set(cytoscape.visual.VisualPropertyType.NODE_FILL_COLOR,
-//
DEFAULT_NODE_COLOR);
-// }
-//
-// private static void createNodeBorderColor(NodeAppearanceCalculator nac)
{
-// // create a discrete mapper, for mapping biopax node type
-// // to a particular node color
-// DiscreteMapping discreteMapping = new
DiscreteMapping(DEFAULT_NODE_BORDER_COLOR,
-// MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE,
ObjectMapping.NODE_MAPPING);
-//
-// // map all complex to black
-// discreteMapping.putMapValue("Complex",
COMPLEX_NODE_BORDER_COLOR);
-//
-// // create and set node label calculator in node appearance
calculator
-// Calculator nodeBorderColorCalculator = new
BasicCalculator("BioPAX Node Border Color"
-// +
VERSION_POST_FIX,
-//
discreteMapping,
-//
VisualPropertyType.NODE_BORDER_COLOR);
-// nac.setCalculator(nodeBorderColorCalculator);
-//
-// // set default color
-//
nac.getDefaultAppearance().set(cytoscape.visual.VisualPropertyType.NODE_BORDER_COLOR,
-//
DEFAULT_NODE_BORDER_COLOR);
-// }
-//
-// private static void createTargetArrows(EdgeAppearanceCalculator eac) {
-// DiscreteMapping discreteMapping = new
DiscreteMapping(ArrowShape.NONE,
-//
MapBioPaxToCytoscape.BIOPAX_EDGE_TYPE,
-//
ObjectMapping.EDGE_MAPPING);
-//
-// discreteMapping.putMapValue(MapBioPaxToCytoscape.RIGHT,
ArrowShape.DELTA);
-// discreteMapping.putMapValue(MapBioPaxToCytoscape.CONTROLLED,
ArrowShape.DELTA);
-// discreteMapping.putMapValue(MapBioPaxToCytoscape.COFACTOR,
ArrowShape.DELTA);
-// discreteMapping.putMapValue(MapBioPaxToCytoscape.CONTAINS,
ArrowShape.CIRCLE);
-//
-// // Inhibition Edges
-// for (ControlType controlType : ControlType.values()) {
-// if(controlType.toString().startsWith("I")) {
-//
discreteMapping.putMapValue(controlType.toString(), ArrowShape.T);
-// }
-// }
-//
-// // Activation Edges
-// for (ControlType controlType : ControlType.values()) {
-// if(controlType.toString().startsWith("A")) {
-//
discreteMapping.putMapValue(controlType.toString(), ArrowShape.DELTA);
-// }
-// }
-//
-// Calculator edgeTargetArrowCalculator = new
BasicCalculator("BioPAX Target Arrows"
-// +
VERSION_POST_FIX,
-//
discreteMapping,
-//
VisualPropertyType.EDGE_TGTARROW_SHAPE);
-// eac.setCalculator(edgeTargetArrowCalculator);
-// }
-//
-//
-// @SuppressWarnings("unchecked")
-// public static void setNodeToolTips(CyNetworkView networkView) {
-// // grab node attributes
-// CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
-//
-// // iterate through the nodes
-// Iterator<NodeView> nodesIt = networkView.getNodeViewsIterator();
-// while (nodesIt.hasNext()) {
-// NodeView nodeView = nodesIt.next();
-// String id = nodeView.getNode().getIdentifier();
-// String tip =
-// nodeAttributes.getStringAttribute(id,
MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE)
-// + "\n" +
-// nodeAttributes.getListAttribute(id,
MapBioPaxToCytoscape.BIOPAX_CELLULAR_LOCATIONS);
-//
-// nodeView.setToolTip(tip);
-//
-// if(log.isDebugging())
-// log.debug("tooltip set "+ tip + " for node " +
id);
-// }
-// networkView.updateView();
-// }
+ VisualStyle style;
+
+ private final VisualStyleFactory styleFactory;
+ private final VisualMappingManager mappingManager;
+ private final VisualMappingFunctionFactory discreteFactory;
+ private final VisualMappingFunctionFactory passthroughFactory;
+
+ public BioPaxVisualStyleUtil(VisualStyleFactory styleFactory,
+ VisualMappingManager mappingManager,
+ VisualMappingFunctionFactory discreteMappingFactory,
+ VisualMappingFunctionFactory passthroughFactory) {
+ this.styleFactory = styleFactory;
+ this.mappingManager = mappingManager;
+ this.discreteFactory = discreteMappingFactory;
+ this.passthroughFactory = passthroughFactory;
+ }
+
+ /**
+ * Constructor. If an existing BioPAX Viz Mapper already exists, we use
it.
+ * Otherwise, we create a new one.
+ *
+ * @return VisualStyle Object.
+ */
+ public VisualStyle getBioPaxVisualStyle() {
+ // If the BioPAX Visual Style already exists, use this one
instead.
+ // The user may have tweaked the out-of-the box mapping, and we
don't
+ // want to over-ride these tweaks.
+ synchronized (this) {
+ if (style == null) {
+ style =
styleFactory.getInstance(BIO_PAX_VISUAL_STYLE);
+
+ //
style.getDependency().set(VisualPropertyDependency.Definition.NODE_SIZE_LOCKED,false);
+
+ createNodeShape(style);
+ createNodeSize(style);
+ createNodeLabel(style);
+ createNodeColor(style);
+ createNodeBorderColor(style);
+ createTargetArrows(style);
+
+ mappingManager.addVisualStyle(style);
+ }
+ }
+ return style;
+ }
+
+ private void createNodeShape(VisualStyle style) {
+ style.setDefaultValue(RichVisualLexicon.NODE_SHAPE,
+ NodeShapeVisualProperty.RECTANGLE);
+
+ // create a discrete mapper, for mapping a biopax type to a
shape
+ DiscreteMapping<String, NodeShape> function =
(DiscreteMapping<String, NodeShape>) discreteFactory
+ .createVisualMappingFunction(
+
MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE, String.class,
+ RichVisualLexicon.NODE_SHAPE);
+
+ // map all physical entities to circles
+ for (Class<? extends BioPAXElement> claz :
BioPaxUtil.getSubclassNames(
+ PhysicalEntity.class, physicalEntity.class)) {
+ String name = BioPaxUtil
+
.getTypeInPlainEnglish(claz.getSimpleName());
+ function.putMapValue(name,
NodeShapeVisualProperty.ELLIPSE);
+ }
+
+ // hack for phosphorylated proteins
+ function.putMapValue(BioPaxUtil.PROTEIN_PHOSPHORYLATED,
+ NodeShapeVisualProperty.ELLIPSE);
+
+ // map all interactions
+ // - control to triangles
+ // - others to square
+ for (Class<?> c : BioPaxUtil.getSubclassNames(Interaction.class,
+ interaction.class)) {
+ String entityName = BioPaxUtil.getTypeInPlainEnglish(c
+ .getSimpleName());
+ if (Control.class.isAssignableFrom(c)
+ || control.class.isAssignableFrom(c)) {
+ function.putMapValue(entityName,
+
NodeShapeVisualProperty.TRIANGLE);
+ } else {
+ function.putMapValue(entityName,
+
NodeShapeVisualProperty.RECTANGLE);
+ }
+ }
+ style.addVisualMappingFunction(function);
+ }
+
+ private void createNodeSize(VisualStyle style) {
+ // create a discrete mapper, for mapping biopax node type
+ // to a particular node size.
+ DiscreteMapping<String, Double> width =
(DiscreteMapping<String, Double>) discreteFactory
+ .createVisualMappingFunction(
+
MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE, String.class,
+
MinimalVisualLexicon.NODE_WIDTH);
+ DiscreteMapping<String, Double> height =
(DiscreteMapping<String, Double>) discreteFactory
+ .createVisualMappingFunction(
+
MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE, String.class,
+
MinimalVisualLexicon.NODE_HEIGHT);
+
+ // map all interactions to required size
+ for (Class c : BioPaxUtil.getSubclassNames(Interaction.class,
+ interaction.class)) {
+ String entityName = c.getSimpleName();
+
width.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
+ new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH
+ *
BIO_PAX_VISUAL_STYLE_INTERACTION_NODE_SIZE_SCALE));
+
height.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
+ new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT
+ *
BIO_PAX_VISUAL_STYLE_INTERACTION_NODE_SIZE_SCALE));
+ }
+
+ // map all complex to required size
+ for (Class c : BioPaxUtil
+ .getSubclassNames(complex.class,
Complex.class)) {
+ String entityName = c.getSimpleName();
+
width.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
+ new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH
+ *
BIO_PAX_VISUAL_STYLE_COMPLEX_NODE_SIZE_SCALE));
+
height.putMapValue(BioPaxUtil.getTypeInPlainEnglish(entityName),
+ new
Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT
+ *
BIO_PAX_VISUAL_STYLE_COMPLEX_NODE_SIZE_SCALE));
+ }
+
+ /*
+ * // hack for phosphorylated proteins - make them large so
label fits
+ * within node // commented out by Ethan Cerami, November 15,
2006
+ *
discreteMappingWidth.putMapValue(BioPaxUtil.PROTEIN_PHOSPHORYLATED,
+ * new Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH
+ * BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_SIZE_SCALE));
+ *
discreteMappingHeight.putMapValue(BioPaxUtil.PROTEIN_PHOSPHORYLATED,
+ * new Double(BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT
+ * BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_SIZE_SCALE));
+ */
+
+ // create and set node height calculator in node appearance
calculator
+ style.setDefaultValue(MinimalVisualLexicon.NODE_WIDTH,
+
BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_WIDTH);
+ style.setDefaultValue(MinimalVisualLexicon.NODE_HEIGHT,
+
BIO_PAX_VISUAL_STYLE_PHYSICAL_ENTITY_NODE_HEIGHT);
+
+ style.addVisualMappingFunction(width);
+ style.addVisualMappingFunction(height);
+ }
+
+ private void createNodeLabel(VisualStyle style) {
+ // create pass through mapper for node labels
+ style.addVisualMappingFunction(passthroughFactory
+ .createVisualMappingFunction(BIOPAX_NODE_LABEL,
String.class,
+
MinimalVisualLexicon.NODE_LABEL));
+ }
+
+ private void createNodeColor(VisualStyle style) {
+ style.setDefaultValue(MinimalVisualLexicon.NODE_FILL_COLOR,
+ DEFAULT_NODE_COLOR);
+
+ // create a discrete mapper, for mapping biopax node type
+ // to a particular node color
+ DiscreteMapping<String, Paint> function =
(DiscreteMapping<String, Paint>) discreteFactory
+ .createVisualMappingFunction(
+
MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE, String.class,
+
MinimalVisualLexicon.NODE_FILL_COLOR);
+
+ // map all complex to black
+ function.putMapValue("Complex", COMPLEX_NODE_COLOR);
+
+ style.addVisualMappingFunction(function);
+ }
+
+ private void createNodeBorderColor(VisualStyle style) {
+ style.setDefaultValue(RichVisualLexicon.NODE_BORDER_PAINT,
+ DEFAULT_NODE_BORDER_COLOR);
+
+ // create a discrete mapper, for mapping biopax node type
+ // to a particular node color
+ DiscreteMapping<String, Paint> function =
(DiscreteMapping<String, Paint>) discreteFactory
+ .createVisualMappingFunction(
+
MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE, String.class,
+
RichVisualLexicon.NODE_BORDER_PAINT);
+
+ // map all complex to black
+ function.putMapValue("Complex", COMPLEX_NODE_BORDER_COLOR);
+
+ style.addVisualMappingFunction(function);
+ }
+
+ private void createTargetArrows(VisualStyle style) {
+ // DiscreteMapping discreteMapping = new
+ // DiscreteMapping(ArrowShape.NONE,
+ // MapBioPaxToCytoscape.BIOPAX_EDGE_TYPE,
+ // ObjectMapping.EDGE_MAPPING);
+ //
+ // discreteMapping.putMapValue(MapBioPaxToCytoscape.RIGHT,
+ // ArrowShape.DELTA);
+ // discreteMapping.putMapValue(MapBioPaxToCytoscape.CONTROLLED,
+ // ArrowShape.DELTA);
+ // discreteMapping.putMapValue(MapBioPaxToCytoscape.COFACTOR,
+ // ArrowShape.DELTA);
+ // discreteMapping.putMapValue(MapBioPaxToCytoscape.CONTAINS,
+ // ArrowShape.CIRCLE);
+ //
+ // // Inhibition Edges
+ // for (ControlType controlType : ControlType.values()) {
+ // if(controlType.toString().startsWith("I")) {
+ // discreteMapping.putMapValue(controlType.toString(),
ArrowShape.T);
+ // }
+ // }
+ //
+ // // Activation Edges
+ // for (ControlType controlType : ControlType.values()) {
+ // if(controlType.toString().startsWith("A")) {
+ // discreteMapping.putMapValue(controlType.toString(),
+ // ArrowShape.DELTA);
+ // }
+ // }
+ //
+ // Calculator edgeTargetArrowCalculator = new
+ // BasicCalculator("BioPAX Target Arrows"
+ // + VERSION_POST_FIX,
+ // discreteMapping,
+ // VisualPropertyType.EDGE_TGTARROW_SHAPE);
+ // eac.setCalculator(edgeTargetArrowCalculator);
+ }
+
+ public void setNodeToolTips(CyNetworkView networkView) {
+ // // grab node attributes
+ // CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
+ //
+ // // iterate through the nodes
+ // Iterator<NodeView> nodesIt =
networkView.getNodeViewsIterator();
+ // while (nodesIt.hasNext()) {
+ // NodeView nodeView = nodesIt.next();
+ // String id = nodeView.getNode().getIdentifier();
+ // String tip =
+ // nodeAttributes.getStringAttribute(id,
+ // MapBioPaxToCytoscape.BIOPAX_ENTITY_TYPE)
+ // + "\n" +
+ // nodeAttributes.getListAttribute(id,
+ // MapBioPaxToCytoscape.BIOPAX_CELLULAR_LOCATIONS);
+ //
+ // nodeView.setToolTip(tip);
+ //
+ // if(log.isDebugging())
+ // log.debug("tooltip set "+ tip + " for node " + id);
+ // }
+ // networkView.updateView();
+ }
}
Modified:
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-07-08 23:28:30 UTC (rev 26126)
+++
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-07-08 23:35:01 UTC (rev 26127)
@@ -37,6 +37,20 @@
<osgi:reference id="streamUtilRef"
interface="org.cytoscape.io.util.StreamUtil" />
+ <osgi:reference id="visualMappingManagerRef"
+ interface="org.cytoscape.view.vizmap.VisualMappingManager" />
+
+ <osgi:reference id="visualStyleFactoryRef"
+ interface="org.cytoscape.view.vizmap.VisualStyleFactory" />
+
+ <osgi:reference id="discreteMappingFunctionFactoryRef"
+
interface="org.cytoscape.view.vizmap.VisualMappingFunctionFactory"
+ filter="(mapping.type=discrete)" />
+
+ <osgi:reference id="passthroughMappingFunctionFactoryRef"
+
interface="org.cytoscape.view.vizmap.VisualMappingFunctionFactory"
+ filter="(mapping.type=passthrough)" />
+
<osgi:service ref="mapBioPaxToCytoscapeFactory"
interface="org.cytoscape.biopax.MapBioPaxToCytoscapeFactory" />
Modified:
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-07-08 23:28:30 UTC (rev 26126)
+++
core3/biopax-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-07-08 23:35:01 UTC (rev 26127)
@@ -66,5 +66,16 @@
<constructor-arg ref="cyNetworkNamingRef"/>
<constructor-arg ref="bioPaxContainer"/>
<constructor-arg ref="networkListener"/>
+ <constructor-arg ref="visualMappingManagerRef"/>
+ <constructor-arg ref="bioPaxVisualStyleUtil"/>
</bean>
+
+ <bean id="bioPaxVisualStyleUtil"
class="org.cytoscape.biopax.util.BioPaxVisualStyleUtil">
+ <constructor-arg ref="visualStyleFactoryRef" />
+ <constructor-arg ref="visualMappingManagerRef" />
+ <constructor-arg ref="discreteMappingFunctionFactoryRef" />
+ <constructor-arg ref="passthroughMappingFunctionFactoryRef" />
+ </bean>
+
+
</beans>
--
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.