summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/gauges/AnalogNeedleIndicator.js
blob: 441795ec89867695f6fdb6ae425e0b76c3dc67fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//>>built
define("dojox/gauges/AnalogNeedleIndicator", ["dojo/_base/declare","./AnalogIndicatorBase"],
  function(declare, AnalogIndicatorBase) { 

/*=====
	AnalogIndicatorBase = dojox.gauges.AnalogIndicatorBase;
=====*/

return declare("dojox.gauges.AnalogNeedleIndicator", [AnalogIndicatorBase], {
	// summary:
	//		An indicator for the AnalogGauge that draws a needle. The needle is drawn on the angle that corresponds
	// 		to the value of the indicator.
	
	_getShapes: function(group){
		// summary:
		//		Override of dojox.gauges.AnalogLineIndicator._getShapes
		if(!this._gauge){
			return null;
		}
		var x = Math.floor(this.width/2);
		var shapes = [];
		
		var color = this.color ? this.color : 'black';
		var strokeColor = this.strokeColor ? this.strokeColor : color;
		var strokeWidth = this.strokeWidth ? this.strokeWidth : 1;

		var stroke = {
			color: strokeColor,
			width: strokeWidth
		};
		
		if (color.type && !this.strokeColor){
			stroke.color = color.colors[0].color;
		}

		var xy = (Math.sqrt(2) * (x));
		shapes[0] = group.createPath()
					.setStroke(stroke).setFill(color)
					.moveTo(xy, -xy).arcTo((2*x), (2*x), 0, 0, 0, -xy, -xy)
					.lineTo(0, -this.length).closePath();
		shapes[1] = group.createCircle({cx: 0, cy: 0, r: this.width})
					.setStroke(stroke)
					.setFill(color);
		return shapes;
	}
});
});