Debian Codegraph @

dojox/dgauges/tests/gauges/AircraftGauge.js

raw symbols SCIP
1 define(["dojo/_base/lang", "dojo/_base/declare", "dojox/dgauges/CircularGauge", "dojox/dgauges/LinearScaler",
2 "dojox/dgauges/CircularScale", "dojox/dgauges/CircularValueIndicator", "dojox/dgauges/CircularRangeIndicator",
3 "dojox/dgauges/TextIndicator"],
4 function(lang, declare, CircularGauge, LinearScaler, CircularScale, CircularValueIndicator, CircularRangeIndicator,
5 TextIndicator){
6 return declare("dojox.dgauges.tests.gauges.AircraftGauge", CircularGauge, {
7 _radius: 100,
8 constructor: function(){
9 this.font = {
10 family: "Helvetica",
11 style: "normal",
12 size: "10pt",
13 color: "#EFEFEF"
14 };
15
16 // Draws a triangle, used by 2 indicators
17 var sharedIndicatorShapeFunc = function(group){
18 return group.createPolyline([40, -6, 60, 0, 40, 6, 40, -6]).setFill("#EFEFEF");
19 };
20
21 // Draws the background
22 this.addElement("background", lang.hitch(this, this.drawBackground));
23
24 // The left scaler
25 var scaler = new LinearScaler({
26 minimum: 10,
27 maximum: 40,
28 majorTickInterval: 5,
29 minorTickInterval: 1
30 });
31
32 // The left scale
33 var scale = new CircularScale({
34 scaler: scaler,
35 originX: 100,
36 originY: 100,
37 startAngle: 110,
38 endAngle: 250,
39 radius: 70,
40 labelPosition: "outside",
41 tickShapeFunc: function(group, scale, tick){
42 return group.createLine({
43 x1: tick.isMinor ? 2 : 0,
44 y1: 0,
45 x2: tick.isMinor ? 8 : 12,
46 y2: 0
47 }).setStroke({
48 color: "#EFEFEF",
49 width: tick.isMinor ? 1 : 1
50 })
51 }
52 });
53 this.addElement("scale", scale);
54
55 // The left value indicator
56 var indicator = new CircularValueIndicator({
57 interactionArea: "indicator",
58 indicatorShapeFunc: sharedIndicatorShapeFunc,
59 value: 27
60 });
61 scale.addIndicator("indicator", indicator);
62
63 // The left range indicator (green)
64 var rangeIndicator = new CircularRangeIndicator({
65 start: 15,
66 value: 23,
67 radius: 68,
68 fill: "#0BCD2F",
69 interactionMode: "none"
70 });
71 scale.addIndicator("rangeIndicator", rangeIndicator, true);
72
73 // The right scaler
74 var scaler2 = new LinearScaler({
75 minimum: 0,
76 maximum: 10,
77 majorTickInterval: 1,
78 minorTickInterval: 0.5
79 });
80
81 // The right scale
82 var scale2 = new CircularScale({
83 scaler: scaler2,
84 originX: 100,
85 originY: 100,
86 startAngle: 70,
87 endAngle: 290,
88 orientation: "cclockwise",
89 radius: 70,
90 labelPosition: "outside",
91 tickShapeFunc: function(group, scale, tick){
92 var x1, x2, color, width = 1;
93 // Strong red tick
94 if (tick.value == 0.5 || tick.value == 8){
95 x1 = -2;
96 x2 = 14;
97 color = "#FB0F00";
98 width = 2;
99 }else if(tick.isMinor){
100 // minor ticks
101 x1 = 2;
102 x2 = 8;
103 color = "#EFEFEF";
104 }else{
105 // Major tick
106 x1 = 0;
107 x2 = 12;
108 color = "#EFEFEF";
109 }
110
111 return group.createLine({
112 x1: x1,
113 y1: 0,
114 x2: x2,
115 y2: 0
116 }).setStroke({
117 color: color,
118 width: width
119 })
120 },
121 // Label filter
122 tickLabelFunc: function(tick){
123 return (tick.value % 2) == 0 ? (tick.value).toString() : ""
124 }
125 });
126 this.addElement("scale2", scale2);
127
128 // The right value indicator
129 var indicator2 = new CircularValueIndicator({
130 interactionArea: "indicator",
131 indicatorShapeFunc: sharedIndicatorShapeFunc,
132 value: 8
133 });
134 scale2.addIndicator("indicator2", indicator2);
135
136 // The right range indicator (green)
137 var rangeIndicator2 = new CircularRangeIndicator({
138 start: 0.5,
139 value: 8,
140 radius: 68,
141 fill: "#0BCD2F",
142 interactionMode: "none"
143 });
144 scale2.addIndicator("rangeIndicator2", rangeIndicator2, true);
145
146 // Indicator Text: "MAN"
147 this.addElement("text1", this._createText("MAN", 97, 90, 9, "end"));
148
149 // Indicator Text: "PRESS"
150 this.addElement("text2", this._createText("PRESS", 97, 100, 9, "end"));
151
152 // Indicator Text: "IN HG"
153 this.addElement("text3", this._createText("IN HG", 97, 113, 8, "end"));
154
155 // Indicator Text: "FUEL
156 this.addElement("text4", this._createText("FUEL", 103, 90, 9, "start"));
157
158 // Indicator Text: "PRESS"
159 this.addElement("text5", this._createText("PRESS", 103, 100, 9, "start"));
160
161 // Indicator Text: "PSI"
162 this.addElement("text6", this._createText("PSI", 103, 113, 8, "start"));
163 },
164 _createText: function(text, x, y, size, align){
165 return new TextIndicator({
166 value: text,
167 x: x,
168 y: y,
169 color: "white",
170 font: {
171 family: "Helvetica",
172 size: size
173 },
174 align: align
175 });
176 },
177
178 drawBackground: function(g){
179 var r = this._radius;
180 var w = 2 * r;
181 var h = w;
182 g.createEllipse({
183 cx: r,
184 cy: r,
185 rx: r,
186 ry: r
187 }).setFill("#000000");
188
189 g.createEllipse({
190 cx: r,
191 cy: r,
192 rx: r * 0.99,
193 ry: r * 0.99
194 }).setFill("#505050");
195
196 g.createEllipse({
197 cx: r,
198 cy: r,
199 rx: r * 0.92,
200 ry: r * 0.92
201 }).setFill("#333333").setStroke({
202 color: "#000000",
203 width: 0.5
204 });
205
206 g.createRect({
207 x: 99,
208 y: 20,
209 width: 4,
210 height: 50
211 }).setFill("#EFEFEF");
212
213 g.createRect({
214 x: 99,
215 y: 130,
216 width: 4,
217 height: 50
218 }).setFill("#EFEFEF");
219 }
220 });
221 });