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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/**
* $Id: mxDoubleEllipse.js,v 1.19 2012-05-21 18:27:17 gaudenz Exp $
* Copyright (c) 2006-2010, JGraph Ltd
*/
/**
* Class: mxDoubleEllipse
*
* Extends <mxShape> to implement a double ellipse shape.
* This shape is registered under <mxConstants.SHAPE_DOUBLE_ELLIPSE>
* in <mxCellRenderer>.
*
* Constructor: mxDoubleEllipse
*
* Constructs a new ellipse shape.
*
* Parameters:
*
* bounds - <mxRectangle> that defines the bounds. This is stored in
* <mxShape.bounds>.
* fill - String that defines the fill color. This is stored in <fill>.
* stroke - String that defines the stroke color. This is stored in <stroke>.
* strokewidth - Optional integer that defines the stroke width. Default is
* 1. This is stored in <strokewidth>.
*/
function mxDoubleEllipse(bounds, fill, stroke, strokewidth)
{
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
};
/**
* Extends mxShape.
*/
mxDoubleEllipse.prototype = new mxShape();
mxDoubleEllipse.prototype.constructor = mxDoubleEllipse;
/**
* Variable: vmlNodes
*
* Adds local references to <mxShape.vmlNodes>.
*/
mxDoubleEllipse.prototype.vmlNodes = mxDoubleEllipse.prototype.vmlNodes.concat(['background', 'foreground']);
/**
* Variable: mixedModeHtml
*
* Overrides the parent value with false, meaning it will
* draw in VML in mixed Html mode.
*/
mxDoubleEllipse.prototype.mixedModeHtml = false;
/**
* Variable: preferModeHtml
*
* Overrides the parent value with false, meaning it will
* draw as VML in prefer Html mode.
*/
mxDoubleEllipse.prototype.preferModeHtml = false;
/**
* Variable: vmlScale
*
* Renders VML with a scale of 2.
*/
mxDoubleEllipse.prototype.vmlScale = 2;
/**
* Function: createVml
*
* Creates and returns the VML node to represent this shape.
*/
mxDoubleEllipse.prototype.createVml = function()
{
var node = document.createElement('v:group');
// Draws the background
this.background = document.createElement('v:arc');
this.background.startangle = '0';
this.background.endangle = '360';
this.configureVmlShape(this.background);
node.appendChild(this.background);
// Ignores values that only apply to the background
this.label = this.background;
this.isShadow = false;
this.fill = null;
// Draws the foreground
this.foreground = document.createElement('v:oval');
this.configureVmlShape(this.foreground);
node.appendChild(this.foreground);
this.stroke = null;
this.configureVmlShape(node);
return node;
};
/**
* Function: redrawVml
*
* Updates the VML node(s) to reflect the latest bounds and scale.
*/
mxDoubleEllipse.prototype.redrawVml = function()
{
this.updateVmlShape(this.node);
this.updateVmlShape(this.background);
this.updateVmlShape(this.foreground);
var inset = Math.round((this.strokewidth + 3) * this.scale) * this.vmlScale;
var w = Math.round(this.bounds.width * this.vmlScale);
var h = Math.round(this.bounds.height * this.vmlScale);
this.foreground.style.top = inset + 'px'; // relative
this.foreground.style.left = inset + 'px'; // relative
this.foreground.style.width = Math.max(0, w - 2 * inset) + 'px';
this.foreground.style.height = Math.max(0, h - 2 * inset) + 'px';
};
/**
* Function: createSvg
*
* Creates and returns the SVG node(s) to represent this shape.
*/
mxDoubleEllipse.prototype.createSvg = function()
{
var g = this.createSvgGroup('ellipse');
this.foreground = document.createElementNS(mxConstants.NS_SVG, 'ellipse');
if (this.stroke != null)
{
this.foreground.setAttribute('stroke', this.stroke);
}
else
{
this.foreground.setAttribute('stroke', 'none');
}
this.foreground.setAttribute('fill', 'none');
g.appendChild(this.foreground);
return g;
};
/**
* Function: redrawSvg
*
* Updates the SVG node(s) to reflect the latest bounds and scale.
*/
mxDoubleEllipse.prototype.redrawSvg = function()
{
if (this.crisp)
{
this.innerNode.setAttribute('shape-rendering', 'crispEdges');
this.foreground.setAttribute('shape-rendering', 'crispEdges');
}
else
{
this.innerNode.removeAttribute('shape-rendering');
this.foreground.removeAttribute('shape-rendering');
}
this.updateSvgNode(this.innerNode);
this.updateSvgNode(this.shadowNode);
this.updateSvgNode(this.foreground, (this.strokewidth + 3) * this.scale);
if (this.isDashed)
{
var phase = Math.max(1, Math.round(3 * this.scale * this.strokewidth));
this.innerNode.setAttribute('stroke-dasharray', phase + ' ' + phase);
}
};
/**
* Function: updateSvgNode
*
* Updates the given node to reflect the new <bounds> and <scale>.
*/
mxDoubleEllipse.prototype.updateSvgNode = function(node, inset)
{
inset = (inset != null) ? inset : 0;
if (node != null)
{
var strokeWidth = Math.round(Math.max(1, this.strokewidth * this.scale));
node.setAttribute('stroke-width', strokeWidth);
node.setAttribute('cx', this.bounds.x + this.bounds.width / 2);
node.setAttribute('cy', this.bounds.y + this.bounds.height / 2);
node.setAttribute('rx', Math.max(0, this.bounds.width / 2 - inset));
node.setAttribute('ry', Math.max(0, this.bounds.height / 2 - inset));
// Updates the transform of the shadow
if (this.shadowNode != null)
{
this.shadowNode.setAttribute('transform', this.getSvgShadowTransform());
}
}
};
|