Author: kono
Date: 2012-03-16 15:07:16 -0700 (Fri, 16 Mar 2012)
New Revision: 28570

Modified:
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/HandleImpl.java
Log:
Boundary conditions had been modified to handle negative-direction vector 
rotation.

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/HandleImpl.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/HandleImpl.java
     2012-03-16 21:43:48 UTC (rev 28569)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/HandleImpl.java
     2012-03-16 22:07:16 UTC (rev 28570)
@@ -46,6 +46,7 @@
                final Double tY = 
targetView.getVisualProperty(DVisualLexicon.NODE_Y_LOCATION);
 
                final Point2D newPoint = new Point2D.Double();
+               
                if (EditMode.isDirectMode() == false) {
                        
                        // Original edge vector v = (vx, vy).  (from source to 
target)
@@ -131,23 +132,32 @@
                
                // Now we can get the Cos(theta)
                cosTheta = lengthVp/dist1;
-               // Theta is the angle between v1 and v2
-               final double theta = Math.acos(cosTheta);
+               
+//             // Theta is the angle between v1 and v2
+               double theta = Math.acos(cosTheta);
+               
+               // Adjust angle if >PI/2
+               if(dotProduct<0) {
+                       // PI/2< theta <=PI
+                       theta = Math.PI-theta;
+                       cosTheta = Math.cos(theta);
+               }
                sinTheta = Math.sin(theta);
                
+//             System.out.println("## Dot prod = " + dotProduct);
+//             System.out.println("** cos = " + cosTheta);
+//             System.out.println("** sin = " + sinTheta);
+               
                // Check direction of rotation
-               final double slopeE = (tY-sY)/(tX-sX);
-               final double slopeH = (hY-sY)/(hX-sX);
-               if((sX<=tX && sY <= tY) || (sX>tX && sY > tY)) {
-                       if(slopeE>=slopeH) {
-                               cosTheta = Math.cos(-theta);
-                               sinTheta = Math.sin(-theta);
-                       }
+               final double slopeE = (tY-sY)/(tX-sX);          
+               
+               // Rotate to opposite direction
+               if((sX<=tX && sY <= tY) || (sX<tX && sY > tY)) {
+                       if (slopeE * hX > hY)
+                               sinTheta = -sinTheta;
                } else {
-                       if(slopeE<=slopeH) {
-                               cosTheta = Math.cos(-theta);
-                               sinTheta = Math.sin(-theta);
-                       }
+                       if (slopeE * hX < hY)
+                               sinTheta = -sinTheta;
                }
 
 //             System.out.println("** (Sx, Sy) = (" + sX + ", " + sY + ")");

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