-
Notifications
You must be signed in to change notification settings - Fork 6
/
gfx.js
77 lines (72 loc) · 2.35 KB
/
gfx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
define([
"dojo/has",
"dojo/_base/Color",
"./dojox/gfx",
"./_base",
"./common/Placemark",
"dojo/_base/sniff"
], function(has, Color, gfx, djeo, P){
// center of each shape must be 0,0
djeo.shapes = {
circle: 1, // a dummy value
star: {
size: [1000,1000],
points: [0,-476, 118,-112, 500,-112, 191,112, 309,476, 0,251, -309,476, -191,112, -500,-112, -118,-112, 0,-476]
},
cross: {
size: [10,10],
points: [-1,-5, 1,-5, 1,-1, 5,-1, 5,1, 1,1, 1,5, -1,5, -1,1, -5,1, -5,-1, -1,-1, -1,-5]
},
x: {
size: [100,100],
points: [-50,-50, -25,-50, 0,-15, 25,-50, 50,-50, 15,0, 50,50, 25,50, 0,15, -25,50, -50,50, -15,0, -50,-50]
},
square: {
size: [2,2],
points: [-1,-1, -1,1, 1,1, 1,-1, -1,-1]
},
triangle: {
size: [10,10],
points: [-5,5, 5,5, 0,-5, -5,5]
}
};
return {
applyFill: function(shape, calculatedStyle, specificStyle, specificShapeStyle) {
var fill = P.get("fill", calculatedStyle, specificStyle, specificShapeStyle),
fillOpacity = P.get("fillOpacity", calculatedStyle, specificStyle, specificShapeStyle);
if (fill || fillOpacity !== undefined) {
var gfxFill = shape.getFill(),
gfxFillOpacity = gfxFill && gfxFill.a;
if (fill) gfxFill = new Color(fill);
if (gfxFill) {
if (fillOpacity !== undefined) gfxFill.a = fillOpacity;
else if (gfxFillOpacity !== undefined) gfxFill.a = gfxFillOpacity;
shape.setFill(gfxFill);
}
}
},
applyStroke: function(shape, calculatedStyle, specificStyle, specificShapeStyle, widthMultiplier) {
if (gfx.renderer == "vml" || (gfx.renderer=="svg" && (has("webkit") || has("opera")))) {
widthMultiplier=1;
}
var stroke = P.get("stroke", calculatedStyle, specificStyle, specificShapeStyle),
strokeWidth = P.get("strokeWidth", calculatedStyle, specificStyle, specificShapeStyle),
strokeOpacity = P.get("strokeOpacity", calculatedStyle, specificStyle, specificShapeStyle);
if (stroke || strokeWidth!==undefined || strokeOpacity!==undefined) {
if (strokeWidth === 0) shape.setStroke(null);
else {
var gfxStroke = shape.getStroke();
if (stroke) {
if (!gfxStroke) gfxStroke = {join: "round", cap: "round"};
gfxStroke.color = new Color(stroke);
}
if (gfxStroke) {
if (strokeOpacity !== undefined) gfxStroke.color.a = strokeOpacity;
if (strokeWidth) gfxStroke.width = strokeWidth*widthMultiplier;
shape.setStroke(gfxStroke);
}
}
}
}
};
});