source: Dev/trunk/src/client/dojox/gauges/AnalogArcIndicator.js @ 529

Last change on this file since 529 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.9 KB
Line 
1define(["dojo/_base/declare","dojo/_base/lang","dojo/_base/connect","dojo/_base/fx","./AnalogIndicatorBase"],
2function(declare, lang, connect, fx, AnalogIndicatorBase) {
3
4return declare("dojox.gauges.AnalogArcIndicator",[AnalogIndicatorBase],{
5       
6        // summary:
7        //              An indicator for the AnalogGauge that draws a segment of arc.
8        //              The segment of arc starts at the start angle of the gauge and ends at the
9        //              angle that corresponds to the value of the indicator.
10       
11        _createArc: function(val){
12               
13                // Creating the Arc Path string manually.  This is instead of creating new dojox.gfx.Path object
14                // each time since we really just need the Path string (to use with setShape) and we don't want to
15                // have to redo the connects, etc.
16                if(this.shape){
17                        var startAngle = this._gauge._mod360(this._gauge.startAngle);
18                        var a = this._gauge._getRadians(this._gauge._getAngle(val));
19                        var sa = this._gauge._getRadians(startAngle);
20
21                        if (this._gauge.orientation == 'cclockwise'){
22                                var tmp = a;
23                                a = sa;
24                                sa = tmp;
25                        }
26
27                        var arange;
28                        var big = 0;
29                        if (sa<=a)
30                                arange = a-sa;
31                        else
32                                arange = 2*Math.PI+a-sa;
33                        if(arange>Math.PI){big=1;}
34                       
35                        var cosa = Math.cos(a);
36                        var sina = Math.sin(a);
37                        var cossa = Math.cos(sa);
38                        var sinsa = Math.sin(sa);
39                        var off = this.offset + this.width;
40                        var p = ['M'];
41                        p.push(this._gauge.cx+this.offset*sinsa);
42                        p.push(this._gauge.cy-this.offset*cossa);
43                        p.push('A', this.offset, this.offset, 0, big, 1);
44                        p.push(this._gauge.cx+this.offset*sina);
45                        p.push(this._gauge.cy-this.offset*cosa);
46                        p.push('L');
47                        p.push(this._gauge.cx+off*sina);
48                        p.push(this._gauge.cy-off*cosa);
49                        p.push('A', off, off, 0, big, 0);
50                        p.push(this._gauge.cx+off*sinsa);
51                        p.push(this._gauge.cy-off*cossa);
52                        p.push('z');
53                        this.shape.setShape(p.join(' '));
54                        this.currentValue = val;
55                }
56        },
57        draw: function(group, /*Boolean?*/ dontAnimate){
58                // summary:
59                //              Override of dojox.gauges._Indicator.draw
60                var v = this.value;
61                if(v < this._gauge.min){v = this._gauge.min;}
62                if(v > this._gauge.max){v = this._gauge.max;}
63                if(this.shape){
64                        if(dontAnimate){
65                                this._createArc(v);
66                        }else{
67                                var anim = new fx.Animation({curve: [this.currentValue, v], duration: this.duration, easing: this.easing});
68                                connect.connect(anim, "onAnimate", lang.hitch(this, this._createArc));
69                                anim.play();
70                        }
71                }else{
72                        var color = this.color ? this.color : 'black';
73                        var strokeColor = this.strokeColor ? this.strokeColor : color;
74                        var stroke = {color: strokeColor, width: 1};
75                        if(this.color.type && !this.strokeColor){
76                                stroke.color = this.color.colors[0].color;
77                        }
78                        this.shape = group.createPath().setStroke(stroke).setFill(color);
79                        this._createArc(v);
80                        this.shape.connect("onmouseover", this, this.handleMouseOver);
81                        this.shape.connect("onmouseout", this,  this.handleMouseOut);
82                        this.shape.connect("onmousedown", this, this.handleMouseDown);
83                        this.shape.connect("touchstart", this, this.handleTouchStart);
84                }
85        }
86});
87
88});
Note: See TracBrowser for help on using the repository browser.