//>>built
define("dojox/sketch/DoubleArrowAnnotation",["dojo/_base/kernel","dojo/_base/lang","./Annotation","./Anchor"],function(d){d.getObject("sketch",!0,dojox);var f=dojox.sketch;f.DoubleArrowAnnotation=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=6;this.textYOffset=10;this.textAlign="middle";this.endRotation=this.startRotation=0;this.endArrowGroup=this.endArrow=this.startArrowGroup=
this.startArrow=this.pathShape=this.labelShape=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.DoubleArrowAnnotation.prototype=new f.Annotation;d=f.DoubleArrowAnnotation.prototype;d.constructor=f.DoubleArrowAnnotation;d.type=function(){return"DoubleArrow"};d.getType=function(){return f.DoubleArrowAnnotation};d._rot=function(){var a=this.control.y-this.start.y,b=this.control.x-this.start.x;this.startRotation=
Math.atan2(a,b);a=this.end.y-this.control.y;b=this.end.x-this.control.x;this.endRotation=Math.atan2(a,b)};d._pos=function(){var a=this.textOffset;a=this.control.y<this.end.y?-1*a:a+this.textYOffset;var b=.5*(this.control.x-this.start.x)+this.start.x,c=.5*(this.control.y-this.start.y)+this.start.y;this.textPosition={x:.5*(.5*(this.end.x-this.control.x)+this.control.x-b)+b,y:.5*(.5*(this.end.y-this.control.y)+this.control.y-c)+c+a}};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();var b=this.startRotation;a=dojox.gfx.matrix.rotate(b);b=this.endRotation;b=dojox.gfx.matrix.rotateAt(b,this.end.x,this.end.y);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.startArrowGroup=this.shape.createGroup().setTransform({dx:this.start.x,dy:this.start.y});this.startArrowGroup.applyTransform(a);this.startArrow=this.startArrowGroup.createPath();this.endArrowGroup=this.shape.createGroup().setTransform(b);this.endArrow=this.endArrowGroup.createPath();this.labelShape=this.shape.createText({x:this.textPosition.x,y:this.textPosition.y,
text:this.property("label"),align:this.textAlign}).setFill(this.property("fill"));this.labelShape.getEventSource().setAttribute("id",this.id+"-labelShape");this.draw()};d.destroy=function(){this.shape&&(this.startArrowGroup.remove(this.startArrow),this.endArrowGroup.remove(this.endArrow),this.shape.remove(this.startArrowGroup),this.shape.remove(this.endArrowGroup),this.shape.remove(this.pathShape),this.shape.remove(this.labelShape),this.figure.group.remove(this.shape),this.shape=this.pathShape=this.labelShape=
this.startArrowGroup=this.startArrow=this.endArrowGroup=this.endArrow=null)};d.draw=function(a){this.apply(a);this._rot();this._pos();var b=this.startRotation;a=dojox.gfx.matrix.rotate(b);b=this.endRotation;b=dojox.gfx.matrix.rotateAt(b,this.end.x,this.end.y);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.startArrowGroup.setTransform({dx:this.start.x,dy:this.start.y}).applyTransform(a);
this.startArrow.setFill(this.property("fill"));this.endArrowGroup.setTransform(b);this.endArrow.setFill(this.property("fill"));this.labelShape.setShape({x:this.textPosition.x,y:this.textPosition.y,text:this.property("label")}).setFill(this.property("fill"));this.zoom()};d.zoom=function(a){if(this.startArrow){a=a||this.figure.zoomFactor;f.Annotation.prototype.zoom.call(this,a);var b=1<a?20:Math.floor(20/a),c=1<a?5:Math.floor(5/a);a=1<a?3:Math.floor(3/a);this.startArrow.setShape("M0,0 l"+b+",-"+c+" -"+
a+","+c+" "+a+","+c+" Z");this.endArrow.setShape("M"+this.end.x+","+this.end.y+" l-"+b+",-"+c+" "+a+","+c+" -"+a+","+c+" 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");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("+Math.round(180/Math.PI*this.startRotation*Math.pow(10,4))/Math.pow(10,4)+')"\x3e\x3cpath style\x3d"fill:'+a.color+';" d\x3d"M0,0 l20,-5, -3,5, 3,5 Z" /\x3e\x3c/g\x3e\x3cg transform\x3d"rotate('+Math.round(180/Math.PI*this.endRotation*Math.pow(10,4))/Math.pow(10,4)+
", "+this.end.x+", "+this.end.y+')"\x3e\x3cpath style\x3d"fill:'+a.color+';" d\x3d"M'+this.end.x+","+this.end.y+' l-20,-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("DoubleArrow");return dojox.sketch.DoubleArrowAnnotation});