Debian Codegraph @

dojox/dgauges/components/default/VerticalLinearGauge.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "dojo/_base/declare",
4 "dojo/_base/Color",
5 "../utils",
6 "../../RectangularGauge",
7 "../../LinearScaler",
8 "../../RectangularScale",
9 "../../RectangularValueIndicator",
10 "../../RectangularRangeIndicator",
11 "../../TextIndicator",
12 "../DefaultPropertiesMixin"
13 ],
14 function(lang, declare, Color, utils, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, RectangularRangeIndicator, TextIndicator, DefaultPropertiesMixin){
15 return declare("dojox.dgauges.components.default.VerticalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
16 // summary:
17 // A vertical gauge widget.
18
19 // borderColor: Object|Array|int
20 // The border color. Default is "#C9DFF2".
21 borderColor: "#C9DFF2",
22 // fillColor: Object|Array|int
23 // The background color. Default is "#FCFCFF".
24 fillColor: "#FCFCFF",
25 // indicatorColor: Object|Array|int
26 // The indicator fill color. Default is "#F01E28".
27 indicatorColor: "#F01E28",
28 constructor: function(){
29 this.orientation = "vertical";
30 // Base colors
31 this.borderColor = new Color(this.borderColor);
32 this.fillColor = new Color(this.fillColor);
33 this.indicatorColor = new Color(this.indicatorColor);
34
35 // Draw background
36 this.addElement("background", lang.hitch(this, this.drawBackground));
37
38
39 // Scaler
40 var scaler = new LinearScaler();
41
42 // Scale
43 var scale = new RectangularScale();
44 scale.set("scaler", scaler);
45 scale.set("labelPosition", "leading");
46 scale.set("paddingBottom", 20);
47 scale.set("paddingLeft", 25);
48
49 this.addElement("scale", scale);
50
51 // Value indicator
52 var indicator = new RectangularValueIndicator();
53
54 indicator.indicatorShapeFunc = lang.hitch(this, function(group){
55 var indic = group.createPolyline([0, 0, 10, 0, 0, 10, -10, 0, 0, 0]).setStroke({
56 color: "blue",
57 width: 0.25
58 }).setFill(this.indicatorColor);
59
60 return indic;
61 });
62 indicator.set("paddingLeft", 45);
63 indicator.set("interactionArea", "gauge");
64 scale.addIndicator("indicator", indicator);
65
66
67 // Indicator Text Border
68 this.addElement("indicatorTextBorder", lang.hitch(this, this.drawTextBorder), "leading");
69
70 // Indicator Text
71 var indicatorText = new TextIndicator();
72 indicatorText.set("indicator", indicator);
73 indicatorText.set("x", 22.5);
74 indicatorText.set("y", 30);
75 this.addElement("indicatorText", indicatorText);
76 },
77
78 drawBackground: function(g, w, h){
79 // summary:
80 // Draws the background shape of the gauge.
81 // g: dojox/gfx/Group
82 // The group used to draw the background.
83 // w: Number
84 // The width of the gauge.
85 // h: Number
86 // The height of the gauge.
87 // tags:
88 // protected
89 w = 49;
90 var gap = 0;
91 var cr = 3;
92 var entries = utils.createGradient([0, utils.brightness(this.borderColor, -20), 0.1, utils.brightness(this.borderColor, -40)]);
93 g.createRect({
94 x: 0,
95 y: 0,
96 width: w,
97 height: h,
98 r: cr
99 }).setFill(lang.mixin({
100 type: "linear",
101 x1: 0,
102 y1: 0,
103 x2: w,
104 y2: h
105 }, entries)).setStroke({
106 color: "#A5A5A5",
107 width: 0.2
108 });
109 entries = utils.createGradient([0, utils.brightness(this.borderColor, 70), 1, utils.brightness(this.borderColor, -50)]);
110 gap = 4;
111 cr = 2
112 g.createRect({
113 x: gap,
114 y: gap,
115 width: w - 2 * gap,
116 height: h - 2 * gap,
117 r: cr
118 }).setFill(lang.mixin({
119 type: "linear",
120 x1: 0,
121 y1: 0,
122 x2: w,
123 y2: h
124 }, entries));
125 gap = 6;
126 cr = 1
127 entries = utils.createGradient([0, utils.brightness(this.borderColor, 60), 1, utils.brightness(this.borderColor, -40)]);
128 g.createRect({
129 x: gap,
130 y: gap,
131 width: w - 2 * gap,
132 height: h - 2 * gap,
133 r: cr
134 }).setFill(lang.mixin({
135 type: "linear",
136 x1: 0,
137 y1: 0,
138 x2: w,
139 y2: h
140 }, entries));
141
142 gap = 7;
143 cr = 0
144 entries = utils.createGradient([0, utils.brightness(this.borderColor, 70), 1, utils.brightness(this.borderColor, -40)]);
145 g.createRect({
146 x: gap,
147 y: gap,
148 width: w - 2 * gap,
149 height: h - 2 * gap,
150 r: cr
151 }).setFill(lang.mixin({
152 type: "linear",
153 x1: w,
154 y1: 0,
155 x2: 0,
156 y2: h
157 }, entries));
158 gap = 5;
159 cr = 0
160 entries = utils.createGradient([0, [255, 255, 255, 220], 0.8, utils.brightness(this.fillColor, -5), 1, utils.brightness(this.fillColor, -30)]);
161 g.createRect({
162 x: gap,
163 y: gap,
164 width: w - 2 * gap,
165 height: h - 2 * gap,
166 r: cr
167 }).setFill(lang.mixin({
168 type: "radial",
169 cx: 0,
170 cy: h / 2,
171 r: h
172 }, entries)).setStroke({
173 color: utils.brightness(this.fillColor, -40),
174 width: 0.4
175 });
176
177 },
178 drawTextBorder: function(g){
179 // summary:
180 // Internal method.
181 // tags:
182 // private
183 return g.createRect({
184 x: 5,
185 y: 5,
186 width: 40,
187 height: 40
188 }).setStroke({
189 color: "#CECECE",
190 width: 1
191 });
192 }
193 });
194 });