root / trunk / web / dojo / dojox / drawing / util / positioning.js
History | View | Annotate | Download (1.01 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.drawing.util.positioning"]){ |
||
9 | dojo._hasResource["dojox.drawing.util.positioning"]=true; |
||
10 | dojo.provide("dojox.drawing.util.positioning");
|
||
11 | (function(){
|
||
12 | var _1=4; |
||
13 | var _2=20; |
||
14 | dojox.drawing.util.positioning.label=function(_3,_4){ |
||
15 | var x=0.5*(_3.x+_4.x); |
||
16 | var y=0.5*(_3.y+_4.y); |
||
17 | var _5=dojox.drawing.util.common.slope(_3,_4);
|
||
18 | var _6=_1/Math.sqrt(1+_5*_5); |
||
19 | if(_4.y>_3.y){
|
||
20 | _6=-_6; |
||
21 | } |
||
22 | x+=-_6*_5; |
||
23 | y+=_6; |
||
24 | var _7=_4.x<_3.x?"end":"start"; |
||
25 | if(_4.y>_3.y){
|
||
26 | y-=_2; |
||
27 | } |
||
28 | return {x:x,y:y,foo:"bar",align:_7}; |
||
29 | }; |
||
30 | dojox.drawing.util.positioning.angle=function(_8,_9){ |
||
31 | var x=0.7*_8.x+0.3*_9.x; |
||
32 | var y=0.7*_8.y+0.3*_9.y; |
||
33 | var _a=dojox.drawing.util.common.slope(_8,_9);
|
||
34 | var _b=_1/Math.sqrt(1+_a*_a); |
||
35 | if(_9.x<_8.x){
|
||
36 | _b=-_b; |
||
37 | } |
||
38 | x+=-_b*_a; |
||
39 | y+=_b; |
||
40 | var _c=_9.y>_8.y?"end":"start"; |
||
41 | y+=_9.x>_8.x?0.5*_2:-0.5*_2; |
||
42 | return {x:x,y:y,align:_c}; |
||
43 | }; |
||
44 | })(); |
||
45 | } |