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