//>>built
define("dojox/sketch/LeadAnnotation",["dojo/_base/kernel","dojo/_base/lang","./Annotation","./Anchor"],function(b){b.getObject("sketch",!0,dojox);var e=dojox.sketch;e.LeadAnnotation=function(a,d){e.Annotation.call(this,a,d);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.labelShape=this.pathShape=null;this.anchors.start=new e.Anchor(this,"start");this.anchors.control=new e.Anchor(this,
"control");this.anchors.end=new e.Anchor(this,"end")};e.LeadAnnotation.prototype=new e.Annotation;b=e.LeadAnnotation.prototype;b.constructor=e.LeadAnnotation;b.type=function(){return"Lead"};b.getType=function(){return e.LeadAnnotation};b._pos=function(){var a=this.textOffset,d=0,c=0,d=this.calculate.slope(this.control,this.end);this.textAlign="middle";1<=Math.abs(d)?(d=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==
d?(d=this.end.x+a,c=this.end.y+this.textYOffset):(this.start.x>this.end.x?(d=this.end.x-a,this.textAlign="end"):(d=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:d,y:c}};b.apply=function(a){if(a){if(a.documentElement)a=a.documentElement;this.readCommonAttrs(a);for(var d=0;d<a.childNodes.length;d++){var c=a.childNodes[d];if("text"==c.localName)this.property("label",
c.childNodes.length?c.childNodes[0].nodeValue:"");else if("path"==c.localName){var b=c.getAttribute("d").split(" "),f=b[0].split(",");this.start.x=parseFloat(f[0].substr(1),10);this.start.y=parseFloat(f[1],10);f=b[1].split(",");this.control.x=parseFloat(f[0].substr(1),10);this.control.y=parseFloat(f[1],10);f=b[2].split(",");this.end.x=parseFloat(f[0],10);this.end.y=parseFloat(f[1],10);b=this.property("stroke");c=c.getAttribute("style");if(f=c.match(/stroke:([^;]+);/))b.color=f[1],this.property("fill",
f[1]);if(f=c.match(/stroke-width:([^;]+);/))b.width=f[1];this.property("stroke",b)}}}};b.initialize=function(a){this.apply(a);this._pos();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.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()};b.destroy=function(){if(this.shape)this.shape.remove(this.pathShape),this.shape.remove(this.labelShape),this.figure.group.remove(this.shape),this.shape=this.pathShape=this.labelShape=null};b.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),c=Math.max(this.start.x,this.control.x,this.end.x)-a,e=Math.max(this.start.y,this.control.y,this.end.y)-
b;return{x:a,y:b,width:c,height:e}};b.draw=function(a){this.apply(a);this._pos();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.labelShape.setShape({x:this.textPosition.x,y:this.textPosition.y,text:this.property("label")}).setFill(this.property("fill"));this.zoom()};b.serialize=function(){var a=this.property("stroke");return"<g "+this.writeCommonAttrs()+'><path style="stroke:'+
a.color+";stroke-width:"+a.width+';fill:none;" d="M'+this.start.x+","+this.start.y+" Q"+this.control.x+","+this.control.y+" "+this.end.x+","+this.end.y+'" /><text style="fill:'+a.color+";text-anchor:"+this.textAlign+'" font-weight="bold" x="'+this.textPosition.x+'" y="'+this.textPosition.y+'">'+this.property("label")+"</text></g>"};e.Annotation.register("Lead");return dojox.sketch.LeadAnnotation});