Author: paperwing
Date: 2012-03-19 15:53:28 -0700 (Mon, 19 Mar 2012)
New Revision: 28584
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSimplifiedEdgesProcedure.java
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MainInputProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/EdgeShapeDrawer.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
Log:
Added RenderSimplifiedEdgesProcedure to allow having bird's eye view draw a
simplified version of the edges, but testing with drawing edges using only
lines did not yield a noticeable framerate improvement. However, lines may be
useful as they do not become broken up into segments when drawn far from the
camera.
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -31,6 +31,7 @@
import org.cytoscape.paperwing.internal.rendering.RenderBoundingBoxProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderNodesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderSelectionBoxProcedure;
+import
org.cytoscape.paperwing.internal.rendering.RenderSimplifiedEdgesProcedure;
import org.cytoscape.paperwing.internal.rendering.ResetSceneProcedure;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.VisualLexicon;
@@ -148,7 +149,6 @@
public void processPicking(MouseMonitor mouse,
KeyboardMonitor keys, GraphicsData
graphicsData) {
}
-
};
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -236,7 +236,7 @@
gl.glEnable(GL2.GL_LIGHTING);
gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT,
FloatBuffer.wrap(global));
- gl.glShadeModel(GL2.GL_FLAT);
+ gl.glShadeModel(GL2.GL_SMOOTH);
/*
float[] ambient = { 0.4f, 0.4f, 0.4f, 1.0f };
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -91,7 +91,7 @@
1.0, ARBITRARY_DOUBLE_RANGE, "LIGHT_Y_LOCATION", "Light
Y Location", CyNetwork.class);
public static final VisualProperty<Double> LIGHT_Z_LOCATION = new
DoubleVisualProperty(
- -1.0, ARBITRARY_DOUBLE_RANGE, "LIGHT_Z_LOCATION",
"Light Z Location", CyNetwork.class);
+ 2.0, ARBITRARY_DOUBLE_RANGE, "LIGHT_Z_LOCATION", "Light
Z Location", CyNetwork.class);
public static final VisualProperty<Boolean> LIGHT_ENABLED = new
BooleanVisualProperty(
true, "LIGHT_ENABLED", "Light Enabled",
CyNetwork.class);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -12,6 +12,7 @@
import org.cytoscape.paperwing.internal.geometric.Vector3;
import org.cytoscape.paperwing.internal.tools.EdgeCoordinateCalculator;
import org.cytoscape.paperwing.internal.tools.GeometryToolkit;
+import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.property.BasicVisualLexicon;
@@ -112,15 +113,11 @@
edge = edgeView.getModel();
- // Assign an identifier to each pair of nodes
sourceIndex = edge.getSource().getIndex();
targetIndex = edge.getTarget().getIndex();
- if (sourceIndex >= targetIndex) {
- identifier = (long) nodeCount * sourceIndex +
targetIndex;
- } else {
- identifier = (long) nodeCount * targetIndex +
sourceIndex;
- }
+ // Assign an identifier to each pair of nodes
+ identifier =
NetworkToolkit.obtainPairIdentifier(edge.getSource(), edge.getTarget(),
networkView.getNodeViews().size());
// Assign a value that represents how many edges have
been found between this pair
if (!pairCoincidenceCount.containsKey(identifier)) {
@@ -141,8 +138,8 @@
}
// Find edge start and end points
-
edgeContainer.setStart(obtainCoordinates(edge.getSource(), networkView,
distanceScale));
-
edgeContainer.setEnd(obtainCoordinates(edge.getTarget(), networkView,
distanceScale));
+
edgeContainer.setStart(NetworkToolkit.obtainNodeCoordinates(edge.getSource(),
networkView, distanceScale));
+
edgeContainer.setEnd(NetworkToolkit.obtainNodeCoordinates(edge.getTarget(),
networkView, distanceScale));
// Determine if edge has sufficient length to be drawn
if (edgeContainer.getStart() != null &&
edgeContainer.getEnd() != null &&
@@ -339,23 +336,4 @@
}
}
}
-
- // Obtain the coordinates of a given node, eg. source or target node
- // Returns null if failed to find coordinates
- private Vector3 obtainCoordinates(CyNode node, CyNetworkView
networkView, double distanceScale) {
- Vector3 coordinates = null;
-
- View<CyNode> nodeView = networkView.getNodeView(node);
-
- if (nodeView != null) {
- double x =
nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION) / distanceScale;
- double y =
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION) / distanceScale;
- double z =
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION) / distanceScale;
-
- // TODO: Perform a check to ensure none of x, y, z are
null?
- coordinates = new Vector3(x, y, z);
- }
-
- return coordinates;
- }
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MainInputProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MainInputProcessor.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MainInputProcessor.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -20,7 +20,7 @@
inputHandlers.add(new SelectionInputHandler());
inputHandlers.add(new NetworkChangeInputHandler());
- inputHandlers.add(new LightMovementInputHandler());
+ // inputHandlers.add(new LightMovementInputHandler());
inputHandlers.add(new ContextMenuInputHandler());
inputHandlers.add(new DebugInputHandler());
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSimplifiedEdgesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSimplifiedEdgesProcedure.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSimplifiedEdgesProcedure.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -0,0 +1,79 @@
+package org.cytoscape.paperwing.internal.rendering;
+
+import java.nio.FloatBuffer;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.media.opengl.GL2;
+
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.geometric.Vector3;
+import org.cytoscape.paperwing.internal.rendering.shapes.EdgeShapeDrawer;
+import
org.cytoscape.paperwing.internal.rendering.shapes.EdgeShapeDrawer.EdgeShapeType;
+import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
+import org.cytoscape.paperwing.internal.tools.RenderToolkit;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+
+/**
+ * This procedure renders edges in a simplified form for the bird's eye view.
+ */
+public class RenderSimplifiedEdgesProcedure implements
+ ReadOnlyGraphicsProcedure {
+
+ private EdgeShapeDrawer shapeDrawer;
+
+ @Override
+ public void initialize(GraphicsData graphicsData) {
+ shapeDrawer = new EdgeShapeDrawer();
+ shapeDrawer.initialize(graphicsData.getGlContext());
+ }
+
+ @Override
+ public void execute(GraphicsData graphicsData) {
+ CyNetworkView networkView = graphicsData.getNetworkView();
+ GL2 gl = graphicsData.getGlContext();
+
+ float[] specularReflection = { 0.1f, 0.1f, 0.1f, 1.0f };
+ gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR,
+ FloatBuffer.wrap(specularReflection));
+ gl.glMateriali(GL2.GL_FRONT, GL2.GL_SHININESS, 1);
+
+ double distanceScale = graphicsData.getDistanceScale();
+
+ // A set containing all pairs of nodes that have had an edge
drawn between them
+ Set<Long> drawnPairs = new
HashSet<Long>(networkView.getNodeViews().size());
+ CyNode source, target;
+
+ for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
+ source = edgeView.getModel().getSource();
+ target = edgeView.getModel().getTarget();
+
+ long pairIdentifier =
NetworkToolkit.obtainPairIdentifier(source, target,
networkView.getModel().getNodeList().size());
+
+ // Only draw an edge between this source-target pair if
one has not been drawn already
+ if (!drawnPairs.contains(pairIdentifier)) {
+
+ Vector3 start =
NetworkToolkit.obtainNodeCoordinates(source, networkView, distanceScale);
+ Vector3 end =
NetworkToolkit.obtainNodeCoordinates(target, networkView, distanceScale);
+ Vector3 displacement = end.subtract(start);
+
+ gl.glPushMatrix();
+
+ // Setup transformations to draw the shape
+ RenderToolkit.setUpFacingTransformation(gl,
start, displacement);
+ gl.glScalef(1.0f, 1.0f, (float)
displacement.magnitude());
+
+ // Perform drawing
+ shapeDrawer.drawSegment(gl,
EdgeShapeType.REGULAR_LINE_BASED);
+
+ gl.glPopMatrix();
+
+ drawnPairs.add(pairIdentifier);
+ }
+ }
+ }
+
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSimplifiedEdgesProcedure.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/EdgeShapeDrawer.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/EdgeShapeDrawer.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/EdgeShapeDrawer.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -112,7 +112,7 @@
* Performs initialization for drawing a segment of a line, but uses
OpenGL lines instead of polygons to perform the drawing.
* The segment has length 1, and extends from the origin towards the
positive z-axis.
*/
- public void initializeLineBasedSegment(GL2 gl) {
+ private void initializeLineBasedSegment(GL2 gl) {
int listIndex = gl.glGenLists(1);
gl.glNewList(listIndex, GL2.GL_COMPILE);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
2012-03-19 20:46:20 UTC (rev 28583)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
2012-03-19 22:53:28 UTC (rev 28584)
@@ -219,4 +219,55 @@
return false;
}
}
+
+ /**
+ * Obtain the coordinates of a given node.
+ *
+ * @param node The node whose coordinates are to be obtained
+ * @param networkView The {@link CyNetworkView} containing the node
+ * @param distanceScale The distance scale ratio used to convert from
Cytoscape coordinates
+ * @return A {@link Vector3} object containing the coordinates, or
<code>null</code> otherwise, such
+ * as if no such node was found.
+ */
+ public static Vector3 obtainNodeCoordinates(CyNode node, CyNetworkView
networkView, double distanceScale) {
+ Vector3 coordinates = null;
+
+ View<CyNode> nodeView = networkView.getNodeView(node);
+
+ if (nodeView != null) {
+ double x =
nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION) / distanceScale;
+ double y =
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION) / distanceScale;
+ double z =
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION) / distanceScale;
+
+ // TODO: Perform a check to ensure none of x, y, z are
null?
+ coordinates = new Vector3(x, y, z);
+ }
+
+ return coordinates;
+ }
+
+ /**
+ * Find a temporary identifier that can uniquely identify a pair of
nodes, ignoring the order of the nodes.
+ * The identifier is valid as long as the size of the network does not
exceed the given network size.
+ *
+ * @param source The source node
+ * @param target The target node
+ * @param networkSize The number of nodes in the network. If the
network grew, the identifiers are no
+ * longer guaranteed to be unique.
+ * @return An identifier that uniquely identifies the pair of nodes,
ignoring the order of the nodes.
+ */
+ public static long obtainPairIdentifier(CyNode source, CyNode target,
int networkSize) {
+ long identifier;
+
+ int sourceIndex = source.getIndex();
+ int targetIndex = target.getIndex();
+
+ if (sourceIndex >= targetIndex) {
+ identifier = (long) networkSize * sourceIndex +
targetIndex;
+ } else {
+ identifier = (long) networkSize * targetIndex +
sourceIndex;
+ }
+
+ return identifier;
+ }
}
--
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.