| 1 |
define(["../util/oo", "../stencil/Path"], |
| 2 |
function(oo, Path){ |
| 3 |
|
| 4 |
|
| 5 |
return oo.declare( |
| 6 |
|
| 7 |
Path, |
| 8 |
function(options){ |
| 9 |
this.stencil.connectMult([ |
| 10 |
[this.stencil, "select", this, "select"], |
| 11 |
[this.stencil, "deselect", this, "deselect"], |
| 12 |
[this.stencil, "render", this, "render"], |
| 13 |
[this.stencil, "onDelete", this, "destroy"] |
| 14 |
]); |
| 15 |
|
| 16 |
this.connect("onBeforeRender", this, function(){ |
| 17 |
var o = this.stencil.points[this.idx1]; |
| 18 |
var c = this.stencil.points[this.idx2]; |
| 19 |
if(this.stencil.getRadius() >= this.minimumSize){ |
| 20 |
this.points = this.arrowHead(c.x, c.y, o.x, o.y, this.style); |
| 21 |
}else{ |
| 22 |
this.points = []; |
| 23 |
} |
| 24 |
}); |
| 25 |
|
| 26 |
}, |
| 27 |
{ |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
idx1:0, |
| 35 |
idx2:1, |
| 36 |
|
| 37 |
subShape:true, |
| 38 |
minimumSize:30, |
| 39 |
|
| 40 |
|
| 41 |
arrowHead: function(x1, y1, x2, y2, style){ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
var obj = { |
| 46 |
start:{ |
| 47 |
x:x1, |
| 48 |
y:y1 |
| 49 |
}, |
| 50 |
x:x2, |
| 51 |
y:y2 |
| 52 |
} |
| 53 |
var angle = this.util.angle(obj); |
| 54 |
|
| 55 |
var lineLength = this.util.length(obj); |
| 56 |
var al = style.arrows.length; |
| 57 |
var aw = style.arrows.width/2; |
| 58 |
if(lineLength<al){ |
| 59 |
al = lineLength/2; |
| 60 |
} |
| 61 |
var p1 = this.util.pointOnCircle(x2, y2, -al, angle-aw); |
| 62 |
var p2 = this.util.pointOnCircle(x2, y2, -al, angle+aw); |
| 63 |
|
| 64 |
return [ |
| 65 |
{x:x2, y:y2}, |
| 66 |
p1, |
| 67 |
p2 |
| 68 |
]; |
| 69 |
} |
| 70 |
|
| 71 |
} |
| 72 |
); |
| 73 |
}); |