Author: mes
Date: 2010-02-11 16:55:58 -0800 (Thu, 11 Feb 2010)
New Revision: 19307
Modified:
corelibs/trunk/ding/src/ding/view/DEdgeDetails.java
Log:
a fix for bug 1835 as well as some cleanup and commenting
Modified: corelibs/trunk/ding/src/ding/view/DEdgeDetails.java
===================================================================
--- corelibs/trunk/ding/src/ding/view/DEdgeDetails.java 2010-02-12 00:12:33 UTC
(rev 19306)
+++ corelibs/trunk/ding/src/ding/view/DEdgeDetails.java 2010-02-12 00:55:58 UTC
(rev 19307)
@@ -251,7 +251,8 @@
final FixedGraph graph = (FixedGraph) m_view.m_drawPersp;
- if (graph.edgeSource(edge) == graph.edgeTarget(edge)) { //
Self-edge.
+ // Calculate anchors necessary for self edges.
+ if (graph.edgeSource(edge) == graph.edgeTarget(edge)) {
final int node = graph.edgeSource(edge);
m_view.m_spacial.exists(node, m_extentsBuff, 0);
@@ -293,25 +294,32 @@
};
}
+ // Now add "invisible" anchors to edges for the case where
multiple edges
+ // exist between two nodes. This has no effect if user
specified anchors
+ // exist on the edge.
while (true) {
- {
- final IntIterator otherEdges =
graph.edgesConnecting(graph.edgeSource(edge),
-
graph.edgeTarget(edge), true,
-
true, true);
- m_heap.empty();
+ // sort the connecting edges
+ final IntIterator conEdges =
graph.edgesConnecting(graph.edgeSource(edge),
+
graph.edgeTarget(edge), true,
+
true, true);
+ m_heap.empty();
- while (otherEdges.hasNext())
- m_heap.toss(otherEdges.nextInt());
- }
+ while (conEdges.hasNext())
+ m_heap.toss(conEdges.nextInt());
final IntEnumerator otherEdges =
m_heap.orderedElements(false);
+
int otherEdge = otherEdges.nextInt();
+ // if the first other edge is the same as this edge,
+ // (i.e. we're at the end of the list?), break
if (otherEdge == edge)
break;
+ // so we don't count the other edge twice ?
int i = (((EdgeAnchors)
m_view.getEdgeView(~otherEdge)).numAnchors() == 0) ? 1 : 0;
+ // count the number of other edges
while (true) {
if (edge == (otherEdge = otherEdges.nextInt()))
break;
@@ -321,19 +329,24 @@
}
final int inx = i;
+
+ // get source node size and position
m_view.m_spacial.exists(graph.edgeSource(edge),
m_extentsBuff, 0);
-
final double srcW = ((double) m_extentsBuff[2]) -
m_extentsBuff[0];
final double srcH = ((double) m_extentsBuff[3]) -
m_extentsBuff[1];
final double srcX = (((double) m_extentsBuff[0]) +
m_extentsBuff[2]) / 2.0d;
final double srcY = (((double) m_extentsBuff[1]) +
m_extentsBuff[3]) / 2.0d;
+
+ // get target node size and position
m_view.m_spacial.exists(graph.edgeTarget(edge),
m_extentsBuff, 0);
-
final double trgW = ((double) m_extentsBuff[2]) -
m_extentsBuff[0];
final double trgH = ((double) m_extentsBuff[3]) -
m_extentsBuff[1];
final double trgX = (((double) m_extentsBuff[0]) +
m_extentsBuff[2]) / 2.0d;
final double trgY = (((double) m_extentsBuff[1]) +
m_extentsBuff[3]) / 2.0d;
+
+ // used for determining the space between the edges
final double nodeSize =
Math.max(Math.max(Math.max(srcW, srcH), trgW), trgH);
+
final double midX = (srcX + trgX) / 2;
final double midY = (srcY + trgY) / 2;
final double dx = trgX - srcX;
@@ -343,12 +356,32 @@
if (((float) len) == 0.0f)
break;
+ // this determines which side of the first edge and how
far from the first
+ // edge the other edge should be placed
+ final double factor = ((inx + 1) / 2) * (((inx % 2) ==
0) ? 1 : (-1)) * nodeSize;
+
final double normX = Math.abs(dx / len);
final double normY = Math.abs(dy / len);
- final double factor = ((inx + 1) / 2) * (((inx % 2) ==
0) ? 1 : (-1)) * nodeSize;
- final double anchorX = midX + (factor * normY);
- final double anchorY = midY - (factor * normX);
+ // calculate the anchor points
+ // jump through hoops so that other edge stays properly
oriented as nodes
+ // move relative to one another
+ final double anchorX;
+ final double anchorY;
+ if (srcX <= trgX && srcY <= trgY){
+ anchorX = midX + (factor * normY);
+ anchorY = midY - (factor * normX);
+ } else if (srcX >= trgX && srcY >= trgY) {
+ anchorX = midX - (factor * normY);
+ anchorY = midY + (factor * normX);
+ } else if (srcX <= trgX && srcY >= trgY) {
+ anchorX = midX - (factor * normY);
+ anchorY = midY - (factor * normX);
+ } else { // (srcX >= trgX && srcY <= trgY)
+ anchorX = midX + (factor * normY);
+ anchorY = midY + (factor * normX);
+ }
+
return new EdgeAnchors() {
public int numAnchors() {
return 1;
--
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.