| 1 |
define(["dojo/_base/lang", "../util/oo", "./_Base", "../manager/_registry"], |
| 2 |
function(lang, oo, Base, registry){ |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
var Ellipse = oo.declare( |
| 20 |
Base, |
| 21 |
function(options){ |
| 22 |
|
| 23 |
|
| 24 |
}, |
| 25 |
{ |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
type:"dojox.drawing.stencil.Ellipse", |
| 30 |
anchorType: "group", |
| 31 |
baseRender:true, |
| 32 |
dataToPoints: function(o){ |
| 33 |
|
| 34 |
|
| 35 |
o = o || this.data; |
| 36 |
var x = o.cx - o.rx, |
| 37 |
y = o.cy - o.ry, |
| 38 |
w = o.rx*2, |
| 39 |
h = o.ry*2 |
| 40 |
this.points = [ |
| 41 |
{x:x, y:y}, |
| 42 |
{x:x+w, y:y}, |
| 43 |
{x:x+w, y:y+h}, |
| 44 |
{x:x, y:y+h} |
| 45 |
]; |
| 46 |
return this.points; |
| 47 |
}, |
| 48 |
|
| 49 |
pointsToData: function(p){ |
| 50 |
|
| 51 |
|
| 52 |
p = p || this.points; |
| 53 |
var s = p[0]; |
| 54 |
var e = p[2]; |
| 55 |
this.data = { |
| 56 |
cx: s.x + (e.x - s.x)/2, |
| 57 |
cy: s.y + (e.y - s.y)/2, |
| 58 |
rx: (e.x - s.x)*.5, |
| 59 |
ry: (e.y - s.y)*.5 |
| 60 |
}; |
| 61 |
return this.data; |
| 62 |
|
| 63 |
}, |
| 64 |
|
| 65 |
_create: function(shp, d, sty){ |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
this.remove(this[shp]); |
| 72 |
this[shp] = this.container.createEllipse(d) |
| 73 |
.setStroke(sty) |
| 74 |
.setFill(sty.fill); |
| 75 |
this._setNodeAtts(this[shp]); |
| 76 |
}, |
| 77 |
|
| 78 |
render: function(){ |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
this.onBeforeRender(this); |
| 85 |
this.renderHit && this._create("hit", this.data, this.style.currentHit); |
| 86 |
this._create("shape", this.data, this.style.current); |
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
); |
| 91 |
|
| 92 |
lang.setObject("dojox.drawing.stencil.Ellipse", Ellipse); |
| 93 |
registry.register({ |
| 94 |
name:"dojox.drawing.stencil.Ellipse" |
| 95 |
}, "stencil"); |
| 96 |
|
| 97 |
return Ellipse; |
| 98 |
}); |