Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / widget / gauge / AnalogArcIndicator.js

History | View | Annotate | Download (2.11 KB)

1 9 andrej.cim
/*
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.widget.gauge.AnalogArcIndicator"]){
9
dojo._hasResource["dojox.widget.gauge.AnalogArcIndicator"]=true;
10
dojo.provide("dojox.widget.gauge.AnalogArcIndicator");
11
dojo.require("dojox.widget.AnalogGauge");
12
dojo.experimental("dojox.widget.gauge.AnalogArcIndicator");
13
dojo.declare("dojox.widget.gauge.AnalogArcIndicator",[dojox.widget.gauge.AnalogLineIndicator],{_createArc:function(_1){
14
if(this.shapes[0]){
15
var a=this._gauge._getRadians(this._gauge._getAngle(_1));
16
var _2=Math.cos(a);
17
var _3=Math.sin(a);
18
var sa=this._gauge._getRadians(this._gauge.startAngle);
19
var _4=Math.cos(sa);
20
var _5=Math.sin(sa);
21
var _6=this.offset+this.width;
22
var p=["M"];
23
p.push(this._gauge.cx+this.offset*_5);
24
p.push(this._gauge.cy-this.offset*_4);
25
p.push("A",this.offset,this.offset,0,((a-sa)>Math.PI)?1:0,1);
26
p.push(this._gauge.cx+this.offset*_3);
27
p.push(this._gauge.cy-this.offset*_2);
28
p.push("L");
29
p.push(this._gauge.cx+_6*_3);
30
p.push(this._gauge.cy-_6*_2);
31
p.push("A",_6,_6,0,((a-sa)>Math.PI)?1:0,0);
32
p.push(this._gauge.cx+_6*_5);
33
p.push(this._gauge.cy-_6*_4);
34
this.shapes[0].setShape(p.join(" "));
35
this.currentValue=_1;
36
}
37
},draw:function(_7){
38
var v=this.value;
39
if(v<this._gauge.min){
40
v=this._gauge.min;
41
}
42
if(v>this._gauge.max){
43
v=this._gauge.max;
44
}
45
if(this.shapes){
46
if(_7){
47
this._createArc(v);
48
}else{
49
var _8=new dojo.Animation({curve:[this.currentValue,v],duration:this.duration,easing:this.easing});
50
dojo.connect(_8,"onAnimate",dojo.hitch(this,this._createArc));
51
_8.play();
52
}
53
}else{
54
var _9={color:this.color,width:1};
55
if(this.color.type){
56
_9.color=this.color.colors[0].color;
57
}
58
this.shapes=[this._gauge.surface.createPath().setStroke(_9).setFill(this.color)];
59
this._createArc(v);
60
if(this.hover){
61
this.shapes[0].getEventSource().setAttribute("hover",this.hover);
62
}
63
if(this.onDragMove&&!this.noChange){
64
this._gauge.connect(this.shapes[0].getEventSource(),"onmousedown",this._gauge.handleMouseDown);
65
this.shapes[0].getEventSource().style.cursor="pointer";
66
}
67
}
68
}});
69
}