Debian Codegraph @

dojox/dgauges/CircularValueIndicator.js

raw symbols SCIP
1 define(["dojo/_base/declare", "dojox/gfx", "./ScaleIndicatorBase", "dojo/_base/event"], function(declare, gfx, ScaleIndicatorBase, eventUtil){
2 return declare("dojox.dgauges.CircularValueIndicator", ScaleIndicatorBase, {
3 // summary:
4 // The circular value indicator, typically used for creating needles.
5
6 indicatorShapeFunc: function(group, indicator){
7 // summary:
8 // Draws the indicator. The rotation center is at (0, 0).
9 // group: dojox/gfx/Group
10 // A GFX group for drawing.
11 // indicator: dojox/dgauges/IndicatorBase
12 // A reference to this indicator.
13 // returns: dojox/gfx/shape.Shape
14 // A GFX shape retrievable using the getIndicatorRenderer method of the associated scale.
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 // summary:
43 // Internal method.
44 // tags:
45 // private
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 // prevent the browser from selecting text
52 eventUtil.stop(event);
53 },
54
55 _onMouseMove: function(event){
56 // summary:
57 // Internal method.
58 // tags:
59 // private
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 });