//>>built
define("dojox/gfx/shape","./_base dojo/_base/lang dojo/_base/declare dojo/_base/kernel dojo/_base/sniff dojo/on dojo/_base/array dojo/dom-construct dojo/_base/Color ./matrix".split(" "),function(d,l,k,w,m,u,n,v,x,g){function p(a,b){for(var c=a.length-1;b<c;)a[b]=a[++b];a.length=c}var e=d.shape={};e.Shape=k("dojox.gfx.shape.Shape",null,{constructor:function(){this.parentMatrix=this.parent=this.bbox=this.strokeStyle=this.fillStyle=this.matrix=this.shape=this.rawNode=null;if(m("gfxRegistry")){var a=
e.register(this);this.getUID=function(){return a}}},destroy:function(){m("gfxRegistry")&&e.dispose(this);this.rawNode&&"__gfxObject__"in this.rawNode&&(this.rawNode.__gfxObject__=null);this.rawNode=null},getNode:function(){return this.rawNode},getShape:function(){return this.shape},getTransform:function(){return this.matrix},getFill:function(){return this.fillStyle},getStroke:function(){return this.strokeStyle},getParent:function(){return this.parent},getBoundingBox:function(){return this.bbox},getTransformedBoundingBox:function(){var a=
this.getBoundingBox();if(!a)return null;var b=this._getRealMatrix();return[g.multiplyPoint(b,a.x,a.y),g.multiplyPoint(b,a.x+a.width,a.y),g.multiplyPoint(b,a.x+a.width,a.y+a.height),g.multiplyPoint(b,a.x,a.y+a.height)]},getEventSource:function(){return this.rawNode},setClip:function(a){this.clip=a},getClip:function(){return this.clip},setShape:function(a){this.shape=d.makeParameters(this.shape,a);this.bbox=null;return this},setFill:function(a){if(!a)return this.fillStyle=null,this;var b=null;if("object"==
typeof a&&"type"in a)switch(a.type){case "linear":b=d.makeParameters(d.defaultLinearGradient,a);break;case "radial":b=d.makeParameters(d.defaultRadialGradient,a);break;case "pattern":b=d.makeParameters(d.defaultPattern,a)}else b=d.normalizeColor(a);this.fillStyle=b;return this},setStroke:function(a){if(!a)return this.strokeStyle=null,this;if("string"==typeof a||l.isArray(a)||a instanceof x)a={color:a};a=this.strokeStyle=d.makeParameters(d.defaultStroke,a);a.color=d.normalizeColor(a.color);return this},
setTransform:function(a){this.matrix=g.clone(a?g.normalize(a):g.identity);return this._applyTransform()},_applyTransform:function(){return this},moveToFront:function(){var a=this.getParent();a&&(a._moveChildToFront(this),this._moveToFront());return this},moveToBack:function(){var a=this.getParent();a&&(a._moveChildToBack(this),this._moveToBack());return this},_moveToFront:function(){},_moveToBack:function(){},applyRightTransform:function(a){return a?this.setTransform([this.matrix,a]):this},applyLeftTransform:function(a){return a?
this.setTransform([a,this.matrix]):this},applyTransform:function(a){return a?this.setTransform([this.matrix,a]):this},removeShape:function(a){this.parent&&this.parent.remove(this,a);return this},_setParent:function(a,b){this.parent=a;return this._updateParentMatrix(b)},_updateParentMatrix:function(a){this.parentMatrix=a?g.clone(a):null;return this._applyTransform()},_getRealMatrix:function(){for(var a=this.matrix,b=this.parent;b;)b.matrix&&(a=g.multiply(b.matrix,a)),b=b.parent;return a}});e._eventsProcessing=
{on:function(a,b){return u(this.getEventSource(),a,e.fixCallback(this,d.fixTarget,b))},connect:function(a,b,c){"on"==a.substring(0,2)&&(a=a.substring(2));return this.on(a,c?l.hitch(b,c):b)},disconnect:function(a){return a.remove()}};e.fixCallback=function(a,b,c,f){f||(f=c,c=null);if(l.isString(f)){c=c||w.global;if(!c[f])throw['dojox.gfx.shape.fixCallback: scope["',f,'"] is null (scope\x3d"',c,'")'].join("");return function(h){return b(h,a)?c[f].apply(c,arguments||[]):void 0}}return c?function(h){return b(h,
a)?f.apply(c,arguments||[]):void 0}:function(h){return b(h,a)?f.apply(c,arguments):void 0}};l.extend(e.Shape,e._eventsProcessing);e.Container={_init:function(){this.children=[];this._batch=0},openBatch:function(){return this},closeBatch:function(){return this},add:function(a){var b=a.getParent();b&&b.remove(a,!0);this.children.push(a);return a._setParent(this,this._getRealMatrix())},remove:function(a,b){for(var c=0;c<this.children.length;++c)if(this.children[c]==a){b||(a.parent=null,a.parentMatrix=
null);p(this.children,c);break}return this},clear:function(a){for(var b,c=0;c<this.children.length;++c)b=this.children[c],b.parent=null,b.parentMatrix=null,a&&b.destroy();this.children=[];return this},getBoundingBox:function(){if(this.children){var a=null;n.forEach(this.children,function(b){var c=b.getBoundingBox();c&&((b=b.getTransform())&&(c=g.multiplyRectangle(b,c)),a?(a.x=Math.min(a.x,c.x),a.y=Math.min(a.y,c.y),a.endX=Math.max(a.endX,c.x+c.width),a.endY=Math.max(a.endY,c.y+c.height)):a={x:c.x,
y:c.y,endX:c.x+c.width,endY:c.y+c.height})});a&&(a.width=a.endX-a.x,a.height=a.endY-a.y);return a}return null},_moveChildToFront:function(a){for(var b=0;b<this.children.length;++b)if(this.children[b]==a){p(this.children,b);this.children.push(a);break}return this},_moveChildToBack:function(a){for(var b=0;b<this.children.length;++b)if(this.children[b]==a){p(this.children,b);this.children.unshift(a);break}return this}};e.Surface=k("dojox.gfx.shape.Surface",null,{constructor:function(){this._parent=this.rawNode=
null;this._nodes=[];this._events=[]},destroy:function(){n.forEach(this._nodes,v.destroy);this._nodes=[];n.forEach(this._events,function(a){a&&a.remove()});this._events=[];this.rawNode=null;if(m("ie"))for(;this._parent.lastChild;)v.destroy(this._parent.lastChild);else this._parent.innerHTML="";this._parent=null},getEventSource:function(){return this.rawNode},_getRealMatrix:function(){return null},isLoaded:!0,onLoad:function(a){},whenLoaded:function(a,b){var c=l.hitch(a,b);if(this.isLoaded)c(this);
else u.once(this,"load",function(f){c(f)})}});l.extend(e.Surface,e._eventsProcessing);e.Rect=k("dojox.gfx.shape.Rect",e.Shape,{constructor:function(a){this.shape=d.getDefault("Rect");this.rawNode=a},getBoundingBox:function(){return this.shape}});e.Ellipse=k("dojox.gfx.shape.Ellipse",e.Shape,{constructor:function(a){this.shape=d.getDefault("Ellipse");this.rawNode=a},getBoundingBox:function(){if(!this.bbox){var a=this.shape;this.bbox={x:a.cx-a.rx,y:a.cy-a.ry,width:2*a.rx,height:2*a.ry}}return this.bbox}});
e.Circle=k("dojox.gfx.shape.Circle",e.Shape,{constructor:function(a){this.shape=d.getDefault("Circle");this.rawNode=a},getBoundingBox:function(){if(!this.bbox){var a=this.shape;this.bbox={x:a.cx-a.r,y:a.cy-a.r,width:2*a.r,height:2*a.r}}return this.bbox}});e.Line=k("dojox.gfx.shape.Line",e.Shape,{constructor:function(a){this.shape=d.getDefault("Line");this.rawNode=a},getBoundingBox:function(){if(!this.bbox){var a=this.shape;this.bbox={x:Math.min(a.x1,a.x2),y:Math.min(a.y1,a.y2),width:Math.abs(a.x2-
a.x1),height:Math.abs(a.y2-a.y1)}}return this.bbox}});e.Polyline=k("dojox.gfx.shape.Polyline",e.Shape,{constructor:function(a){this.shape=d.getDefault("Polyline");this.rawNode=a},setShape:function(a,b){a&&a instanceof Array?(this.inherited(arguments,[{points:a}]),b&&this.shape.points.length&&this.shape.points.push(this.shape.points[0])):this.inherited(arguments,[a]);return this},_normalizePoints:function(){var a=this.shape.points,b=a&&a.length;if(b&&"number"==typeof a[0]){for(var c=[],f=0;f<b;f+=
2)c.push({x:a[f],y:a[f+1]});this.shape.points=c}},getBoundingBox:function(){if(!this.bbox&&this.shape.points.length){for(var a=this.shape.points,b=a.length,c=a[0],f=c.x,h=c.y,q=c.x,r=c.y,t=1;t<b;++t)c=a[t],f>c.x&&(f=c.x),q<c.x&&(q=c.x),h>c.y&&(h=c.y),r<c.y&&(r=c.y);this.bbox={x:f,y:h,width:q-f,height:r-h}}return this.bbox}});e.Image=k("dojox.gfx.shape.Image",e.Shape,{constructor:function(a){this.shape=d.getDefault("Image");this.rawNode=a},getBoundingBox:function(){return this.shape},setStroke:function(){return this},
setFill:function(){return this}});e.Text=k(e.Shape,{constructor:function(a){this.fontStyle=null;this.shape=d.getDefault("Text");this.rawNode=a},getFont:function(){return this.fontStyle},setFont:function(a){this.fontStyle="string"==typeof a?d.splitFontString(a):d.makeParameters(d.defaultFont,a);this._setFont();return this},getBoundingBox:function(){var a=null;this.getShape().text&&(a=d._base._computeTextBoundingBox(this));return a}});e.Creator={createShape:function(a){switch(a.type){case d.defaultPath.type:return this.createPath(a);
case d.defaultRect.type:return this.createRect(a);case d.defaultCircle.type:return this.createCircle(a);case d.defaultEllipse.type:return this.createEllipse(a);case d.defaultLine.type:return this.createLine(a);case d.defaultPolyline.type:return this.createPolyline(a);case d.defaultImage.type:return this.createImage(a);case d.defaultText.type:return this.createText(a);case d.defaultTextPath.type:return this.createTextPath(a)}return null},createGroup:function(){return this.createObject(d.Group)},createRect:function(a){return this.createObject(d.Rect,
a)},createEllipse:function(a){return this.createObject(d.Ellipse,a)},createCircle:function(a){return this.createObject(d.Circle,a)},createLine:function(a){return this.createObject(d.Line,a)},createPolyline:function(a){return this.createObject(d.Polyline,a)},createImage:function(a){return this.createObject(d.Image,a)},createText:function(a){return this.createObject(d.Text,a)},createPath:function(a){return this.createObject(d.Path,a)},createTextPath:function(a){return this.createObject(d.TextPath,{}).setText(a)},
createObject:function(a,b){return null}};return e});