source: Dev/trunk/src/client/dojox/dgauges/CircularValueIndicator.js @ 529

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

Added Dojo 1.9.3 release.

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1define(["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                        var v = isNaN(this._transitionValue) ? this.value : this._transitionValue;
29                        var angle = this.scale.positionForValue(v);
30                       
31                        this._gfxGroup.setTransform([{
32                                dx: this.scale.originX,
33                                dy: this.scale.originY
34                        }, gfx.matrix.rotateg(angle)]);
35                },
36               
37                _onMouseDown: function(event){
38                        // summary:
39                        //              Internal method.
40                        // tags:
41                        //              private
42                        this.inherited(arguments);
43                        var origin = this.scale._gauge._gaugeToPage(this.scale.originX, this.scale.originY);
44                        var angle = ((Math.atan2(event.pageY - origin.y, event.pageX - origin.x)) * 180) / (Math.PI);
45                        this.set("value", this.scale.valueForPosition(angle));
46
47                        // prevent the browser from selecting text
48                        eventUtil.stop(event);
49                },
50               
51                _onMouseMove: function(event){
52                        // summary:
53                        //              Internal method.
54                        // tags:
55                        //              private
56                        this.inherited(arguments);
57                        var origin = this.scale._gauge._gaugeToPage(this.scale.originX, this.scale.originY);
58                        var angle = ((Math.atan2(event.pageY - origin.y, event.pageX - origin.x)) * 180) / (Math.PI);
59                        this.set("value", this.scale.valueForPosition(angle));
60                }
61        });
62});
Note: See TracBrowser for help on using the repository browser.