Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 4d1748ae1 -> f9599ffab


DISPATCH-435 Take node radius into account when dragging on console's topology 
page. Also fixes DISPATCH-436


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/f9599ffa
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/f9599ffa
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/f9599ffa

Branch: refs/heads/master
Commit: f9599ffab261c39a5f27c52e87f7fc48cea8eb19
Parents: 4d1748a
Author: Ernest Allen <[email protected]>
Authored: Wed Aug 3 08:46:23 2016 -0400
Committer: Ernest Allen <[email protected]>
Committed: Wed Aug 3 08:46:23 2016 -0400

----------------------------------------------------------------------
 .../src/main/webapp/plugin/js/qdrTopology.js    | 52 ++++++++++++--------
 1 file changed, 31 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/f9599ffa/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
----------------------------------------------------------------------
diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js 
b/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
index 567a494..795549a 100644
--- a/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
+++ b/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
@@ -846,30 +846,47 @@ var QDR = (function (QDR) {
 
            // update force layout (called automatically each iteration)
            function tick() {
+               circle.attr('transform', function (d) {
+                var cradius;
+                if (d.nodeType == "inter-router") {
+                                       cradius = d.left ? radius + 8  : radius;
+                } else {
+                                       cradius = d.left ? radiusNormal + 18  : 
radiusNormal;
+                }
+                   d.x = Math.max(d.x, radiusNormal * 2);
+                   d.y = Math.max(d.y, radiusNormal * 2);
+                               d.x = Math.max(0, Math.min(width-cradius, d.x))
+                               d.y = Math.max(0, Math.min(height-cradius, d.y))
+                   return 'translate(' + d.x + ',' + d.y + ')';
+               });
+
                // draw directed edges with proper padding from node centers
                path.attr('d', function (d) {
                                //QDR.log.debug("in tick for d");
                                //console.dump(d);
-                               var dtx = Math.max(0, Math.min(width, 
d.target.x)),
-                                   dty = Math.max(0, Math.min(height, 
d.target.y)),
-                                   dsx = Math.max(0, Math.min(width, 
d.source.x)),
-                                       dsy = Math.max(0, Math.min(height, 
d.source.y));
+                var sourcePadding, targetPadding, r;
+
+                if (d.target.nodeType == "inter-router") {
+                                       r = radius;
+                                       //                       right arrow  
left line start
+                                       sourcePadding = d.left ? radius + 8  : 
radius;
+                                       //                      left arrow      
right line start
+                                       targetPadding = d.right ? radius + 16 : 
radius;
+                } else {
+                                       r = radiusNormal - 18;
+                                       sourcePadding = d.left ? radiusNormal + 
18  : radiusNormal;
+                                       targetPadding = d.right ? radiusNormal 
+ 16 : radiusNormal;
+                }
+                               var dtx = Math.max(targetPadding, 
Math.min(width-r, d.target.x)),
+                                   dty = Math.max(targetPadding, 
Math.min(height-r, d.target.y)),
+                                   dsx = Math.max(sourcePadding, 
Math.min(width-r, d.source.x)),
+                                       dsy = Math.max(sourcePadding, 
Math.min(height-r, d.source.y));
 
                    var deltaX = dtx - dsx,
                        deltaY = dty - dsy,
                        dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
                        normX = deltaX / dist,
                        normY = deltaY / dist;
-                       var sourcePadding, targetPadding;
-                       if (d.target.nodeType == "inter-router") {
-                                               //                       right 
arrow  left line start
-                                               sourcePadding = d.left ? radius 
+ 8  : radius;
-                                               //                      left 
arrow      right line start
-                                               targetPadding = d.right ? 
radius + 16 : radius;
-                       } else {
-                                               sourcePadding = d.left ? 
radiusNormal + 18  : radiusNormal;
-                                               targetPadding = d.right ? 
radiusNormal + 16 : radiusNormal;
-                       }
                        var sourceX = dsx + (sourcePadding * normX),
                        sourceY = dsy + (sourcePadding * normY),
                        targetX = dtx - (targetPadding * normX),
@@ -882,13 +899,6 @@ var QDR = (function (QDR) {
                    return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' 
+ targetY;
                });
 
-               circle.attr('transform', function (d) {
-                   d.x = Math.max(d.x, radiusNormal * 2);
-                   d.y = Math.max(d.y, radiusNormal * 2);
-                               d.x = Math.max(0, Math.min(width, d.x))
-                               d.y = Math.max(0, Math.min(height, d.y))
-                   return 'translate(' + d.x + ',' + d.y + ')';
-               });
                if (!animate) {
                    animate = true;
                    force.stop();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to