| 1 |
define(["dojo/_base/lang", "../util/oo", "./_Base", "../manager/_registry"], |
| 2 |
function(lang, oo, Base, registry){ |
| 3 |
var Line = oo.declare( |
| 4 |
Base, |
| 5 |
function(options){ |
| 6 |
|
| 7 |
|
| 8 |
}, |
| 9 |
{ |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
type:"dojox.drawing.stencil.Line", |
| 14 |
anchorType: "single", |
| 15 |
baseRender:true, |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
dataToPoints: function(o){ |
| 52 |
|
| 53 |
|
| 54 |
o = o || this.data; |
| 55 |
if(o.radius || o.angle){ |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
var pt = this.util.pointOnCircle(o.x,o.y,o.radius,o.angle); |
| 60 |
|
| 61 |
this.data = o = { |
| 62 |
x1:o.x, |
| 63 |
y1:o.y, |
| 64 |
x2:pt.x, |
| 65 |
y2:pt.y |
| 66 |
} |
| 67 |
|
| 68 |
} |
| 69 |
this.points = [ |
| 70 |
{x:o.x1, y:o.y1}, |
| 71 |
{x:o.x2, y:o.y2} |
| 72 |
]; |
| 73 |
return this.points; |
| 74 |
}, |
| 75 |
pointsToData: function(p){ |
| 76 |
|
| 77 |
|
| 78 |
p = p || this.points; |
| 79 |
this.data = { |
| 80 |
x1: p[0].x, |
| 81 |
y1: p[0].y, |
| 82 |
x2: p[1].x, |
| 83 |
y2: p[1].y |
| 84 |
}; |
| 85 |
return this.data; |
| 86 |
}, |
| 87 |
|
| 88 |
_create: function(shp, d, sty){ |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
this.remove(this[shp]); |
| 95 |
this[shp] = this.container.createLine(d) |
| 96 |
.setStroke(sty); |
| 97 |
this._setNodeAtts(this[shp]); |
| 98 |
}, |
| 99 |
|
| 100 |
render: function(){ |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
this.onBeforeRender(this); |
| 107 |
this.renderHit && this._create("hit", this.data, this.style.currentHit); |
| 108 |
this._create("shape", this.data, this.style.current); |
| 109 |
|
| 110 |
} |
| 111 |
|
| 112 |
} |
| 113 |
); |
| 114 |
|
| 115 |
lang.setObject("dojox.drawing.stencil.Line", Line); |
| 116 |
registry.register({ |
| 117 |
name:"dojox.drawing.stencil.Line" |
| 118 |
}, "stencil"); |
| 119 |
|
| 120 |
return Line; |
| 121 |
}); |