/* Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ if(!dojo._hasResource["dojox.sketch.SingleArrowAnnotation"]){dojo._hasResource["dojox.sketch.SingleArrowAnnotation"]=true;dojo.provide("dojox.sketch.SingleArrowAnnotation");dojo.require("dojox.sketch.Annotation");dojo.require("dojox.sketch.Anchor");(function(){var ta=dojox.sketch;ta.SingleArrowAnnotation=function(_1,id){ta.Annotation.call(this,_1,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=4;this.textYOffset=10;this.rotation=0;this.pathShape=null;this.arrowhead=null;this.arrowheadGroup=null;this.labelShape=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.SingleArrowAnnotation.prototype=new ta.Annotation;var p=ta.SingleArrowAnnotation.prototype;p.constructor=ta.SingleArrowAnnotation;p.type=function(){return "SingleArrow";};p.getType=function(){return ta.SingleArrowAnnotation;};p._rot=function(){var _2=this.control.y-this.start.y;var _3=this.control.x-this.start.x;this.rotation=Math.atan2(_2,_3);};p._pos=function(){var _4=this.textOffset,x=0,y=0;var _5=this.calculate.slope(this.control,this.end);this.textAlign="middle";if(Math.abs(_5)>=1){x=this.end.x+this.calculate.dx(this.control,this.end,_4);if(this.control.y>this.end.y){y=this.end.y-_4;}else{y=this.end.y+_4+this.textYOffset;}}else{if(_5==0){x=this.end.x+_4;y=this.end.y+this.textYOffset;}else{if(this.start.x>this.end.x){x=this.end.x-_4;this.textAlign="end";}else{x=this.end.x+_4;this.textAlign="start";}if(this.start.y1?20:Math.floor(20/pct),w=pct>1?5:Math.floor(5/pct),h=pct>1?3:Math.floor(3/pct);this.arrowhead.setShape("M0,0 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");var r=this.rotation*(180/Math.PI);r=Math.round(r*Math.pow(10,4))/Math.pow(10,4);return ""+""+""+""+""+""+this.property("label")+""+"";};ta.Annotation.register("SingleArrow");})();}