/* Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ if(!dojo._hasResource["dojox.drawing.util.positioning"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["dojox.drawing.util.positioning"] = true; dojo.provide("dojox.drawing.util.positioning"); (function(){ var textOffset = 4; // distance from line to text box var textYOffset = 20; // height of text box dojox.drawing.util.positioning.label = function(/*Object*/start, /*Object*/end){ // summary: // Returns the optimal text positions for annotations.Label. // label at middle of vector 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.ystart.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 } })(); }