//>>built
define("dojox/sketch/SingleArrowAnnotation",["dojo/_base/kernel","dojo/_base/lang","./Annotation","./Anchor"],function(d){d.getObject("sketch",!0,dojox);var f=dojox.sketch;f.SingleArrowAnnotation=function(a,b){f.Annotation.call(this,a,b);this.transform={dx:0,dy:0};this.start={x:0,y:0};this.control={x:100,y:-50};this.end={x:200,y:0};this.textPosition={x:0,y:0};this.textOffset=4;this.textYOffset=10;this.rotation=0;this.labelShape=this.arrowheadGroup=this.arrowhead=this.pathShape=null;this.anchors.start=
new f.Anchor(this,"start");this.anchors.control=new f.Anchor(this,"control");this.anchors.end=new f.Anchor(this,"end")};f.SingleArrowAnnotation.prototype=new f.Annotation;d=f.SingleArrowAnnotation.prototype;d.constructor=f.SingleArrowAnnotation;d.type=function(){return"SingleArrow"};d.getType=function(){return f.SingleArrowAnnotation};d._rot=function(){this.rotation=Math.atan2(this.control.y-this.start.y,this.control.x-this.start.x)};d._pos=function(){var a=this.textOffset,b=0,c=0;b=this.calculate.slope(this.control,
this.end);this.textAlign="middle";1<=Math.abs(b)?(b=this.end.x+this.calculate.dx(this.control,this.end,a),c=this.control.y>this.end.y?this.end.y-a:this.end.y+a+this.textYOffset):0==b?(b=this.end.x+a,c=this.end.y+this.textYOffset):(this.start.x>this.end.x?(b=this.end.x-a,this.textAlign="end"):(b=this.end.x+a,this.textAlign="start"),c=this.start.y<this.end.y?this.end.y+this.calculate.dy(this.control,this.end,a)+this.textYOffset:this.end.y+this.calculate.dy(this.control,this.end,-a));this.textPosition=
{x:b,y:c}};d.apply=function(a){if(a){a.documentElement&&(a=a.documentElement);this.readCommonAttrs(a);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("text"==c.localName)this.property("label",c.childNodes.length?c.childNodes[0].nodeValue:"");else if("path"==c.localName){var g=c.getAttribute("d").split(" "),e=g[0].split(",");this.start.x=parseFloat(e[0].substr(1),10);this.start.y=parseFloat(e[1],10);e=g[1].split(",");this.control.x=parseFloat(e[0].substr(1),10);this.control.y=parseFloat(e[1],
10);e=g[2].split(",");this.end.x=parseFloat(e[0],10);this.end.y=parseFloat(e[1],10);g=this.property("stroke");c=c.getAttribute("style");if(e=c.match(/stroke:([^;]+);/))g.color=e[1],this.property("fill",e[1]);if(e=c.match(/stroke-width:([^;]+);/))g.width=e[1];this.property("stroke",g)}}}};d.initialize=function(a){this.apply(a);this._rot();this._pos();dojox.gfx.matrix.rotate(this.rotation);this.shape=this.figure.group.createGroup();this.shape.getEventSource().setAttribute("id",this.id);this.pathShape=
this.shape.createPath("M"+this.start.x+","+this.start.y+" Q"+this.control.x+","+this.control.y+" "+this.end.x+","+this.end.y+" l0,0");this.arrowheadGroup=this.shape.createGroup();this.arrowhead=this.arrowheadGroup.createPath();this.labelShape=this.shape.createText({x:this.textPosition.x,y:this.textPosition.y,text:this.property("label"),align:this.textAlign});this.labelShape.getEventSource().setAttribute("id",this.id+"-labelShape");this.draw()};d.destroy=function(){this.shape&&(this.arrowheadGroup.remove(this.arrowhead),
this.shape.remove(this.arrowheadGroup),this.shape.remove(this.pathShape),this.shape.remove(this.labelShape),this.figure.group.remove(this.shape),this.shape=this.pathShape=this.labelShape=this.arrowheadGroup=this.arrowhead=null)};d.draw=function(a){this.apply(a);this._rot();this._pos();a=dojox.gfx.matrix.rotate(this.rotation);this.shape.setTransform(this.transform);this.pathShape.setShape("M"+this.start.x+","+this.start.y+" Q"+this.control.x+","+this.control.y+" "+this.end.x+","+this.end.y+" l0,0");
this.arrowheadGroup.setTransform({dx:this.start.x,dy:this.start.y}).applyTransform(a);this.arrowhead.setFill(this.property("fill"));this.labelShape.setShape({x:this.textPosition.x,y:this.textPosition.y,text:this.property("label"),align:this.textAlign}).setFill(this.property("fill"));this.zoom()};d.zoom=function(a){if(this.arrowhead&&(a=a||this.figure.zoomFactor,f.Annotation.prototype.zoom.call(this,a),this._curPct!==a)){this._curPct=a;var b=1<a?5:Math.floor(5/a),c=1<a?3:Math.floor(3/a);this.arrowhead.setShape("M0,0 l"+
(1<a?20:Math.floor(20/a))+",-"+b+" -"+c+","+b+" "+c+","+b+" Z")}};d.getBBox=function(){var a=Math.min(this.start.x,this.control.x,this.end.x),b=Math.min(this.start.y,this.control.y,this.end.y);return{x:a,y:b,width:Math.max(this.start.x,this.control.x,this.end.x)-a,height:Math.max(this.start.y,this.control.y,this.end.y)-b}};d.serialize=function(){var a=this.property("stroke"),b=180/Math.PI*this.rotation;b=Math.round(b*Math.pow(10,4))/Math.pow(10,4);return"\x3cg "+this.writeCommonAttrs()+'\x3e\x3cpath style\x3d"stroke:'+
a.color+";stroke-width:"+a.width+';fill:none;" d\x3d"M'+this.start.x+","+this.start.y+" Q"+this.control.x+","+this.control.y+" "+this.end.x+","+this.end.y+'" /\x3e\x3cg transform\x3d"translate('+this.start.x+","+this.start.y+") rotate("+b+')"\x3e\x3cpath style\x3d"fill:'+a.color+';" d\x3d"M0,0 l20,-5, -3,5, 3,5 Z" /\x3e\x3c/g\x3e\x3ctext style\x3d"fill:'+a.color+";text-anchor:"+this.textAlign+'" font-weight\x3d"bold" x\x3d"'+this.textPosition.x+'" y\x3d"'+this.textPosition.y+'"\x3e'+this.property("label")+
"\x3c/text\x3e\x3c/g\x3e"};f.Annotation.register("SingleArrow");return dojox.sketch.SingleArrowAnnotation});