| 1 |
define(["dojo/_base/lang", "../util/oo", "../manager/_registry", "./Line", |
| 2 |
"../annotations/Arrow", "../util/positioning"], |
| 3 |
function(lang, oo, registry, Line, AnnotationArrow, positioning){ |
| 4 |
|
| 5 |
var Arrow = oo.declare( |
| 6 |
Line, |
| 7 |
function(options){ |
| 8 |
|
| 9 |
|
| 10 |
if(this.arrowStart){ |
| 11 |
this.begArrow = new AnnotationArrow({stencil:this, idx1:0, idx2:1}); |
| 12 |
} |
| 13 |
if(this.arrowEnd){ |
| 14 |
this.endArrow = new AnnotationArrow({stencil:this, idx1:1, idx2:0}); |
| 15 |
} |
| 16 |
if(this.points.length){ |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
this.render(); |
| 21 |
options.label && this.setLabel(options.label); |
| 22 |
} |
| 23 |
}, |
| 24 |
{ |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
draws:true, |
| 30 |
type:"dojox.drawing.tools.Arrow", |
| 31 |
baseRender:false, |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
arrowStart:false, |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
arrowEnd:true, |
| 40 |
|
| 41 |
labelPosition: function(){ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
var d = this.data; |
| 46 |
var pt = positioning.label({x:d.x1,y:d.y1},{x:d.x2,y:d.y2}); |
| 47 |
return { |
| 48 |
x:pt.x, |
| 49 |
y:pt.y |
| 50 |
} |
| 51 |
}, |
| 52 |
|
| 53 |
onUp: function(obj){ |
| 54 |
if(this.created || !this.shape){ return; } |
| 55 |
|
| 56 |
|
| 57 |
var p = this.points; |
| 58 |
var len = this.util.distance(p[0].x,p[0].y,p[1].x,p[1].y); |
| 59 |
if(len<this.minimumSize){ |
| 60 |
this.remove(this.shape, this.hit); |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
var pt = this.util.snapAngle(obj, this.angleSnap/180); |
| 65 |
this.setPoints([ |
| 66 |
{x:p[0].x, y:p[0].y}, |
| 67 |
{x:pt.x, y:pt.y} |
| 68 |
]); |
| 69 |
|
| 70 |
this.renderedOnce = true; |
| 71 |
this.onRender(this); |
| 72 |
} |
| 73 |
} |
| 74 |
); |
| 75 |
|
| 76 |
lang.setObject("dojox.drawing.tools.Arrow", Arrow); |
| 77 |
Arrow.setup = { |
| 78 |
name:"dojox.drawing.tools.Arrow", |
| 79 |
tooltip:"Arrow Tool", |
| 80 |
iconClass:"iconArrow" |
| 81 |
}; |
| 82 |
|
| 83 |
registry.register(Arrow.setup, "tool"); |
| 84 |
|
| 85 |
return Arrow; |
| 86 |
}); |