@datagrok/helm 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1024 @@
1
+ define("dojox/gfx/_base", ["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window",
2
+ "dojo/_base/array","dojo/dom", "dojo/dom-construct","dojo/dom-geometry"],
3
+ function(kernel, lang, Color, has, win, arr, dom, domConstruct, domGeom){
4
+ // module:
5
+ // dojox/gfx
6
+ // summary:
7
+ // This module contains common core Graphics API used by different graphics renderers.
8
+
9
+ var g = lang.getObject("dojox.gfx", true),
10
+ b = g._base = {};
11
+
12
+ // candidates for dojox.style (work on VML and SVG nodes)
13
+ g._hasClass = function(/*DomNode*/node, /*String*/classStr){
14
+ // summary:
15
+ // Returns whether or not the specified classes are a portion of the
16
+ // class list currently applied to the node.
17
+
18
+ // return (new RegExp('(^|\\s+)'+classStr+'(\\s+|$)')).test(node.className) // Boolean
19
+ var cls = node.getAttribute("className");
20
+ return cls && (" " + cls + " ").indexOf(" " + classStr + " ") >= 0; // Boolean
21
+ };
22
+ g._addClass = function(/*DomNode*/node, /*String*/classStr){
23
+ // summary:
24
+ // Adds the specified classes to the end of the class list on the
25
+ // passed node.
26
+ var cls = node.getAttribute("className") || "";
27
+ if(!cls || (" " + cls + " ").indexOf(" " + classStr + " ") < 0){
28
+ node.setAttribute("className", cls + (cls ? " " : "") + classStr);
29
+ }
30
+ };
31
+ g._removeClass = function(/*DomNode*/node, /*String*/classStr){
32
+ // summary:
33
+ // Removes classes from node.
34
+ var cls = node.getAttribute("className");
35
+ if(cls){
36
+ node.setAttribute(
37
+ "className",
38
+ cls.replace(new RegExp('(^|\\s+)' + classStr + '(\\s+|$)'), "$1$2")
39
+ );
40
+ }
41
+ };
42
+
43
+ // candidate for dojox.html.metrics (dynamic font resize handler is not implemented here)
44
+
45
+ // derived from Morris John's emResized measurer
46
+ b._getFontMeasurements = function(){
47
+ // summary:
48
+ // Returns an object that has pixel equivilents of standard font
49
+ // size values.
50
+ var heights = {
51
+ '1em': 0, '1ex': 0, '100%': 0, '12pt': 0, '16px': 0, 'xx-small': 0,
52
+ 'x-small': 0, 'small': 0, 'medium': 0, 'large': 0, 'x-large': 0,
53
+ 'xx-large': 0
54
+ };
55
+ var p, oldStyle;
56
+ if(has("ie")){
57
+ // We do a font-size fix if and only if one isn't applied already.
58
+ // NOTE: If someone set the fontSize on the HTML Element, this will kill it.
59
+ oldStyle = win.doc.documentElement.style.fontSize || "";
60
+ if(!oldStyle){
61
+ win.doc.documentElement.style.fontSize="100%";
62
+ }
63
+ }
64
+
65
+ // set up the measuring node.
66
+ var div = domConstruct.create("div", {style: {
67
+ position: "absolute",
68
+ left: "0",
69
+ top: "-100px",
70
+ width: "30px",
71
+ height: "1000em",
72
+ borderWidth: "0",
73
+ margin: "0",
74
+ padding: "0",
75
+ outline: "none",
76
+ lineHeight: "1",
77
+ overflow: "hidden"
78
+ }}, win.body());
79
+
80
+ // do the measurements.
81
+ for(p in heights){
82
+ div.style.fontSize = p;
83
+ heights[p] = Math.round(div.offsetHeight * 12/16) * 16/12 / 1000;
84
+ }
85
+
86
+ if(has("ie")){
87
+ // Restore the font to its old style.
88
+ win.doc.documentElement.style.fontSize = oldStyle;
89
+ }
90
+ win.body().removeChild(div);
91
+ return heights; //object
92
+ };
93
+
94
+ var fontMeasurements = null;
95
+
96
+ b._getCachedFontMeasurements = function(recalculate){
97
+ if(recalculate || !fontMeasurements){
98
+ fontMeasurements = b._getFontMeasurements();
99
+ }
100
+ return fontMeasurements;
101
+ };
102
+
103
+ // candidate for dojox.html.metrics
104
+
105
+ var measuringNode = null, empty = {};
106
+ b._getTextBox = function( /*String*/ text,
107
+ /*Object*/ style,
108
+ /*String?*/ className){
109
+ var m, s, al = arguments.length;
110
+ var i, box;
111
+ if(!measuringNode){
112
+ measuringNode = domConstruct.create("div", {style: {
113
+ position: "absolute",
114
+ top: "-10000px",
115
+ left: "0",
116
+ visibility: "hidden"
117
+ }}, win.body());
118
+ }
119
+ m = measuringNode;
120
+ // reset styles
121
+ m.className = "";
122
+ s = m.style;
123
+ s.borderWidth = "0";
124
+ s.margin = "0";
125
+ s.padding = "0";
126
+ s.outline = "0";
127
+ // set new style
128
+ if(al > 1 && style){
129
+ for(i in style){
130
+ if(i in empty){ continue; }
131
+ s[i] = style[i];
132
+ }
133
+ }
134
+ // set classes
135
+ if(al > 2 && className){
136
+ m.className = className;
137
+ }
138
+ // take a measure
139
+ m.innerHTML = text;
140
+
141
+ if(m.getBoundingClientRect){
142
+ var bcr = m.getBoundingClientRect();
143
+ box = {l: bcr.left, t: bcr.top, w: bcr.width || (bcr.right - bcr.left), h: bcr.height || (bcr.bottom - bcr.top)};
144
+ }else{
145
+ box = domGeom.getMarginBox(m);
146
+ }
147
+ m.innerHTML = "";
148
+ return box;
149
+ };
150
+
151
+ b._computeTextLocation = function(/*g.defaultTextShape*/textShape, /*Number*/width, /*Number*/height, /*Boolean*/fixHeight) {
152
+ var loc = {}, align = textShape.align;
153
+ switch (align) {
154
+ case 'end':
155
+ loc.x = textShape.x - width;
156
+ break;
157
+ case 'middle':
158
+ loc.x = textShape.x - width / 2;
159
+ break;
160
+ default:
161
+ loc.x = textShape.x;
162
+ break;
163
+ }
164
+ var c = fixHeight ? 0.75 : 1;
165
+ loc.y = textShape.y - height*c; // **rough** approximation of the ascent...
166
+ return loc;
167
+ };
168
+ b._computeTextBoundingBox = function(/*shape.Text*/s){
169
+ // summary:
170
+ // Compute the bbox of the given shape.Text instance. Note that this method returns an
171
+ // approximation of the bbox, and should be used when the underlying renderer cannot provide precise metrics.
172
+ if(!g._base._isRendered(s)){
173
+ return {x:0, y:0, width:0, height:0};
174
+ }
175
+ var loc, textShape = s.getShape(),
176
+ font = s.getFont() || g.defaultFont,
177
+ w = s.getTextWidth(),
178
+ h = g.normalizedLength(font.size);
179
+ loc = b._computeTextLocation(textShape, w, h, true);
180
+ return {
181
+ x: loc.x,
182
+ y: loc.y,
183
+ width: w,
184
+ height: h
185
+ };
186
+ };
187
+ b._isRendered = function(/*Shape*/s){
188
+ var p = s.parent;
189
+ while(p && p.getParent){
190
+ p = p.parent;
191
+ }
192
+ return p !== null;
193
+ };
194
+
195
+ // candidate for dojo.dom
196
+
197
+ var uniqueId = 0;
198
+ b._getUniqueId = function(){
199
+ // summary:
200
+ // returns a unique string for use with any DOM element
201
+ var id;
202
+ do{
203
+ id = kernel._scopeName + "xUnique" + (++uniqueId);
204
+ }while(dom.byId(id));
205
+ return id;
206
+ };
207
+
208
+ // IE10
209
+
210
+ var touchActionProp = has("pointer-events") ? "touchAction" : has("MSPointer") ? "msTouchAction" : null;
211
+ b._fixMsTouchAction = touchActionProp ? function(/*dojox/gfx/shape.Surface*/surface){
212
+ surface.rawNode.style[touchActionProp] = "none";
213
+ } : function() {};
214
+
215
+ /*=====
216
+ g.Stroke = {
217
+ // summary:
218
+ // A stroke defines stylistic properties that are used when drawing a path.
219
+
220
+ // color: String
221
+ // The color of the stroke, default value 'black'.
222
+ color: "black",
223
+
224
+ // style: String
225
+ // The style of the stroke, one of 'solid', ... . Default value 'solid'.
226
+ style: "solid",
227
+
228
+ // width: Number
229
+ // The width of a stroke, default value 1.
230
+ width: 1,
231
+
232
+ // cap: String
233
+ // The endcap style of the path. One of 'butt', 'round', ... . Default value 'butt'.
234
+ cap: "butt",
235
+
236
+ // join: Number
237
+ // The join style to use when combining path segments. Default value 4.
238
+ join: 4
239
+ };
240
+
241
+ g.Fill = {
242
+ // summary:
243
+ // Defines how to fill a shape. Four types of fills can be used: solid, linear gradient, radial gradient and pattern.
244
+ // See dojox/gfx.LinearGradient, dojox/gfx.RadialGradient and dojox/gfx.Pattern respectively for more information about the properties supported by each type.
245
+
246
+ // type: String?
247
+ // The type of fill. One of 'linear', 'radial', 'pattern' or undefined. If not specified, a solid fill is assumed.
248
+ type:"",
249
+
250
+ // color: String|dojo/Color?
251
+ // The color of a solid fill type.
252
+ color:null,
253
+
254
+ };
255
+
256
+ g.LinearGradient = {
257
+ // summary:
258
+ // An object defining the default stylistic properties used for Linear Gradient fills.
259
+ // Linear gradients are drawn along a virtual line, which results in appearance of a rotated pattern in a given direction/orientation.
260
+
261
+ // type: String
262
+ // Specifies this object is a Linear Gradient, value 'linear'
263
+ type: "linear",
264
+
265
+ // x1: Number
266
+ // The X coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
267
+ x1: 0,
268
+
269
+ // y1: Number
270
+ // The Y coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
271
+ y1: 0,
272
+
273
+ // x2: Number
274
+ // The X coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
275
+ x2: 100,
276
+
277
+ // y2: Number
278
+ // The Y coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
279
+ y2: 100,
280
+
281
+ // colors: Array
282
+ // An array of colors at given offsets (from the start of the line). The start of the line is
283
+ // defined at offest 0 with the end of the line at offset 1.
284
+ // Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
285
+ colors: []
286
+ };
287
+
288
+ g.RadialGradient = {
289
+ // summary:
290
+ // Specifies the properties for RadialGradients using in fills patterns.
291
+
292
+ // type: String
293
+ // Specifies this is a RadialGradient, value 'radial'
294
+ type: "radial",
295
+
296
+ // cx: Number
297
+ // The X coordinate of the center of the radial gradient, default value 0.
298
+ cx: 0,
299
+
300
+ // cy: Number
301
+ // The Y coordinate of the center of the radial gradient, default value 0.
302
+ cy: 0,
303
+
304
+ // r: Number
305
+ // The radius to the end of the radial gradient, default value 100.
306
+ r: 100,
307
+
308
+ // colors: Array
309
+ // An array of colors at given offsets (from the center of the radial gradient).
310
+ // The center is defined at offest 0 with the outer edge of the gradient at offset 1.
311
+ // Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
312
+ colors: []
313
+ };
314
+
315
+ g.Pattern = {
316
+ // summary:
317
+ // An object specifying the default properties for a Pattern using in fill operations.
318
+
319
+ // type: String
320
+ // Specifies this object is a Pattern, value 'pattern'.
321
+ type: "pattern",
322
+
323
+ // x: Number
324
+ // The X coordinate of the position of the pattern, default value is 0.
325
+ x: 0,
326
+
327
+ // y: Number
328
+ // The Y coordinate of the position of the pattern, default value is 0.
329
+ y: 0,
330
+
331
+ // width: Number
332
+ // The width of the pattern image, default value is 0.
333
+ width: 0,
334
+
335
+ // height: Number
336
+ // The height of the pattern image, default value is 0.
337
+ height: 0,
338
+
339
+ // src: String
340
+ // A url specifying the image to use for the pattern.
341
+ src: ""
342
+ };
343
+
344
+ g.Text = {
345
+ // summary:
346
+ // A keyword argument object defining both the text to be rendered in a VectorText shape,
347
+ // and specifying position, alignment, and fitting.
348
+ // text: String
349
+ // The text to be rendered.
350
+ // x: Number?
351
+ // The left coordinate for the text's bounding box.
352
+ // y: Number?
353
+ // The top coordinate for the text's bounding box.
354
+ // width: Number?
355
+ // The width of the text's bounding box.
356
+ // height: Number?
357
+ // The height of the text's bounding box.
358
+ // align: String?
359
+ // The alignment of the text, as defined in SVG. Can be "start", "end" or "middle".
360
+ // fitting: Number?
361
+ // How the text is to be fitted to the bounding box. Can be 0 (no fitting), 1 (fitting based on
362
+ // passed width of the bounding box and the size of the font), or 2 (fit text to the bounding box,
363
+ // and ignore any size parameters).
364
+ // leading: Number?
365
+ // The leading to be used between lines in the text.
366
+ // decoration: String?
367
+ // Any text decoration to be used.
368
+ };
369
+
370
+ g.Font = {
371
+ // summary:
372
+ // An object specifying the properties for a Font used in text operations.
373
+
374
+ // type: String
375
+ // Specifies this object is a Font, value 'font'.
376
+ type: "font",
377
+
378
+ // style: String
379
+ // The font style, one of 'normal', 'bold', default value 'normal'.
380
+ style: "normal",
381
+
382
+ // variant: String
383
+ // The font variant, one of 'normal', ... , default value 'normal'.
384
+ variant: "normal",
385
+
386
+ // weight: String
387
+ // The font weight, one of 'normal', ..., default value 'normal'.
388
+ weight: "normal",
389
+
390
+ // size: String
391
+ // The font size (including units), default value '10pt'.
392
+ size: "10pt",
393
+
394
+ // family: String
395
+ // The font family, one of 'serif', 'sanserif', ..., default value 'serif'.
396
+ family: "serif"
397
+ };
398
+
399
+ =====*/
400
+
401
+ lang.mixin(g, {
402
+ // summary:
403
+ // defines constants, prototypes, and utility functions for the core Graphics API
404
+
405
+ // default shapes, which are used to fill in missing parameters
406
+ defaultPath: {
407
+ // summary:
408
+ // Defines the default Path prototype object.
409
+
410
+ // type: String
411
+ // Specifies this object is a Path, default value 'path'.
412
+ type: "path",
413
+
414
+ // path: String
415
+ // The path commands. See W32C SVG 1.0 specification.
416
+ // Defaults to empty string value.
417
+ path: ""
418
+ },
419
+ defaultPolyline: {
420
+ // summary:
421
+ // Defines the default PolyLine prototype.
422
+
423
+ // type: String
424
+ // Specifies this object is a PolyLine, default value 'polyline'.
425
+ type: "polyline",
426
+
427
+ // points: Array
428
+ // An array of point objects [{x:0,y:0},...] defining the default polyline's line segments. Value is an empty array [].
429
+ points: []
430
+ },
431
+ defaultRect: {
432
+ // summary:
433
+ // Defines the default Rect prototype.
434
+
435
+ // type: String
436
+ // Specifies this default object is a type of Rect. Value is 'rect'
437
+ type: "rect",
438
+
439
+ // x: Number
440
+ // The X coordinate of the default rectangles position, value 0.
441
+ x: 0,
442
+
443
+ // y: Number
444
+ // The Y coordinate of the default rectangle's position, value 0.
445
+ y: 0,
446
+
447
+ // width: Number
448
+ // The width of the default rectangle, value 100.
449
+ width: 100,
450
+
451
+ // height: Number
452
+ // The height of the default rectangle, value 100.
453
+ height: 100,
454
+
455
+ // r: Number
456
+ // The corner radius for the default rectangle, value 0.
457
+ r: 0
458
+ },
459
+ defaultEllipse: {
460
+ // summary:
461
+ // Defines the default Ellipse prototype.
462
+
463
+ // type: String
464
+ // Specifies that this object is a type of Ellipse, value is 'ellipse'
465
+ type: "ellipse",
466
+
467
+ // cx: Number
468
+ // The X coordinate of the center of the ellipse, default value 0.
469
+ cx: 0,
470
+
471
+ // cy: Number
472
+ // The Y coordinate of the center of the ellipse, default value 0.
473
+ cy: 0,
474
+
475
+ // rx: Number
476
+ // The radius of the ellipse in the X direction, default value 200.
477
+ rx: 200,
478
+
479
+ // ry: Number
480
+ // The radius of the ellipse in the Y direction, default value 200.
481
+ ry: 100
482
+ },
483
+ defaultCircle: {
484
+ // summary:
485
+ // An object defining the default Circle prototype.
486
+
487
+ // type: String
488
+ // Specifies this object is a circle, value 'circle'
489
+ type: "circle",
490
+
491
+ // cx: Number
492
+ // The X coordinate of the center of the circle, default value 0.
493
+ cx: 0,
494
+ // cy: Number
495
+ // The Y coordinate of the center of the circle, default value 0.
496
+ cy: 0,
497
+
498
+ // r: Number
499
+ // The radius, default value 100.
500
+ r: 100
501
+ },
502
+ defaultLine: {
503
+ // summary:
504
+ // An object defining the default Line prototype.
505
+
506
+ // type: String
507
+ // Specifies this is a Line, value 'line'
508
+ type: "line",
509
+
510
+ // x1: Number
511
+ // The X coordinate of the start of the line, default value 0.
512
+ x1: 0,
513
+
514
+ // y1: Number
515
+ // The Y coordinate of the start of the line, default value 0.
516
+ y1: 0,
517
+
518
+ // x2: Number
519
+ // The X coordinate of the end of the line, default value 100.
520
+ x2: 100,
521
+
522
+ // y2: Number
523
+ // The Y coordinate of the end of the line, default value 100.
524
+ y2: 100
525
+ },
526
+ defaultImage: {
527
+ // summary:
528
+ // Defines the default Image prototype.
529
+
530
+ // type: String
531
+ // Specifies this object is an image, value 'image'.
532
+ type: "image",
533
+
534
+ // x: Number
535
+ // The X coordinate of the image's position, default value 0.
536
+ x: 0,
537
+
538
+ // y: Number
539
+ // The Y coordinate of the image's position, default value 0.
540
+ y: 0,
541
+
542
+ // width: Number
543
+ // The width of the image, default value 0.
544
+ width: 0,
545
+
546
+ // height: Number
547
+ // The height of the image, default value 0.
548
+ height: 0,
549
+
550
+ // src: String
551
+ // The src url of the image, defaults to empty string.
552
+ src: ""
553
+ },
554
+ defaultText: {
555
+ // summary:
556
+ // Defines the default Text prototype.
557
+
558
+ // type: String
559
+ // Specifies this is a Text shape, value 'text'.
560
+ type: "text",
561
+
562
+ // x: Number
563
+ // The X coordinate of the text position, default value 0.
564
+ x: 0,
565
+
566
+ // y: Number
567
+ // The Y coordinate of the text position, default value 0.
568
+ y: 0,
569
+
570
+ // text: String
571
+ // The text to be displayed, default value empty string.
572
+ text: "",
573
+
574
+ // align: String
575
+ // The horizontal text alignment, one of 'start', 'end', 'center'. Default value 'start'.
576
+ align: "start",
577
+
578
+ // decoration: String
579
+ // The text decoration , one of 'none', ... . Default value 'none'.
580
+ decoration: "none",
581
+
582
+ // rotated: Boolean
583
+ // Whether the text is rotated, boolean default value false.
584
+ rotated: false,
585
+
586
+ // kerning: Boolean
587
+ // Whether kerning is used on the text, boolean default value true.
588
+ kerning: true
589
+ },
590
+ defaultTextPath: {
591
+ // summary:
592
+ // Defines the default TextPath prototype.
593
+
594
+ // type: String
595
+ // Specifies this is a TextPath, value 'textpath'.
596
+ type: "textpath",
597
+
598
+ // text: String
599
+ // The text to be displayed, default value empty string.
600
+ text: "",
601
+
602
+ // align: String
603
+ // The horizontal text alignment, one of 'start', 'end', 'center'. Default value 'start'.
604
+ align: "start",
605
+
606
+ // decoration: String
607
+ // The text decoration , one of 'none', ... . Default value 'none'.
608
+ decoration: "none",
609
+
610
+ // rotated: Boolean
611
+ // Whether the text is rotated, boolean default value false.
612
+ rotated: false,
613
+
614
+ // kerning: Boolean
615
+ // Whether kerning is used on the text, boolean default value true.
616
+ kerning: true
617
+ },
618
+
619
+ // default stylistic attributes
620
+ defaultStroke: {
621
+ // summary:
622
+ // A stroke defines stylistic properties that are used when drawing a path.
623
+ // This object defines the default Stroke prototype.
624
+ // type: String
625
+ // Specifies this object is a type of Stroke, value 'stroke'.
626
+ type: "stroke",
627
+
628
+ // color: String
629
+ // The color of the stroke, default value 'black'.
630
+ color: "black",
631
+
632
+ // style: String
633
+ // The style of the stroke, one of 'solid', ... . Default value 'solid'.
634
+ style: "solid",
635
+
636
+ // width: Number
637
+ // The width of a stroke, default value 1.
638
+ width: 1,
639
+
640
+ // cap: String
641
+ // The endcap style of the path. One of 'butt', 'round', ... . Default value 'butt'.
642
+ cap: "butt",
643
+
644
+ // join: Number
645
+ // The join style to use when combining path segments. Default value 4.
646
+ join: 4
647
+ },
648
+ defaultLinearGradient: {
649
+ // summary:
650
+ // An object defining the default stylistic properties used for Linear Gradient fills.
651
+ // Linear gradients are drawn along a virtual line, which results in appearance of a rotated pattern in a given direction/orientation.
652
+
653
+ // type: String
654
+ // Specifies this object is a Linear Gradient, value 'linear'
655
+ type: "linear",
656
+
657
+ // x1: Number
658
+ // The X coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
659
+ x1: 0,
660
+
661
+ // y1: Number
662
+ // The Y coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
663
+ y1: 0,
664
+
665
+ // x2: Number
666
+ // The X coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
667
+ x2: 100,
668
+
669
+ // y2: Number
670
+ // The Y coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
671
+ y2: 100,
672
+
673
+ // colors: Array
674
+ // An array of colors at given offsets (from the start of the line). The start of the line is
675
+ // defined at offest 0 with the end of the line at offset 1.
676
+ // Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
677
+ colors: [
678
+ { offset: 0, color: "black" }, { offset: 1, color: "white" }
679
+ ]
680
+ },
681
+ defaultRadialGradient: {
682
+ // summary:
683
+ // An object specifying the default properties for RadialGradients using in fills patterns.
684
+
685
+ // type: String
686
+ // Specifies this is a RadialGradient, value 'radial'
687
+ type: "radial",
688
+
689
+ // cx: Number
690
+ // The X coordinate of the center of the radial gradient, default value 0.
691
+ cx: 0,
692
+
693
+ // cy: Number
694
+ // The Y coordinate of the center of the radial gradient, default value 0.
695
+ cy: 0,
696
+
697
+ // r: Number
698
+ // The radius to the end of the radial gradient, default value 100.
699
+ r: 100,
700
+
701
+ // colors: Array
702
+ // An array of colors at given offsets (from the center of the radial gradient).
703
+ // The center is defined at offest 0 with the outer edge of the gradient at offset 1.
704
+ // Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
705
+ colors: [
706
+ { offset: 0, color: "black" }, { offset: 1, color: "white" }
707
+ ]
708
+ },
709
+ defaultPattern: {
710
+ // summary:
711
+ // An object specifying the default properties for a Pattern using in fill operations.
712
+
713
+ // type: String
714
+ // Specifies this object is a Pattern, value 'pattern'.
715
+ type: "pattern",
716
+
717
+ // x: Number
718
+ // The X coordinate of the position of the pattern, default value is 0.
719
+ x: 0,
720
+
721
+ // y: Number
722
+ // The Y coordinate of the position of the pattern, default value is 0.
723
+ y: 0,
724
+
725
+ // width: Number
726
+ // The width of the pattern image, default value is 0.
727
+ width: 0,
728
+
729
+ // height: Number
730
+ // The height of the pattern image, default value is 0.
731
+ height: 0,
732
+
733
+ // src: String
734
+ // A url specifying the image to use for the pattern.
735
+ src: ""
736
+ },
737
+ defaultFont: {
738
+ // summary:
739
+ // An object specifying the default properties for a Font used in text operations.
740
+
741
+ // type: String
742
+ // Specifies this object is a Font, value 'font'.
743
+ type: "font",
744
+
745
+ // style: String
746
+ // The font style, one of 'normal', 'bold', default value 'normal'.
747
+ style: "normal",
748
+
749
+ // variant: String
750
+ // The font variant, one of 'normal', ... , default value 'normal'.
751
+ variant: "normal",
752
+
753
+ // weight: String
754
+ // The font weight, one of 'normal', ..., default value 'normal'.
755
+ weight: "normal",
756
+
757
+ // size: String
758
+ // The font size (including units), default value '10pt'.
759
+ size: "10pt",
760
+
761
+ // family: String
762
+ // The font family, one of 'serif', 'sanserif', ..., default value 'serif'.
763
+ family: "serif"
764
+ },
765
+
766
+ getDefault: (function(){
767
+ // summary:
768
+ // Returns a function used to access default memoized prototype objects (see them defined above).
769
+ var typeCtorCache = {};
770
+ // a memoized delegate()
771
+ return function(/*String*/ type){
772
+ var t = typeCtorCache[type];
773
+ if(t){
774
+ return new t();
775
+ }
776
+ t = typeCtorCache[type] = new Function();
777
+ t.prototype = g[ "default" + type ];
778
+ return new t();
779
+ }
780
+ })(),
781
+
782
+ normalizeColor: function(/*dojo/Color|Array|string|Object*/ color){
783
+ // summary:
784
+ // converts any legal color representation to normalized
785
+ // dojo/Color object
786
+ // color:
787
+ // A color representation.
788
+ return (color instanceof Color) ? color : new Color(color); // dojo/Color
789
+ },
790
+ normalizeParameters: function(existed, update){
791
+ // summary:
792
+ // updates an existing object with properties from an 'update'
793
+ // object
794
+ // existed: Object
795
+ // the target object to be updated
796
+ // update: Object
797
+ // the 'update' object, whose properties will be used to update
798
+ // the existed object
799
+ var x;
800
+ if(update){
801
+ var empty = {};
802
+ for(x in existed){
803
+ if(x in update && !(x in empty)){
804
+ existed[x] = update[x];
805
+ }
806
+ }
807
+ }
808
+ return existed; // Object
809
+ },
810
+ makeParameters: function(defaults, update){
811
+ // summary:
812
+ // copies the original object, and all copied properties from the
813
+ // 'update' object
814
+ // defaults: Object
815
+ // the object to be cloned before updating
816
+ // update: Object
817
+ // the object, which properties are to be cloned during updating
818
+ // returns: Object
819
+ // new object with new and default properties
820
+ var i = null;
821
+ if(!update){
822
+ // return dojo.clone(defaults);
823
+ return lang.delegate(defaults);
824
+ }
825
+ var result = {};
826
+ for(i in defaults){
827
+ if(!(i in result)){
828
+ result[i] = lang.clone((i in update) ? update[i] : defaults[i]);
829
+ }
830
+ }
831
+ return result; // Object
832
+ },
833
+ formatNumber: function(x, addSpace){
834
+ // summary:
835
+ // converts a number to a string using a fixed notation
836
+ // x: Number
837
+ // number to be converted
838
+ // addSpace: Boolean
839
+ // whether to add a space before a positive number
840
+ // returns: String
841
+ // the formatted value
842
+ var val = x.toString();
843
+ if(val.indexOf("e") >= 0){
844
+ val = x.toFixed(4);
845
+ }else{
846
+ var point = val.indexOf(".");
847
+ if(point >= 0 && val.length - point > 5){
848
+ val = x.toFixed(4);
849
+ }
850
+ }
851
+ if(x < 0){
852
+ return val; // String
853
+ }
854
+ return addSpace ? " " + val : val; // String
855
+ },
856
+ // font operations
857
+ makeFontString: function(font){
858
+ // summary:
859
+ // converts a font object to a CSS font string
860
+ // font: Object
861
+ // font object (see dojox/gfx.defaultFont)
862
+ return font.style + " " + font.variant + " " + font.weight + " " + font.size + " " + font.family; // Object
863
+ },
864
+ splitFontString: function(str){
865
+ // summary:
866
+ // converts a CSS font string to a font object
867
+ // description:
868
+ // Converts a CSS font string to a gfx font object. The CSS font
869
+ // string components should follow the W3C specified order
870
+ // (see http://www.w3.org/TR/CSS2/fonts.html#font-shorthand):
871
+ // style, variant, weight, size, optional line height (will be
872
+ // ignored), and family. Note that the Font.size attribute is limited to numeric CSS length.
873
+ // str: String
874
+ // a CSS font string.
875
+ // returns: Object
876
+ // object in dojox/gfx.defaultFont format
877
+ var font = g.getDefault("Font");
878
+ var t = str.split(/\s+/);
879
+ do{
880
+ if(t.length < 5){ break; }
881
+ font.style = t[0];
882
+ font.variant = t[1];
883
+ font.weight = t[2];
884
+ var i = t[3].indexOf("/");
885
+ font.size = i < 0 ? t[3] : t[3].substring(0, i);
886
+ var j = 4;
887
+ if(i < 0){
888
+ if(t[4] == "/"){
889
+ j = 6;
890
+ }else if(t[4].charAt(0) == "/"){
891
+ j = 5;
892
+ }
893
+ }
894
+ if(j < t.length){
895
+ font.family = t.slice(j).join(" ");
896
+ }
897
+ }while(false);
898
+ return font; // Object
899
+ },
900
+ // length operations
901
+
902
+ // cm_in_pt: Number
903
+ // points per centimeter (constant)
904
+ cm_in_pt: 72 / 2.54,
905
+
906
+ // mm_in_pt: Number
907
+ // points per millimeter (constant)
908
+ mm_in_pt: 7.2 / 2.54,
909
+
910
+ px_in_pt: function(){
911
+ // summary:
912
+ // returns the current number of pixels per point.
913
+ return g._base._getCachedFontMeasurements()["12pt"] / 12; // Number
914
+ },
915
+
916
+ pt2px: function(len){
917
+ // summary:
918
+ // converts points to pixels
919
+ // len: Number
920
+ // a value in points
921
+ return len * g.px_in_pt(); // Number
922
+ },
923
+
924
+ px2pt: function(len){
925
+ // summary:
926
+ // converts pixels to points
927
+ // len: Number
928
+ // a value in pixels
929
+ return len / g.px_in_pt(); // Number
930
+ },
931
+
932
+ normalizedLength: function(len) {
933
+ // summary:
934
+ // converts any length value to pixels
935
+ // len: String
936
+ // a length, e.g., '12pc'
937
+ // returns: Number
938
+ // pixels
939
+ if(len.length === 0){ return 0; }
940
+ if(len.length > 2){
941
+ var px_in_pt = g.px_in_pt();
942
+ var val = parseFloat(len);
943
+ switch(len.slice(-2)){
944
+ case "px": return val;
945
+ case "pt": return val * px_in_pt;
946
+ case "in": return val * 72 * px_in_pt;
947
+ case "pc": return val * 12 * px_in_pt;
948
+ case "mm": return val * g.mm_in_pt * px_in_pt;
949
+ case "cm": return val * g.cm_in_pt * px_in_pt;
950
+ }
951
+ }
952
+ return parseFloat(len); // Number
953
+ },
954
+
955
+ // pathVmlRegExp: RegExp
956
+ // a constant regular expression used to split a SVG/VML path into primitive components
957
+ // tags:
958
+ // private
959
+ pathVmlRegExp: /([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
960
+
961
+ // pathVmlRegExp: RegExp
962
+ // a constant regular expression used to split a SVG/VML path into primitive components
963
+ // tags:
964
+ // private
965
+ pathSvgRegExp: /([A-DF-Za-df-z])|([-+]?\d*[.]?\d+(?:[eE][-+]?\d+)?)/g,
966
+
967
+ equalSources: function(a, b){
968
+ // summary:
969
+ // compares event sources, returns true if they are equal
970
+ // a: Object
971
+ // first event source
972
+ // b: Object
973
+ // event source to compare against a
974
+ // returns: Boolean
975
+ // true, if objects are truthy and the same
976
+ return a && b && a === b;
977
+ },
978
+
979
+ switchTo: function(/*String|Object*/ renderer){
980
+ // summary:
981
+ // switch the graphics implementation to the specified renderer.
982
+ // renderer:
983
+ // Either the string name of a renderer (eg. 'canvas', 'svg, ...) or the renderer
984
+ // object to switch to.
985
+ var ns = typeof renderer == "string" ? g[renderer] : renderer;
986
+ if(ns){
987
+ // If more options are added, update the docblock at the end of shape.js!
988
+ arr.forEach(["Group", "Rect", "Ellipse", "Circle", "Line",
989
+ "Polyline", "Image", "Text", "Path", "TextPath",
990
+ "Surface", "createSurface", "fixTarget"], function(name){
991
+ g[name] = ns[name];
992
+ });
993
+ if(typeof renderer == "string"){
994
+ g.renderer = renderer;
995
+ }else{
996
+ arr.some(["svg","vml","canvas","canvasWithEvents","silverlight"], function(r){
997
+ return (g.renderer = g[r] && g[r].Surface === g.Surface ? r : null);
998
+ });
999
+ }
1000
+ }
1001
+ }
1002
+ });
1003
+
1004
+ /*=====
1005
+ g.createSurface = function(parentNode, width, height){
1006
+ // summary:
1007
+ // creates a surface
1008
+ // parentNode: Node
1009
+ // a parent node
1010
+ // width: String|Number
1011
+ // width of surface, e.g., "100px" or 100
1012
+ // height: String|Number
1013
+ // height of surface, e.g., "100px" or 100
1014
+ // returns: dojox/gfx.Surface
1015
+ // newly created surface
1016
+ };
1017
+ g.fixTarget = function(){
1018
+ // tags:
1019
+ // private
1020
+ };
1021
+ =====*/
1022
+
1023
+ return g; // defaults object api
1024
+ });