Author: paperwing
Date: 2012-01-17 08:56:30 -0800 (Tue, 17 Jan 2012)
New Revision: 28030
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ShapeProducer.java
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
Log:
Updated algorithm for analyzing the network to determine for each edge its
index amongst the other edges that connect the same pair of nodes, as well as
the total number of edges that connect the same pair of nodes. This is useful
for spreading out the edges during rendering so that edges are not drawn on top
of each other.
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-01-17 15:41:08 UTC (rev 28029)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-01-17 16:56:30 UTC (rev 28030)
@@ -40,11 +40,21 @@
private int segmentListIndex;
+ // Container for EdgeView objects that also adds information about
whether the
+ // edge is part of a series of edges that connect the same pair of nodes
private class EdgeViewContainer {
- private View<CyEdge> edgeView;
+ protected View<CyEdge> edgeView;
- private int edgeNumber;
- private int totalCoincidentEdges;
+ // Identifies the pair of nodes that the edge connects
+ protected long pairIdentifier;
+
+ // The index of this edge compared to all the other edges that
connect the same pair
+ // of nodes. If this is the first of 7 edges that connect the
same pair of nodes, its
+ // edgeNumber would be set to 1.
+ protected int edgeNumber;
+
+ // The total number of edges that connect the pair of nodes.
+ protected int totalCoincidentEdges;
}
// Analyze the network to obtain whether each edge is connecting 2
nodes that
@@ -52,15 +62,24 @@
// Maybe add an optimization so we only have to re-analyze the network
each time it changes?
private Set<EdgeViewContainer> analyzeEdges(CyNetworkView networkView) {
- // A pair of nodes will be identified by index1 * index2 +
index1, where index1
- // is the higher of the 2 indices
- Map<Long, Integer> pairs = new HashMap<Long, Integer>(
+ // Create the set of containers to be returned
+ Set<EdgeViewContainer> edgeViewContainers = new
HashSet<EdgeViewContainer>(
+ networkView.getModel().getEdgeCount());
+
+ // This map maps each node-pair identifier to the number of
edges between that pair of nodes
+ // The identifier is: max(sourceIndex, targetIndex) * nodeCount
+ min(sourceIndex, targetIndex)
+ Map<Long, Integer> pairCoincidenceCount = new HashMap<Long,
Integer>(
networkView.getModel().getNodeCount());
long identifier;
int sourceIndex, targetIndex;
int nodeCount = networkView.getModel().getNodeCount();
+ CyEdge edge;
+ int edgeNumber;
- for (CyEdge edge : networkView.getModel().getEdgeList()) {
+ // Assign an identifier to each pair of nodes
+ for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
+ edge = edgeView.getModel();
+
sourceIndex = edge.getSource().getIndex();
targetIndex = edge.getTarget().getIndex();
@@ -70,23 +89,31 @@
identifier = (long) nodeCount * targetIndex +
sourceIndex;
}
- if (!pairs.containsKey(identifier)) {
- pairs.put(identifier, 1);
+ // Assign a value that represents how many edges have
been found between this pair
+ if (!pairCoincidenceCount.containsKey(identifier)) {
+ edgeNumber = 1;
} else {
- pairs.put(identifier, pairs.get(identifier) +
1);
+ edgeNumber =
pairCoincidenceCount.get(identifier) + 1;
}
+
+ pairCoincidenceCount.put(identifier, edgeNumber);
+
+ EdgeViewContainer container = new EdgeViewContainer();
+ container.edgeView = edgeView;
+ container.pairIdentifier = identifier;
+ container.edgeNumber = edgeNumber;
+
+ edgeViewContainers.add(container);
}
- Set<EdgeViewContainer> edgeViewContainers = new
HashSet<EdgeViewContainer>(
- networkView.getModel().getEdgeCount());
-
- EdgeViewContainer container;
- for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
- // container = new
+ // Update the value for the total number of edges between this
pair of nodes
+ for (EdgeViewContainer container : edgeViewContainers) {
+ container.totalCoincidentEdges =
pairCoincidenceCount.get(container.pairIdentifier);
}
- return null;
+ return edgeViewContainers;
}
+
@Override
public void initialize(GraphicsData graphicsData) {
@@ -199,9 +226,11 @@
double nearCornerAngle = Math.PI / 2 - (arcAngle / 2);
+ // Set the angle of rotation along the node-to-node
displacement axis
Vector3 targetDirection = new Vector3(0, 0, 1);
targetDirection = targetDirection.rotate(displacement, angle);
+ // Offset vector that points from first node to the circle's
center
Vector3 circleCenterOffset =
displacement.rotate(targetDirection.cross(displacement), nearCornerAngle);
circleCenterOffset.normalizeLocal();
circleCenterOffset.multiplyLocal(radius);
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ShapeProducer.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ShapeProducer.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ShapeProducer.java
2012-01-17 16:56:30 UTC (rev 28030)
@@ -0,0 +1,9 @@
+package org.cytoscape.paperwing.internal.rendering.shapes;
+
+public class ShapeProducer {
+ public static enum ShapeType {
+ SHAPE_CUBIC,
+ SHAPE_TETRAHEDRAL};
+
+
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ShapeProducer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
--
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.