root / trunk / web / dojo / dojox / drawing / annotations / Arrow.js
History | View | Annotate | Download (1.31 KB)
1 |
/*
|
---|---|
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.annotations.Arrow"]){ |
9 |
dojo._hasResource["dojox.drawing.annotations.Arrow"]=true; |
10 |
dojo.provide("dojox.drawing.annotations.Arrow");
|
11 |
dojo.require("dojox.drawing.stencil.Path");
|
12 |
dojox.drawing.annotations.Arrow=dojox.drawing.util.oo.declare(dojox.drawing.stencil.Path,function(_1){
|
13 |
this.stencil.connectMult([[this.stencil,"select",this,"select"],[this.stencil,"deselect",this,"deselect"],[this.stencil,"render",this,"render"],[this.stencil,"onDelete",this,"destroy"]]); |
14 |
this.connect("onBeforeRender",this,function(){ |
15 |
var o=this.stencil.points[this.idx1]; |
16 |
var c=this.stencil.points[this.idx2]; |
17 |
if(this.stencil.getRadius()>=this.minimumSize){ |
18 |
this.points=this.arrowHead(c.x,c.y,o.x,o.y,this.style); |
19 |
}else{
|
20 |
this.points=[];
|
21 |
} |
22 |
}); |
23 |
},{idx1:0,idx2:1,subShape:true,minimumSize:30,arrowHead:function(x1,y1,x2,y2,_2){ |
24 |
var _3={start:{x:x1,y:y1},x:x2,y:y2}; |
25 |
var _4=this.util.angle(_3); |
26 |
var _5=this.util.length(_3); |
27 |
var al=_2.arrows.length;
|
28 |
var aw=_2.arrows.width/2; |
29 |
if(_5<al){
|
30 |
al=_5/2;
|
31 |
} |
32 |
var p1=this.util.pointOnCircle(x2,y2,-al,_4-aw); |
33 |
var p2=this.util.pointOnCircle(x2,y2,-al,_4+aw); |
34 |
return [{x:x2,y:y2},p1,p2]; |
35 |
}}); |
36 |
} |