Debian Codegraph @

dojox/dgauges/components/black/VerticalLinearGauge.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.black.VerticalLinearGauge", [RectangularGauge, DefaultPropertiesMixin], {
13 // summary:
14 // A vertical gauge widget.
15
16 // borderColor: Object|Array|int
17 // The border color. Default is "#000000".
18 borderColor: "#000000",
19 // fillColor: Object|Array|int
20 // The background color. Default is "#000000".
21 fillColor: "#000000",
22 // indicatorColor: Object|Array|int
23 // The indicator fill color. Default is "#A4A4A4".
24 indicatorColor: "#A4A4A4",
25 constructor: function(){
26 this.orientation = "vertical";
27 // Base colors
28 this.borderColor = new Color(this.borderColor);
29 this.fillColor = new Color(this.fillColor);
30 this.indicatorColor = new Color(this.indicatorColor);
31
32 this.addElement("background", lang.hitch(this, this.drawBackground));
33
34 // Scaler
35 var scaler = new LinearScaler();
36
37 // Scale
38 var scale = new RectangularScale();
39 scale.set("scaler", scaler);
40 scale.set("labelPosition", "trailing");
41 scale.set("paddingTop", 30);
42 scale.set("paddingBottom", 30);
43 scale.set("paddingLeft", 15);
44 scale.set("font", {
45 family: "Helvetica",
46 weight: "bold",
47 size: "7pt",
48 color: "#CECECE"
49 });
50 scale.set("tickShapeFunc", function(group, scale, tick){
51 return group.createCircle({
52 r: tick.isMinor ? 0.5 : 3
53 }).setFill("#CECECE");
54 });
55 this.addElement("scale", scale);
56
57 var indicator = new RectangularValueIndicator();
58 indicator.set("interactionArea", "gauge");
59 indicator.set("value", scaler.minimum);
60 indicator.set("paddingLeft", 18);
61 indicator.set("indicatorShapeFunc", lang.hitch(this, function(group){
62 return group.createPolyline([0, 0, -10, -20, 10, -20, 0, 0]).setFill(this.indicatorColor).setStroke({
63 color: [69,69,69],
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: 50,
89 height: h,
90 r: 15
91 }).setFill(this.borderColor);
92 g.createRect({
93 x: 4,
94 y: 4,
95 width: 42,
96 height: h - 8,
97 r: 12
98 }).setFill({
99 type: "linear",
100 x1: 5,
101 y1: 0,
102 x2: 20,
103 y2: 0,
104 colors: [
105 {offset: 0, color: [100,100,100]},
106 {offset: 1, color: this.fillColor}
107 ]
108 });
109 g.createPath().moveTo(25, 4).hLineTo(36).smoothCurveTo(46, 4, 46, 18).vLineTo(h - 20).smoothCurveTo(46, h - 4, 36, h - 4).closePath().setFill({
110 type: "linear",
111 x1: 70,
112 y1: 0,
113 x2: 25,
114 y2: 0,
115 colors: [
116 {offset: 0, color: [150,150,150]},
117 {offset: 1, color: this.fillColor}
118 ]
119 });
120 g.createPath().moveTo(25, 4).hLineTo(36).smoothCurveTo(46, 4, 46, 18).vLineTo(h - 20).smoothCurveTo(46, h - 4, 36, h - 4).closePath().setFill([255,255,255,0.05]);
121 }
122
123 });
124 }
125 );
126