dojox/drawing/util/positioning.js

  • Provides:

    • dojox.drawing.util.positioning
  • dojox.drawing.util.positioning.label

    • type
      Function
    • parameters:
      • start: (typeof Object)
      • end: (typeof Object)
    • source: [view]
        var x = 0.5*(start.x+end.x);
        var y = 0.5*(start.y+end.y);

        
        // move label a set distance from the line
        var slope = dojox.drawing.util.common.slope(start, end);
        var deltay = textOffset/Math.sqrt(1.0+slope*slope);

        
        if(end.y>start.y && end.x>start.x || end.y   // Position depending on quadrant. Y offset
         // positions box aligned vertically from top
         deltay = -deltay;
         y -= textYOffset;
        }
        x += -deltay*slope;
        y += deltay;

        
        // want text to be away from start of vector
        // This will make force diagrams less crowded
        var align = end.x
        
        return { x:x, y:y, foo:"bar", align:align}; // Object
    • summary
      Returns the optimal text positions for annotations.Label.
      
      label at middle of vector
    • returns
      Object
  • dojox.drawing.util.positioning.angle

    • type
      Function
    • parameters:
      • start: (typeof Object)
      • end: (typeof Object)
    • source: [view]
        var x = 0.7*start.x+0.3*end.x;
        var y = 0.7*start.y+0.3*end.y;
        // move label a set distance from the line
        var slope = dojox.drawing.util.common.slope(start, end);
        var deltay = textOffset/Math.sqrt(1.0+slope*slope);

        
        if(end.x  x += -deltay * slope;
        y += deltay;

        
        // want text to be clockwise from vector
        // to match angle measurement from x-axis
        var align = end.y>start.y ? "end" : "start";
        // box vertical aligned from middle
        y += end.x > start.x ? 0.5*textYOffset : -0.5*textYOffset;

        
        return { x:x, y:y, align:align}; // Object
    • summary
      Returns the optimal position for annotations.Angle.
      
      angle at first third of vector
    • returns
      Object
  • dojox.drawing.util.positioning

    • type
      Object
    • summary
  • dojox.drawing.util

    • type
      Object
    • summary
  • dojox.drawing

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary