//>>built
define("dojox/gfx/shape","./_base,dojo/_base/lang,dojo/_base/declare,dojo/_base/kernel,dojo/_base/sniff,dojo/_base/connect,dojo/_base/array,dojo/dom-construct,dojo/_base/Color,./matrix".split(","),function(d,h,g,q,o,i,l,p,r,f){var e=d.shape={},m={},j={},n=0,s=9>o("ie");e.register=function(a){var b=a.declaredClass.split(".").pop(),c=b in m?++m[b]:m[b]=0,b=b+c;j[b]=a;return b};e.byId=function(a){return j[a]};e.dispose=function(a,b){if(b&&a.children)for(var c=0;c<a.children.length;++c)e.dispose(a.children[c],
!0);delete j[a.getUID()];++n;if(s&&1E4<n){var c=j,d={},k;for(k in c)c.hasOwnProperty(k)&&(d[k]=c[k]);j=d;n=0}};e.Shape=g("dojox.gfx.shape.Shape",null,{constructor:function(){this.parentMatrix=this.parent=this.bbox=this.strokeStyle=this.fillStyle=this.matrix=this.shape=this.rawNode=null;var a=e.register(this);this.getUID=function(){return a}},destroy:function(){e.dispose(this)},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[f.multiplyPoint(b,a.x,a.y),f.multiplyPoint(b,a.x+a.width,a.y),f.multiplyPoint(b,a.x+a.width,a.y+a.height),f.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||h.isArray(a)||a instanceof r)a={color:a};a=this.strokeStyle=d.makeParameters(d.defaultStroke,a);a.color=d.normalizeColor(a.color);return this},setTransform:function(a){this.matrix=f.clone(a?f.normalize(a):f.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?f.clone(a):null;return this._applyTransform()},_getRealMatrix:function(){for(var a=this.matrix,b=this.parent;b;)b.matrix&&(a=f.multiply(b.matrix,a)),b=b.parent;return a}});e._eventsProcessing={connect:function(a,b,c){return i.connect(this.getEventSource(),a,e.fixCallback(this,d.fixTarget,b,c))},disconnect:function(a){i.disconnect(a)}};e.fixCallback=function(a,b,c,d){d||(d=c,c=null);if(h.isString(d)){c=c||q.global;if(!c[d])throw['dojox.gfx.shape.fixCallback: scope["',d,'"] is null (scope="',c,'")'].join("");
return function(e){return b(e,a)?c[d].apply(c,arguments||[]):void 0}}return!c?function(e){return b(e,a)?d.apply(c,arguments):void 0}:function(e){return b(e,a)?d.apply(c,arguments||[]):void 0}};h.extend(e.Shape,e._eventsProcessing);e.Container={_init:function(){this.children=[]},openBatch:function(){},closeBatch:function(){},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){if(!b)a.parent=null,a.parentMatrix=null;this.children.splice(c,1);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;l.forEach(this.children,function(b){var c=b.getBoundingBox();if(c)(b=b.getTransform())&&(c=f.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}});if(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){this.children.splice(b,1);this.children.push(a);break}return this},_moveChildToBack:function(a){for(var b=0;b<this.children.length;++b)if(this.children[b]==a){this.children.splice(b,1);this.children.unshift(a);break}return this}};e.Surface=g("dojox.gfx.shape.Surface",
null,{constructor:function(){this._parent=this.rawNode=null;this._nodes=[];this._events=[]},destroy:function(){l.forEach(this._nodes,p.destroy);this._nodes=[];l.forEach(this._events,i.disconnect);this._events=[];this.rawNode=null;if(o("ie"))for(;this._parent.lastChild;)p.destroy(this._parent.lastChild);else this._parent.innerHTML="";this._parent=null},getEventSource:function(){return this.rawNode},_getRealMatrix:function(){return null},isLoaded:!0,onLoad:function(){},whenLoaded:function(a,b){var c=
h.hitch(a,b);if(this.isLoaded)c(this);else var d=i.connect(this,"onLoad",function(a){i.disconnect(d);c(a)})}});h.extend(e.Surface,e._eventsProcessing);e.Rect=g("dojox.gfx.shape.Rect",e.Shape,{constructor:function(a){this.shape=d.getDefault("Rect");this.rawNode=a},getBoundingBox:function(){return this.shape}});e.Ellipse=g("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=g("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=g("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=g("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=[],d=0;d<b;d+=2)c.push({x:a[d],y:a[d+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],d=c.x,e=c.y,f=c.x,g=c.y,h=1;h<b;++h){c=a[h];if(d>c.x)d=c.x;if(f<c.x)f=c.x;if(e>c.y)e=c.y;if(g<c.y)g=c.y}this.bbox={x:d,y:e,width:f-d,height:g-e}}return this.bbox}});e.Image=g("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=g(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}});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(){return null}};return e});