Author: paperwing
Date: 2012-01-30 15:29:01 -0800 (Mon, 30 Jan 2012)
New Revision: 28159

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
Log:
fixes #647 support for sparse edges, such as dashed and dotted edges, is 
implemented for self-edges but due to the short length of the self-edges, not 
many dashes appear. This can be resolved by specifically decreasing dash and 
dot spacing for self-edges in the future.

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-30 23:09:23 UTC (rev 28158)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-30 23:29:01 UTC (rev 28159)
@@ -48,16 +48,9 @@
        private static final float DOTTED_EDGE_RADIUS = 0.017f;
        private static final float DOTTED_EDGE_SPACING = 0.057f;
        
-       private static final double ARC_SELF_EDGE_MINIMUM_RADIUS = 0.04;
+       private static final double ARC_SELF_EDGE_MINIMUM_RADIUS = 0.045;
        private static final double ARC_SELF_EDGE_RADIUS_FACTOR = 0.007;
        
-       private static final Vector3 X_UNIT_VECTOR = new Vector3(1, 0, 0);
-       private static final Vector3 Y_UNIT_VECTOR = new Vector3(0, 1, 0);
-       private static final Vector3 Z_UNIT_VECTOR = new Vector3(0, 0, 1);
-       
-       private static final Vector3 SELF_EDGE_DEFAULT_FACING = new Vector3(1, 
0, 0);
-       private static final Vector3 SELF_EDGE_DEFAULT_ROTATION_AXIS = new 
Vector3(0, 1, 0);
-       
        /**
         * The number of straight segments used to approximate a curved edge
         */
@@ -306,10 +299,10 @@
                double arcAngle = startOffset.angle(endOffset);
                double rotation = arcAngle / segments;
                
-               // Invert the angle and the rotation directin if needed
+               // Invert the angle and the rotation direction if needed
                if (invert) {
                        arcAngle = 2 * Math.PI - arcAngle;
-                       rotation = -rotation;
+                       rotation = -arcAngle / segments;
                }
                
                for (int i = 0; i < segments; i++) {
@@ -343,12 +336,13 @@
                
                Vector3 startOffset = start.subtract(circleCenter);
                Vector3 endOffset = end.subtract(circleCenter);
-               double offsetLength = startOffset.magnitude();
+               double radius = startOffset.magnitude();
                
                // The angular increment to achieve the desired distance 
between points on the
                // arc. This increment is found by applying the cosine law
                double segmentAngle = GeometryToolkit.saferArcCos(
-                               (2 * offsetLength * offsetLength - distance * 
distance) / (2 * offsetLength * offsetLength));
+                               (2 * radius * radius - distance * distance)
+                               / (2 * radius * radius));
                
                double arcAngle = startOffset.angle(endOffset);
                
@@ -367,13 +361,13 @@
                
                // Self-edge suspected, use default normal to avoid division by 0
                if (start.distanceSquared(end) < MIN_LENGTH) {
-                       rotationNormal = startOffset.cross(new Vector3(0, -1, 
0));
+                       rotationNormal = startOffset.cross(new Vector3(0, 1, 
0));
                } else {
                        rotationNormal = startOffset.cross(endOffset);
                }
 
                Vector3 centerCurvePointOffset = startOffset.rotate(
-                               rotationNormal, arcAngle / 2);  
+                               rotationNormal, arcAngle / 2);
                
                // Manually add the first point
                arcCoordinates[0] = start.copy();

-- 
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.

Reply via email to