forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmxICanvas2D.java
More file actions
368 lines (324 loc) · 7.74 KB
/
mxICanvas2D.java
File metadata and controls
368 lines (324 loc) · 7.74 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
package com.mxgraph.canvas;
import com.mxgraph.util.mxConstants;
/**
* Requirements for implementing technologies:
*
* - Path rendering (move, line, quad, curve, arc)
* - Images, flip v/h, aspect, alpha (PNG, JPG, GIF)
* - Linear gradients (in all four directions)
* - Transparency, fill and stroke
* - Rotation, flip v/h
* - Font rendering
* - Dash patterns
* - Clipping by path (not just rectangle)
* - Alpha gradients (for glass effect)
* - Encode result as image (PNG, JPG)
*/
public interface mxICanvas2D
{
/**
* Saves the current state of the canvas.
*/
void save();
/**
* Restores the previous state of the canvas.
*/
void restore();
/**
* Uniformaly scales the canvas by the given amount.
*
* @param value The new scale value.
*/
void scale(double value);
/**
* Translates the canvas by the given amount.
*
* @param dx X-coordinate of the translation.
* @param dy Y-coordinate of the translation.
*/
void translate(double dx, double dy);
/**
* Rotates the canvas by the given angle around the given center. This
* method may add rendering overhead and should be used with care.
*
* @param theta Rotation angle in degrees (0 - 360).
* @param flipH Specifies if drawing should be flipped horizontally.
* @param flipV Specifies if drawing should be flipped vertically.
* @param cx X-coordinate of the center point.
* @param cy Y-coordinate of the center point.
*/
void rotate(double theta, boolean flipH, boolean flipV, double cx, double cy);
/**
* Sets the stroke width. This should default to 1 if unset.
*
* @param value Width of the stroke. The value should be multiplied by the
* current scale.
*/
void setStrokeWidth(double value);
/**
* Sets the stroke color. This should default to {@link mxConstants#NONE}
* if unset.
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setStrokeColor(String value);
/**
* Sets the dashed state. This should default to false if unset.
*
* @param value Boolean representing the dashed state.
*/
void setDashed(boolean value);
/**
* Sets the dashed state. This should default to false if unset.
*
* @param value Boolean representing the dashed state.
*/
void setDashed(boolean value, boolean fixDash);
/**
* Sets the dash pattern. This should default to "3 3" if unset.
*
* @param value Space separated list of floats representing the dash
* pattern. The value should be multiplied by the current scale.
*/
void setDashPattern(String value);
/**
* Sets the linecap. This should default to "flat" if unset.
*
* @param value "flat", "square" or "round".
*/
void setLineCap(String value);
/**
* Sets the linejoin. This should default to "miter" if unset.
*
* @param value "miter", "round" or "bevel".
*/
void setLineJoin(String value);
/**
* Sets the miterlimit. This should default to 10 if unset.
*
* @param value
*/
void setMiterLimit(double value);
/**
* Default value {@link mxConstants#DEFAULT_FONTSIZE}.
*
* @param value
*/
void setFontSize(double value);
/**
* Default value "#000000".
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setFontColor(String value);
/**
* Default value {@link mxConstants#DEFAULT_FONTFAMILY}.
*
* @param value
*/
void setFontFamily(String value);
/**
* Default value 0. See {@link mxConstants#STYLE_FONTSTYLE}.
*
* @param value
*/
void setFontStyle(int value);
/**
* Default value "#000000".
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setFontBackgroundColor(String value);
/**
* Default value "#000000".
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setFontBorderColor(String value);
/**
* Default value 1. This method may add rendering overhead and should be
* used with care.
*
* @param value
*/
void setAlpha(double value);
/**
* Default value 1. This method may add rendering overhead and should be
* used with care.
*
* @param value
*/
void setFillAlpha(double value);
/**
* Default value 1. This method may add rendering overhead and should be
* used with care.
*
* @param value
*/
void setStrokeAlpha(double value);
/**
* Default value {@link mxConstants#NONE}.
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setFillColor(String value);
/**
* Prepares the canvas to draw a gradient.
*
* @param color1
* @param color2
* @param x
* @param y
* @param w
* @param h
* @param direction Direction may be null. Use default value
* {@link mxConstants#DIRECTION_SOUTH}.
*/
void setGradient(String color1, String color2, double x, double y,
double w, double h, String direction, double alpha1, double alpha2);
/**
* Enables or disables the painting of shadows.
*
* @param enabled Whether the shadow should be enabled.
*/
void setShadow(boolean enabled);
/**
* Default value {@link mxConstants#NONE}.
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setShadowColor(String value);
/**
* Default value {@link mxConstants#NONE}.
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setShadowAlpha(double value);
/**
* Default value {@link mxConstants#NONE}.
*
* @param value Hex representation of the color or {@link mxConstants#NONE}.
*/
void setShadowOffset(double dx, double dy);
/**
* Next fill or stroke should draw a rectangle.
*
* @param x
* @param y
* @param w
* @param h
*/
void rect(double x, double y, double w, double h);
/**
*
* Next fill or stroke should draw a round rectangle.
*
* @param x
* @param y
* @param w
* @param h
* @param dx
* @param dy
*/
void roundrect(double x, double y, double w, double h, double dx, double dy);
/**
*
* Next fill or stroke should draw an ellipse.
*
* @param x
* @param y
* @param w
* @param h
*/
void ellipse(double x, double y, double w, double h);
/**
* Draws the given image.
*
* @param x
* @param y
* @param w
* @param h
* @param src
* @param aspect
* @param flipH
* @param flipV
*/
void image(double x, double y, double w, double h, String src,
boolean aspect, boolean flipH, boolean flipV);
/**
* Draws the given string. Possible values for format are empty string for
* plain text and html for HTML markup.
*
* @param x
* @param y
* @param w
* @param h
* @param str
* @param align
* @param valign
* @param wrap
* @param format
* @param overflow
* @param clip
* @param rotation
* @param dir
*/
void text(double x, double y, double w, double h, String str, String align,
String valign, boolean wrap, String format, String overflow,
boolean clip, double rotation, String dir);
/**
* Begins a new path.
*/
void begin();
/**
* Moves to the given path.
*
* @param x
* @param y
*/
void moveTo(double x, double y);
/**
* Draws a line to the given path.
*
* @param x
* @param y
*/
void lineTo(double x, double y);
/**
* Draws a quadratic curve to the given point.
*
* @param x1
* @param y1
* @param x2
* @param y2
*/
void quadTo(double x1, double y1, double x2, double y2);
/**
* Draws a bezier curve to the given point.
*
* @param x1
* @param y1
* @param x2
* @param y2
* @param x3
* @param y3
*/
void curveTo(double x1, double y1, double x2, double y2, double x3,
double y3);
/**
* Closes the current path.
*/
void close();
/**
* Paints the outline of the current path.
*/
void stroke();
/**
* Fills the current path.
*/
void fill();
/**
* Fills and paints the outline of the current path.
*/
void fillAndStroke();
}