/* 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.drawing.tools.custom.Axes"]){dojo._hasResource["dojox.drawing.tools.custom.Axes"]=true;dojo.provide("dojox.drawing.tools.custom.Axes");dojo.require("dojox.drawing.stencil.Path");dojox.drawing.tools.custom.Axes=dojox.drawing.util.oo.declare(dojox.drawing.stencil.Path,function(_1){this.closePath=false;this.xArrow=new dojox.drawing.annotations.Arrow({stencil:this,idx1:0,idx2:1});this.yArrow=new dojox.drawing.annotations.Arrow({stencil:this,idx1:2,idx2:1});if(this.points&&this.points.length){this.setPoints=this._postSetPoints;this.render();this.onRender();}},{draws:true,type:"dojox.drawing.tools.custom.Axes",minimumSize:30,showAngle:true,closePath:false,baseRender:false,createLabels:function(){var _2={align:"middle",valign:"middle",util:this.util,annotation:true,container:this.container,mouse:this.mouse,stencil:this};this.labelX=new dojox.drawing.annotations.Label(dojo.mixin(_2,{labelPosition:this.setLabelX}));this.labelY=new dojox.drawing.annotations.Label(dojo.mixin(_2,{labelPosition:this.setLabelY}));},setLabelX:function(){var ax=this.points[0];var c=this.points[1];var ay=this.points[2];var _3=40;var _4=20;var pt,px,py,_5;pt=this.util.lineSub(c.x,c.y,ax.x,ax.y,_3);px=pt.x+(pt.y-ax.y);py=pt.y+(ax.x-pt.x);_5=this.util.lineSub(pt.x,pt.y,px,py,(_3-_4));return {x:_5.x,y:_5.y,width:20};},setLabelY:function(){var ax=this.points[0];var c=this.points[1];var ay=this.points[2];var _6=40;var _7=20;var pt,px,py,_8;pt=this.util.lineSub(c.x,c.y,ay.x,ay.y,_6);px=pt.x+(ay.y-pt.y);py=pt.y+(pt.x-ay.x);_8=this.util.lineSub(pt.x,pt.y,px,py,(_6-_7));_8=this.util.lineSub(pt.x,pt.y,px,py,(_6-_7));return {x:_8.x,y:_8.y,width:20};},setLabel:function(_9){if(this._labelsCreated){return;}!this.labelX&&this.createLabels();var x="x";var y="y";if(_9){_9.replace(/^\s+/,"");_9.replace(/\s+$/,"");var _a=_9.match(/(.*?)(and|&)(.*)/i);if(_a.length>2){x=_a[1].replace(/\s+$/,"");y=_a[3].replace(/^\s+/,"");}}this.labelX.setLabel(x);this.labelY.setLabel(y);this._labelsCreated=true;},getLabel:function(){if(!this.labelX){return {};}return {x:this.labelX._text,y:this.labelY._text};},anchorPositionCheck:function(x,y,_b){var pm=this.container.getParent().getTransform();var am=_b.shape.getTransform();var p=this.points;var o={x:am.dx+_b.org.x+pm.dx,y:am.dy+_b.org.y+pm.dy};var c={x:p[1].x+pm.dx,y:p[1].y+pm.dy};var ox=c.x-(c.y-o.y);var oy=c.y-(o.x-c.x);return {x:ox,y:oy};},onTransformBegin:function(_c){this._isBeingModified=true;},onTransformEnd:function(_d){if(!_d){return;}this._isBeingModified=false;this._toggleSelected();var o=this.points[0];var c=this.points[1];var pt=this.util.constrainAngle({start:{x:c.x,y:c.y},x:o.x,y:o.y},91,180);if(pt.x==o.x&&pt.y==o.y){var _e={start:{x:c.x,y:c.y},x:o.x,y:o.y};pt=this.util.snapAngle(_e,this.angleSnap/180);_e.x=pt.x;_e.y=pt.y;var ox=_e.start.x-(_e.start.y-_e.y);var oy=_e.start.y-(_e.x-_e.start.x);if(ox<0||oy<0){console.warn("AXES ERROR LESS THAN ZERO - ABORT");return;}this.points=[{x:_e.x,y:_e.y},{x:_e.start.x,y:_e.start.y,noAnchor:true}];this.points.push({x:ox,y:oy,noAnchor:true});this.setPoints(this.points);this.onModify(this);return;}this.points[0].x=pt.x;this.points[0].y=pt.y;o=this.points[0];var ox=c.x-(c.y-o.y);var oy=c.y-(o.x-c.x);this.points[2]={x:ox,y:oy,noAnchor:true};this.setPoints(this.points);this.labelX.setLabel();this.labelY.setLabel();this.onModify(this);},getBounds:function(_f){var px=this.points[0],pc=this.points[1],py=this.points[2];if(_f){return {x:pc.x,y:pc.y,x1:pc.x,y1:pc.y,x2:px.x,y2:px.y,x3:py.x,y3:py.y};}var x1=py.x,y1=py.y