Debian Codegraph @

dojox/dgauges/components/classic/HorizontalLinearGauge.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/Color",
5 "../../RectangularGauge",
6 "../../LinearScaler",
7 "../../RectangularScale",
8 "../../RectangularValueIndicator",
9 "../DefaultPropertiesMixin"
10 ],
11 function(lang, declare, Color, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, DefaultPropertiesMixin){
12 return declare("dojox.dgauges.components.classic.HorizontalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
13 // summary:
14 // A horizontal gauge widget.
15
16 // borderColor: Object|Array|int
17 // The border color. Default is "#797E86".
18 borderColor: [121,126,134],
19 // fillColor: Object|Array|int
20 // The background color. Default is "#9498A1".
21 fillColor: [148,152,161],
22 // indicatorColor: Object|Array|int
23 // The indicator fill color. Default is "#FFFFFF".
24 indicatorColor: "#FFFFFF",
25 constructor: function(){
26 // Base colors
27 this.borderColor = new Color(this.borderColor);
28 this.fillColor = new Color(this.fillColor);
29 this.indicatorColor = new Color(this.indicatorColor);
30
31 this.addElement("background", lang.hitch(this, this.drawBackground));
32
33 // Scaler
34 var scaler = new LinearScaler();
35
36 // Scale
37 var scale = new RectangularScale();
38 scale.set("scaler", scaler);
39 scale.set("labelPosition", "leading");
40 scale.set("paddingLeft", 30);
41 scale.set("paddingRight", 30);
42 scale.set("paddingTop", 32);
43 scale.set("labelGap", 8);
44 scale.set("font", {
45 family: "Helvetica",
46 weight: "bold",
47 size: "7pt"
48 });
49 scale.set("tickShapeFunc", function(group, scale, tick){
50 return group.createCircle({
51 r: tick.isMinor ? 0.5 : 2
52 }).setFill("black");
53 });
54 this.addElement("scale", scale);
55
56 var indicator = new RectangularValueIndicator();
57 indicator.set("interactionArea", "gauge");
58 indicator.set("value", scaler.minimum);
59 indicator.set("paddingTop", 30);
60 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group, indicator){
61
62 return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor).setStroke({
63 color: [121,126,134],
64 width: 1,
65 style: "Solid",
66 cap: "butt",
67 join: 20.0
68 });
69
70 }));
71 scale.addIndicator("indicator", indicator);
72 },
73
74 drawBackground: function(g, w, h){
75 // summary:
76 // Draws the background shape of the gauge.
77 // g: dojox/gfx/Group
78 // The group used to draw the background.
79 // w: Number
80 // The width of the gauge.
81 // h: Number
82 // The height of the gauge.
83 // tags:
84 // protected
85 g.createRect({
86 x: 0,
87 y: 0,
88 width: w,
89 height: 50,
90 r: 8
91 }).setFill(this.borderColor);
92 g.createRect({
93 x: 2,
94 y: 2,
95 width: w - 4,
96 height: 32,
97 r: 6
98 }).setFill({
99 type: "linear",
100 x1: 0,
101 y1: 2,
102 x2: 0,
103 y2: 15,
104 colors: [
105 {offset: 0, color: [235,235,235]},
106 {offset: 1, color: this.borderColor}
107 ]
108 });
109 g.createRect({
110 x: 6,
111 y: 6,
112 width: w - 12,
113 height: 38,
114 r: 5
115 }).setFill({
116 type: "linear",
117 x1: 0,
118 y1: 6,
119 x2: 0,
120 y2: 38,
121 colors: [
122 {offset: 0, color: [220,220,220]},
123 {offset: 1, color: this.fillColor}
124 ]
125 });
126 g.createRect({
127 x: 7,
128 y: 7,
129 width: w - 14,
130 height: 36,
131 r: 3
132 }).setFill({
133 type: "linear",
134 x1: 0,
135 y1: 7,
136 x2: 0,
137 y2: 36,
138 colors: [
139 {offset: 0, color: this.fillColor},
140 {offset: 1, color: [220,220,220]}
141 ]
142 });
143 }
144 });
145 }
146 );
147