| 1 |
define(["dojo/_base/declare", "dojox/gfx", "./ScaleIndicatorBase", "dojo/_base/event"], function(declare, gfx, ScaleIndicatorBase, eventUtil){ |
| 2 |
return declare("dojox.dgauges.CircularValueIndicator", ScaleIndicatorBase, { |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
indicatorShapeFunc: function(group, indicator){ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
return group.createLine({ |
| 16 |
x1: 0, |
| 17 |
y1: 0, |
| 18 |
x2: 40, |
| 19 |
y2: 0 |
| 20 |
}).setStroke({ |
| 21 |
color: "black", |
| 22 |
width: 1 |
| 23 |
}); |
| 24 |
}, |
| 25 |
|
| 26 |
refreshRendering: function(){ |
| 27 |
this.inherited(arguments); |
| 28 |
if(this._gfxGroup === null || this.scale === null){ |
| 29 |
return; |
| 30 |
}else{ |
| 31 |
var v = isNaN(this._transitionValue) ? this.value : this._transitionValue; |
| 32 |
var angle = this.scale.positionForValue(v); |
| 33 |
|
| 34 |
this._gfxGroup.setTransform([{ |
| 35 |
dx: this.scale.originX, |
| 36 |
dy: this.scale.originY |
| 37 |
}, gfx.matrix.rotateg(angle)]); |
| 38 |
} |
| 39 |
}, |
| 40 |
|
| 41 |
_onMouseDown: function(event){ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
this.inherited(arguments); |
| 47 |
var origin = this.scale._gauge._gaugeToPage(this.scale.originX, this.scale.originY); |
| 48 |
var angle = ((Math.atan2(event.pageY - origin.y, event.pageX - origin.x)) * 180) / (Math.PI); |
| 49 |
this.set("value", this.scale.valueForPosition(angle)); |
| 50 |
|
| 51 |
|
| 52 |
eventUtil.stop(event); |
| 53 |
}, |
| 54 |
|
| 55 |
_onMouseMove: function(event){ |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
this.inherited(arguments); |
| 61 |
var origin = this.scale._gauge._gaugeToPage(this.scale.originX, this.scale.originY); |
| 62 |
var angle = ((Math.atan2(event.pageY - origin.y, event.pageX - origin.x)) * 180) / (Math.PI); |
| 63 |
this.set("value", this.scale.valueForPosition(angle)); |
| 64 |
} |
| 65 |
}); |
| 66 |
}); |