Mercurial > projects > dwt-win
annotate dwt/graphics/Path.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 0405e18fec7f |
children | 36f5cb12e1a2 |
rev | line source |
---|---|
25 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
26 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
25 | 12 *******************************************************************************/ |
13 module dwt.graphics.Path; | |
14 | |
15 import dwt.internal.gdip.Gdip; | |
16 | |
17 import dwt.DWT; | |
18 import dwt.DWTError; | |
19 import dwt.DWTException; | |
20 import dwt.internal.gdip.Gdip; | |
21 import dwt.internal.win32.OS; | |
22 | |
26 | 23 import dwt.graphics.Resource; |
24 import dwt.graphics.Device; | |
25 import dwt.graphics.Font; | |
26 import dwt.graphics.GC; | |
27 import dwt.graphics.GCData; | |
28 import dwt.graphics.PathData; | |
29 | |
30 import dwt.dwthelper.System; | |
31 import tango.text.convert.Format; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
53
diff
changeset
|
32 import dwt.dwthelper.utils; |
26 | 33 |
25 | 34 /** |
35 * Instances of this class represent paths through the two-dimensional | |
36 * coordinate system. Paths do not have to be continuous, and can be | |
37 * described using lines, rectangles, arcs, cubic or quadratic bezier curves, | |
38 * glyphs, or other paths. | |
39 * <p> | |
40 * Application code must explicitly invoke the <code>Path.dispose()</code> | |
41 * method to release the operating system resources managed by each instance | |
42 * when those instances are no longer required. | |
43 * </p> | |
44 * <p> | |
45 * This class requires the operating system's advanced graphics subsystem | |
46 * which may not be available on some platforms. | |
47 * </p> | |
48 * | |
49 * @since 3.1 | |
50 */ | |
26 | 51 public class Path : Resource { |
25 | 52 |
53 /** | |
54 * the OS resource for the Path | |
55 * (Warning: This field is platform dependent) | |
56 * <p> | |
57 * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT | |
58 * public API. It is marked public only so that it can be shared | |
59 * within the packages provided by DWT. It is not available on all | |
60 * platforms and should never be accessed from application code. | |
61 * </p> | |
62 */ | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
63 public Gdip.Path handle; |
25 | 64 |
26 | 65 Gdip.PointF currentPoint, startPoint; |
25 | 66 |
67 /** | |
68 * Constructs a new empty Path. | |
69 * <p> | |
70 * This operation requires the operating system's advanced | |
71 * graphics subsystem which may not be available on some | |
72 * platforms. | |
73 * </p> | |
74 * | |
75 * @param device the device on which to allocate the path | |
76 * | |
77 * @exception IllegalArgumentException <ul> | |
78 * <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li> | |
79 * </ul> | |
80 * @exception DWTException <ul> | |
81 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> | |
82 * </ul> | |
83 * @exception DWTError <ul> | |
84 * <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li> | |
85 * </ul> | |
86 * | |
87 * @see #dispose() | |
88 */ | |
26 | 89 public this (Device device) { |
25 | 90 if (device is null) device = Device.getDevice(); |
91 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
92 this.device = device; | |
93 device.checkGDIP(); | |
94 handle = Gdip.GraphicsPath_new(Gdip.FillModeAlternate); | |
26 | 95 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); |
25 | 96 if (device.tracking) device.new_Object(this); |
97 } | |
98 | |
99 /** | |
100 * Adds to the receiver a circular or elliptical arc that lies within | |
101 * the specified rectangular area. | |
102 * <p> | |
103 * The resulting arc begins at <code>startAngle</code> and extends | |
104 * for <code>arcAngle</code> degrees. | |
105 * Angles are interpreted such that 0 degrees is at the 3 o'clock | |
106 * position. A positive value indicates a counter-clockwise rotation | |
107 * while a negative value indicates a clockwise rotation. | |
108 * </p><p> | |
109 * The center of the arc is the center of the rectangle whose origin | |
110 * is (<code>x</code>, <code>y</code>) and whose size is specified by the | |
111 * <code>width</code> and <code>height</code> arguments. | |
112 * </p><p> | |
113 * The resulting arc covers an area <code>width + 1</code> pixels wide | |
114 * by <code>height + 1</code> pixels tall. | |
115 * </p> | |
116 * | |
117 * @param x the x coordinate of the upper-left corner of the arc | |
118 * @param y the y coordinate of the upper-left corner of the arc | |
119 * @param width the width of the arc | |
120 * @param height the height of the arc | |
121 * @param startAngle the beginning angle | |
122 * @param arcAngle the angular extent of the arc, relative to the start angle | |
123 * | |
124 * @exception DWTException <ul> | |
125 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
126 * </ul> | |
127 */ | |
128 public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) { | |
129 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
130 if (width < 0) { | |
131 x = x + width; | |
132 width = -width; | |
133 } | |
134 if (height < 0) { | |
135 y = y + height; | |
136 height = -height; | |
137 } | |
138 if (width is 0 || height is 0 || arcAngle is 0) return; | |
139 if (width is height) { | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
140 Gdip.GraphicsPath_AddArcF(handle, x, y, width, height, -startAngle, -arcAngle); |
25 | 141 } else { |
26 | 142 auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate); |
143 if (path is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
144 auto matrix = Gdip.Matrix_new(width, 0, 0, height, x, y); | |
145 if (matrix is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
25 | 146 Gdip.GraphicsPath_AddArc(path, 0, 0, 1, 1, -startAngle, -arcAngle); |
147 Gdip.GraphicsPath_Transform(path, matrix); | |
148 Gdip.GraphicsPath_AddPath(handle, path, true); | |
149 Gdip.Matrix_delete(matrix); | |
150 Gdip.GraphicsPath_delete(path); | |
151 } | |
152 Gdip.GraphicsPath_GetLastPoint(handle, currentPoint); | |
153 } | |
154 | |
155 /** | |
156 * Adds to the receiver the path described by the parameter. | |
157 * | |
158 * @param path the path to add to the receiver | |
159 * | |
160 * @exception IllegalArgumentException <ul> | |
161 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> | |
162 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> | |
163 * </ul> | |
164 * @exception DWTException <ul> | |
165 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
166 * </ul> | |
167 */ | |
168 public void addPath(Path path) { | |
169 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
170 if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
171 if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
172 //TODO - expose connect? | |
173 Gdip.GraphicsPath_AddPath(handle, path.handle, false); | |
174 currentPoint.X = path.currentPoint.X; | |
175 currentPoint.Y = path.currentPoint.Y; | |
176 } | |
177 | |
178 /** | |
179 * Adds to the receiver the rectangle specified by x, y, width and height. | |
180 * | |
181 * @param x the x coordinate of the rectangle to add | |
182 * @param y the y coordinate of the rectangle to add | |
183 * @param width the width of the rectangle to add | |
184 * @param height the height of the rectangle to add | |
185 * | |
186 * @exception DWTException <ul> | |
187 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
188 * </ul> | |
189 */ | |
190 public void addRectangle(float x, float y, float width, float height) { | |
191 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
26 | 192 Gdip.RectF rect; |
25 | 193 rect.X = x; |
194 rect.Y = y; | |
195 rect.Width = width; | |
196 rect.Height = height; | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
197 Gdip.GraphicsPath_AddRectangle(handle, rect); |
25 | 198 currentPoint.X = x; |
199 currentPoint.Y = y; | |
200 } | |
201 | |
202 /** | |
203 * Adds to the receiver the pattern of glyphs generated by drawing | |
204 * the given string using the given font starting at the point (x, y). | |
205 * | |
206 * @param string the text to use | |
207 * @param x the x coordinate of the starting point | |
208 * @param y the y coordinate of the starting point | |
209 * @param font the font to use | |
210 * | |
211 * @exception IllegalArgumentException <ul> | |
212 * <li>ERROR_NULL_ARGUMENT - if the font is null</li> | |
213 * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li> | |
214 * </ul> | |
215 * @exception DWTException <ul> | |
216 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
217 * </ul> | |
218 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
53
diff
changeset
|
219 public void addString(String string, float x, float y, Font font) { |
25 | 220 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
221 if (font is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
222 if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
26 | 223 wchar[] wstr = StrToWCHARs( string ); |
224 wchar* buffer = wstr.ptr; | |
225 int length = wstr.length; | |
226 auto hDC = device.internal_new_GC(null); | |
227 auto gdipFont = GC.createGdipFont(hDC, font.handle); | |
228 Gdip.PointF point; | |
25 | 229 point.X = x - (Gdip.Font_GetSize(gdipFont) / 6); |
230 point.Y = y; | |
26 | 231 auto family = Gdip.FontFamily_new(); |
25 | 232 Gdip.Font_GetFamily(gdipFont, family); |
233 int style = Gdip.Font_GetStyle(gdipFont); | |
234 float size = Gdip.Font_GetSize(gdipFont); | |
26 | 235 Gdip.GraphicsPath_AddString(handle, buffer, length, family, style, size, point, null); |
25 | 236 Gdip.GraphicsPath_GetLastPoint(handle, currentPoint); |
237 Gdip.FontFamily_delete(family); | |
238 Gdip.Font_delete(gdipFont); | |
239 device.internal_dispose_GC(hDC, null); | |
240 } | |
241 | |
242 /** | |
243 * Closes the current sub path by adding to the receiver a line | |
244 * from the current point of the path back to the starting point | |
245 * of the sub path. | |
246 * | |
247 * @exception DWTException <ul> | |
248 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
249 * </ul> | |
250 */ | |
251 public void close() { | |
252 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
253 Gdip.GraphicsPath_CloseFigure(handle); | |
254 /* | |
255 * Feature in GDI+. CloseFigure() does affect the last | |
256 * point, so GetLastPoint() does not return the starting | |
257 * point of the subpath after calling CloseFigure(). The | |
258 * fix is to remember the subpath starting point and use | |
259 * it instead. | |
260 */ | |
261 currentPoint.X = startPoint.X; | |
262 currentPoint.Y = startPoint.Y; | |
263 } | |
264 | |
265 /** | |
266 * Returns <code>true</code> if the specified point is contained by | |
267 * the receiver and false otherwise. | |
268 * <p> | |
269 * If outline is <code>true</code>, the point (x, y) checked for containment in | |
270 * the receiver's outline. If outline is <code>false</code>, the point is | |
271 * checked to see if it is contained within the bounds of the (closed) area | |
272 * covered by the receiver. | |
273 * | |
274 * @param x the x coordinate of the point to test for containment | |
275 * @param y the y coordinate of the point to test for containment | |
276 * @param gc the GC to use when testing for containment | |
277 * @param outline controls whether to check the outline or contained area of the path | |
278 * @return <code>true</code> if the path contains the point and <code>false</code> otherwise | |
279 * | |
280 * @exception IllegalArgumentException <ul> | |
281 * <li>ERROR_NULL_ARGUMENT - if the gc is null</li> | |
282 * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li> | |
283 * </ul> | |
284 * @exception DWTException <ul> | |
285 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
286 * </ul> | |
287 */ | |
288 public bool contains(float x, float y, GC gc, bool outline) { | |
289 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
290 if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
291 if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
292 //TODO - should use GC transformation | |
293 gc.initGdip(); | |
294 gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH); | |
295 int mode = OS.GetPolyFillMode(gc.handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; | |
296 Gdip.GraphicsPath_SetFillMode(handle, mode); | |
297 if (outline) { | |
298 return Gdip.GraphicsPath_IsOutlineVisible(handle, x, y, gc.data.gdipPen, gc.data.gdipGraphics); | |
299 } else { | |
300 return Gdip.GraphicsPath_IsVisible(handle, x, y, gc.data.gdipGraphics); | |
301 } | |
302 } | |
303 | |
304 /** | |
305 * Adds to the receiver a cubic bezier curve based on the parameters. | |
306 * | |
307 * @param cx1 the x coordinate of the first control point of the spline | |
308 * @param cy1 the y coordinate of the first control of the spline | |
309 * @param cx2 the x coordinate of the second control of the spline | |
310 * @param cy2 the y coordinate of the second control of the spline | |
311 * @param x the x coordinate of the end point of the spline | |
312 * @param y the y coordinate of the end point of the spline | |
313 * | |
314 * @exception DWTException <ul> | |
315 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
316 * </ul> | |
317 */ | |
318 public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) { | |
319 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
320 Gdip.GraphicsPath_AddBezier(handle, currentPoint.X, currentPoint.Y, cx1, cy1, cx2, cy2, x, y); | |
321 Gdip.GraphicsPath_GetLastPoint(handle, currentPoint); | |
322 } | |
323 | |
324 /** | |
325 * Disposes of the operating system resources associated with | |
326 * the Path. Applications must dispose of all Paths that | |
327 * they allocate. | |
328 */ | |
48
9a64a7781bab
Added override and alias, first chunk. Thanks torhu for doing this patch.
Frank Benoit <benoit@tionex.de>
parents:
26
diff
changeset
|
329 override public void dispose() { |
26 | 330 if (handle is null) return; |
25 | 331 if (device.isDisposed()) return; |
332 Gdip.GraphicsPath_delete(handle); | |
26 | 333 handle = null; |
25 | 334 if (device.tracking) device.dispose_Object(this); |
335 device = null; | |
336 } | |
337 | |
338 /** | |
339 * Replaces the first four elements in the parameter with values that | |
340 * describe the smallest rectangle that will completely contain the | |
341 * receiver (i.e. the bounding box). | |
342 * | |
343 * @param bounds the array to hold the result | |
344 * | |
345 * @exception IllegalArgumentException <ul> | |
346 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> | |
347 * <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the bounding box</li> | |
348 * </ul> | |
349 * @exception DWTException <ul> | |
350 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
351 * </ul> | |
352 */ | |
353 public void getBounds(float[] bounds) { | |
354 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
355 if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
356 if (bounds.length < 4) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
26 | 357 Gdip.RectF rect; |
358 Gdip.GraphicsPath_GetBounds(handle, rect, null, null); | |
25 | 359 bounds[0] = rect.X; |
360 bounds[1] = rect.Y; | |
361 bounds[2] = rect.Width; | |
362 bounds[3] = rect.Height; | |
363 } | |
364 | |
365 /** | |
366 * Replaces the first two elements in the parameter with values that | |
367 * describe the current point of the path. | |
368 * | |
369 * @param point the array to hold the result | |
370 * | |
371 * @exception IllegalArgumentException <ul> | |
372 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> | |
373 * <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the end point</li> | |
374 * </ul> | |
375 * @exception DWTException <ul> | |
376 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
377 * </ul> | |
378 */ | |
379 public void getCurrentPoint(float[] point) { | |
380 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
381 if (point is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
382 if (point.length < 2) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
383 point[0] = currentPoint.X; | |
384 point[1] = currentPoint.Y; | |
385 } | |
386 | |
387 /** | |
388 * Returns a device independent representation of the receiver. | |
389 * | |
390 * @return the PathData for the receiver | |
391 * | |
392 * @exception DWTException <ul> | |
393 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
394 * </ul> | |
395 * | |
396 * @see PathData | |
397 */ | |
398 public PathData getPathData() { | |
399 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
400 int count = Gdip.GraphicsPath_GetPointCount(handle); | |
401 byte[] gdipTypes = new byte[count]; | |
402 float[] points = new float[count * 2]; | |
403 Gdip.GraphicsPath_GetPathTypes(handle, gdipTypes, count); | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
404 Gdip.GraphicsPath_GetPathPoints(handle, cast(Gdip.PointF[])points, count); |
25 | 405 byte[] types = new byte[count * 2]; |
406 int index = 0, typesIndex = 0; | |
407 while (index < count) { | |
408 byte type = gdipTypes[index]; | |
409 bool close = false; | |
410 switch (type & Gdip.PathPointTypePathTypeMask) { | |
411 case Gdip.PathPointTypeStart: | |
412 types[typesIndex++] = DWT.PATH_MOVE_TO; | |
413 close = (type & Gdip.PathPointTypeCloseSubpath) !is 0; | |
414 index += 1; | |
415 break; | |
416 case Gdip.PathPointTypeLine: | |
417 types[typesIndex++] = DWT.PATH_LINE_TO; | |
418 close = (type & Gdip.PathPointTypeCloseSubpath) !is 0; | |
419 index += 1; | |
420 break; | |
421 case Gdip.PathPointTypeBezier: | |
422 types[typesIndex++] = DWT.PATH_CUBIC_TO; | |
423 close = (gdipTypes[index + 2] & Gdip.PathPointTypeCloseSubpath) !is 0; | |
424 index += 3; | |
425 break; | |
426 default: | |
427 index++; | |
428 } | |
429 if (close) { | |
430 types[typesIndex++] = DWT.PATH_CLOSE; | |
431 } | |
432 } | |
433 if (typesIndex !is types.length) { | |
434 byte[] newTypes = new byte[typesIndex]; | |
435 System.arraycopy(types, 0, newTypes, 0, typesIndex); | |
436 types = newTypes; | |
437 } | |
438 PathData result = new PathData(); | |
439 result.types = types; | |
440 result.points = points; | |
441 return result; | |
442 } | |
443 | |
444 /** | |
445 * Adds to the receiver a line from the current point to | |
446 * the point specified by (x, y). | |
447 * | |
448 * @param x the x coordinate of the end of the line to add | |
449 * @param y the y coordinate of the end of the line to add | |
450 * | |
451 * @exception DWTException <ul> | |
452 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
453 * </ul> | |
454 */ | |
455 public void lineTo(float x, float y) { | |
456 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
457 Gdip.GraphicsPath_AddLine(handle, currentPoint.X, currentPoint.Y, x, y); | |
458 Gdip.GraphicsPath_GetLastPoint(handle, currentPoint); | |
459 } | |
460 | |
461 /** | |
462 * Returns <code>true</code> if the Path has been disposed, | |
463 * and <code>false</code> otherwise. | |
464 * <p> | |
465 * This method gets the dispose state for the Path. | |
466 * When a Path has been disposed, it is an error to | |
467 * invoke any other method using the Path. | |
468 * | |
469 * @return <code>true</code> when the Path is disposed, and <code>false</code> otherwise | |
470 */ | |
48
9a64a7781bab
Added override and alias, first chunk. Thanks torhu for doing this patch.
Frank Benoit <benoit@tionex.de>
parents:
26
diff
changeset
|
471 override public bool isDisposed() { |
26 | 472 return handle is null; |
25 | 473 } |
474 | |
475 /** | |
476 * Sets the current point of the receiver to the point | |
477 * specified by (x, y). Note that this starts a new | |
478 * sub path. | |
479 * | |
480 * @param x the x coordinate of the new end point | |
481 * @param y the y coordinate of the new end point | |
482 * | |
483 * @exception DWTException <ul> | |
484 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
485 * </ul> | |
486 */ | |
487 public void moveTo(float x, float y) { | |
488 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
489 Gdip.GraphicsPath_StartFigure(handle); | |
490 currentPoint.X = startPoint.X = x; | |
491 currentPoint.Y = startPoint.Y = y; | |
492 } | |
493 | |
494 /** | |
495 * Adds to the receiver a quadratic curve based on the parameters. | |
496 * | |
497 * @param cx the x coordinate of the control point of the spline | |
498 * @param cy the y coordinate of the control point of the spline | |
499 * @param x the x coordinate of the end point of the spline | |
500 * @param y the y coordinate of the end point of the spline | |
501 * | |
502 * @exception DWTException <ul> | |
503 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
504 * </ul> | |
505 */ | |
506 public void quadTo(float cx, float cy, float x, float y) { | |
507 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
508 float cx1 = currentPoint.X + 2 * (cx - currentPoint.X) / 3; | |
509 float cy1 = currentPoint.Y + 2 * (cy - currentPoint.Y) / 3; | |
510 float cx2 = cx1 + (x - currentPoint.X) / 3; | |
511 float cy2 = cy1 + (y - currentPoint.Y) / 3; | |
512 Gdip.GraphicsPath_AddBezier(handle, currentPoint.X, currentPoint.Y, cx1, cy1, cx2, cy2, x, y); | |
513 Gdip.GraphicsPath_GetLastPoint(handle, currentPoint); | |
514 } | |
515 | |
516 /** | |
517 * Returns a string containing a concise, human-readable | |
518 * description of the receiver. | |
519 * | |
520 * @return a string representation of the receiver | |
521 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
53
diff
changeset
|
522 override public String toString() { |
25 | 523 if (isDisposed()) return "Path {*DISPOSED*}"; |
26 | 524 return Format( "Path {{{}}", handle ); |
25 | 525 } |
526 | |
527 } |