source: Dev/branches/rest-dojo-ui/client/dojox/gauges/AnalogNeedleIndicator.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.3 KB
Line 
1define(["dojo/_base/declare","./AnalogIndicatorBase"],
2  function(declare, AnalogIndicatorBase) {
3
4/*=====
5        AnalogIndicatorBase = dojox.gauges.AnalogIndicatorBase;
6=====*/
7
8return declare("dojox.gauges.AnalogNeedleIndicator", [AnalogIndicatorBase], {
9        // summary:
10        //              An indicator for the AnalogGauge that draws a needle. The needle is drawn on the angle that corresponds
11        //              to the value of the indicator.
12       
13        _getShapes: function(group){
14                // summary:
15                //              Override of dojox.gauges.AnalogLineIndicator._getShapes
16                if(!this._gauge){
17                        return null;
18                }
19                var x = Math.floor(this.width/2);
20                var shapes = [];
21               
22                var color = this.color ? this.color : 'black';
23                var strokeColor = this.strokeColor ? this.strokeColor : color;
24                var strokeWidth = this.strokeWidth ? this.strokeWidth : 1;
25
26                var stroke = {
27                        color: strokeColor,
28                        width: strokeWidth
29                };
30               
31                if (color.type && !this.strokeColor){
32                        stroke.color = color.colors[0].color;
33                }
34
35                var xy = (Math.sqrt(2) * (x));
36                shapes[0] = group.createPath()
37                                        .setStroke(stroke).setFill(color)
38                                        .moveTo(xy, -xy).arcTo((2*x), (2*x), 0, 0, 0, -xy, -xy)
39                                        .lineTo(0, -this.length).closePath();
40                shapes[1] = group.createCircle({cx: 0, cy: 0, r: this.width})
41                                        .setStroke(stroke)
42                                        .setFill(color);
43                return shapes;
44        }
45});
46});
Note: See TracBrowser for help on using the repository browser.