dojo.provide("dojox.sketch.DoubleArrowAnnotation"); dojo.require("dojox.sketch.Annotation"); dojo.require("dojox.sketch.Anchor"); (function(){ var ta=dojox.sketch; ta.DoubleArrowAnnotation=function(figure, id){ ta.Annotation.call(this, figure, id); 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.startRotation=0; this.endRotation=0; // this.property('label',this.id); this.labelShape=null; this.pathShape=null; this.startArrow=null; this.startArrowGroup=null; this.endArrow=null; this.endArrowGroup=null; this.anchors.start=new ta.Anchor(this, "start"); this.anchors.control=new ta.Anchor(this, "control"); this.anchors.end=new ta.Anchor(this, "end"); }; ta.DoubleArrowAnnotation.prototype=new ta.Annotation; var p=ta.DoubleArrowAnnotation.prototype; p.constructor=ta.DoubleArrowAnnotation; p.type=function(){ return 'DoubleArrow'; }; p.getType=function(){ return ta.DoubleArrowAnnotation; }; p._rot=function(){ // arrowhead rotation var opp=this.control.y-this.start.y; var adj=this.control.x-this.start.x; this.startRotation=Math.atan2(opp,adj); opp=this.end.y-this.control.y; adj=this.end.x-this.control.x; this.endRotation=Math.atan2(opp,adj); }; p._pos=function(){ // text position var offset=this.textOffset; // figure out the pull of the curve and place accordingly if(this.control.y1?20:Math.floor(20/pct), w=pct>1?5:Math.floor(5/pct),h=pct>1?3:Math.floor(3/pct); this.startArrow.setShape("M0,0 l"+l+",-"+w+" -"+h+","+w+" "+h+","+w+" Z");//.setFill(this.property('fill')); this.endArrow.setShape("M" + this.end.x + "," + this.end.y + " l-"+l+",-"+w+" "+h+","+w+" -"+h+","+w+" Z"); } }; p.getBBox=function(){ var x=Math.min(this.start.x, this.control.x, this.end.x); var y=Math.min(this.start.y, this.control.y, this.end.y); var w=Math.max(this.start.x, this.control.x, this.end.x)-x; var h=Math.max(this.start.y, this.control.y, this.end.y)-y; return { x:x, y:y, width:w, height:h }; }; p.serialize=function(){ var s=this.property('stroke'); return '' + '' + '' + '' + '' + '' + '' + '' + '' + this.property('label') + '' + ''; }; ta.Annotation.register("DoubleArrow"); })();