Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / drawing / annotations / Angle.js @ 12

History | View | Annotate | Download (2.06 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.drawing.annotations.Angle"]){
9
dojo._hasResource["dojox.drawing.annotations.Angle"]=true;
10
dojo.provide("dojox.drawing.annotations.Angle");
11
dojox.drawing.annotations.Angle=dojox.drawing.util.oo.declare(function(_1){
12
this.stencil=_1.stencil;
13
this.util=_1.stencil.util;
14
this.mouse=_1.stencil.mouse;
15
this.stencil.connectMult([["onDrag",this,"showAngle"],["onUp",this,"hideAngle"],["onTransformBegin",this,"showAngle"],["onTransform",this,"showAngle"],["onTransformEnd",this,"hideAngle"]]);
16
},{type:"dojox.drawing.tools.custom",angle:0,showAngle:function(){
17
if(!this.stencil.selected&&this.stencil.created){
18
return;
19
}
20
if(this.stencil.getRadius()<this.stencil.minimumSize){
21
this.hideAngle();
22
return;
23
}
24
var _2=this.getAngleNode();
25
var d=this.stencil.pointsToData();
26
var pt=dojox.drawing.util.positioning.angle({x:d.x1,y:d.y1},{x:d.x2,y:d.y2});
27
var sc=this.mouse.scrollOffset();
28
var mx=this.stencil.getTransform();
29
var dx=mx.dx/this.mouse.zoom;
30
var dy=mx.dy/this.mouse.zoom;
31
pt.x/=this.mouse.zoom;
32
pt.y/=this.mouse.zoom;
33
var x=this.stencil._offX+pt.x-sc.left+dx;
34
var y=this.stencil._offY+pt.y-sc.top+dy;
35
dojo.style(_2,{left:x+"px",top:y+"px",align:pt.align});
36
var _3=this.stencil.getAngle();
37
if(this.stencil.style.zAxis&&this.stencil.shortType=="vector"){
38
_2.innerHTML=this.stencil.data.cosphi>0?"out of":"into";
39
}else{
40
if(this.stencil.shortType=="line"){
41
_2.innerHTML=this.stencil.style.zAxis?"out of":Math.ceil(_3%180);
42
}else{
43
_2.innerHTML=Math.ceil(_3);
44
}
45
}
46
},getAngleNode:function(){
47
if(!this._angleNode){
48
this._angleNode=dojo.create("span",null,dojo.body());
49
dojo.addClass(this._angleNode,"textAnnotation");
50
dojo.style(this._angleNode,"opacity",1);
51
}
52
return this._angleNode;
53
},hideAngle:function(){
54
if(this._angleNode&&dojo.style(this._angleNode,"opacity")>0.9){
55
dojo.fadeOut({node:this._angleNode,duration:500,onEnd:function(_4){
56
dojo.destroy(_4);
57
}}).play();
58
this._angleNode=null;
59
}
60
}});
61
}