Mercurial > projects > dwt2
comparison org.eclipse.draw2d/src/org/eclipse/draw2d/Graphics.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2005 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 | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.draw2d.Graphics; | |
14 | |
15 import java.lang.all; | |
16 | |
17 | |
18 | |
19 import org.eclipse.swt.SWT; | |
20 import org.eclipse.swt.graphics.Color; | |
21 import org.eclipse.swt.graphics.Font; | |
22 import org.eclipse.swt.graphics.FontMetrics; | |
23 import org.eclipse.swt.graphics.GC; | |
24 import org.eclipse.swt.graphics.Image; | |
25 import org.eclipse.swt.graphics.Path; | |
26 import org.eclipse.swt.graphics.Pattern; | |
27 import org.eclipse.swt.graphics.TextLayout; | |
28 import org.eclipse.draw2d.geometry.Point; | |
29 import org.eclipse.draw2d.geometry.PointList; | |
30 import org.eclipse.draw2d.geometry.Rectangle; | |
31 | |
32 /** | |
33 * The Graphics class allows you to draw to a surface. The drawXxx() methods that pertain | |
34 * to shapes draw an outline of the shape, whereas the fillXxx() methods fill in the shape. | |
35 * Also provides for drawing text, lines and images. | |
36 */ | |
37 public abstract class Graphics { | |
38 | |
39 /** | |
40 * @see SWT#LINE_CUSTOM | |
41 */ | |
42 public static final int LINE_CUSTOM = SWT.LINE_CUSTOM; | |
43 | |
44 /** | |
45 * @see SWT#LINE_DASH | |
46 */ | |
47 public static final int LINE_DASH = SWT.LINE_DASH; | |
48 | |
49 /** | |
50 * @see SWT#LINE_DASHDOT | |
51 */ | |
52 public static final int LINE_DASHDOT = SWT.LINE_DASHDOT; | |
53 | |
54 /** | |
55 * @see SWT#LINE_DASHDOTDOT | |
56 */ | |
57 public static final int LINE_DASHDOTDOT = SWT.LINE_DASHDOTDOT; | |
58 | |
59 /** | |
60 * @see SWT#LINE_DOT | |
61 */ | |
62 public static final int LINE_DOT = SWT.LINE_DOT; | |
63 | |
64 /** | |
65 * @see SWT#LINE_SOLID | |
66 */ | |
67 public static final int LINE_SOLID = SWT.LINE_SOLID; | |
68 | |
69 /** | |
70 * Sets the clip region to the given rectangle. Anything outside this rectangle will not | |
71 * be drawn. | |
72 * @param r the clip rectangle | |
73 */ | |
74 public abstract void clipRect(Rectangle r); | |
75 | |
76 /** | |
77 * Disposes this object, releasing any resources. | |
78 */ | |
79 public abstract void dispose(); | |
80 | |
81 /** | |
82 * Draws the outline of an arc located at (x,y) with width <i>w</i> and height <i>h</i>. | |
83 * The starting angle of the arc (specified in degrees) is <i>offset</i> and <i>length</i> | |
84 * is the arc's angle (specified in degrees). | |
85 * | |
86 * @param x the x coordinate | |
87 * @param y the y coordinate | |
88 * @param w the width | |
89 * @param h the height | |
90 * @param offset the start angle | |
91 * @param length the length of the arc | |
92 */ | |
93 public abstract void drawArc(int x, int y, int w, int h, int offset, int length); | |
94 | |
95 /** | |
96 * @see #drawArc(int, int, int, int, int, int) | |
97 */ | |
98 public final void drawArc(Rectangle r, int offset, int length) { | |
99 drawArc(r.x, r.y, r.width, r.height, offset, length); | |
100 } | |
101 | |
102 /** | |
103 * Draws a focus rectangle. | |
104 * | |
105 * @param x the x coordinate | |
106 * @param y the y coordinate | |
107 * @param w the width | |
108 * @param h the height | |
109 */ | |
110 public abstract void drawFocus(int x, int y, int w, int h); | |
111 | |
112 /** | |
113 * @see #drawFocus(int, int, int, int) | |
114 */ | |
115 public final void drawFocus(Rectangle r) { | |
116 drawFocus(r.x, r.y, r.width, r.height); | |
117 } | |
118 | |
119 /** | |
120 * Draws the given Image at the location (x,y). | |
121 * @param srcImage the Image | |
122 * @param x the x coordinate | |
123 * @param y the y coordinate | |
124 */ | |
125 public abstract void drawImage(Image srcImage, int x, int y); | |
126 | |
127 /** | |
128 * Draws a rectangular section of the given Image to the specified rectangular reagion on | |
129 * the canvas. The section of the image bounded by the rectangle (x1,y1,w1,h1) is copied | |
130 * to the section of the canvas bounded by the rectangle (x2,y2,w2,h2). If these two | |
131 * sizes are different, scaling will occur. | |
132 * | |
133 * @param srcImage the image | |
134 * @param x1 the x coordinate of the source | |
135 * @param y1 the y coordinate of the source | |
136 * @param w1 the width of the source | |
137 * @param h1 the height of the source | |
138 * @param x2 the x coordinate of the destination | |
139 * @param y2 the y coordinate of the destination | |
140 * @param w2 the width of the destination | |
141 * @param h2 the height of the destination | |
142 */ | |
143 public abstract void drawImage(Image srcImage, int x1, int y1, int w1, int h1, | |
144 int x2, int y2, int w2, int h2); | |
145 | |
146 /** | |
147 * Draws the given image at a point. | |
148 * @param image the image to draw | |
149 * @param p where to draw the image | |
150 * @see #drawImage(Image, int, int) | |
151 */ | |
152 public final void drawImage(Image image, Point p) { | |
153 drawImage(image, p.x, p.y); | |
154 } | |
155 | |
156 /** | |
157 * @see #drawImage(Image, int, int, int, int, int, int, int, int) | |
158 */ | |
159 public final void drawImage(Image srcImage, Rectangle src, Rectangle dest) { | |
160 drawImage(srcImage, src.x, src.y, src.width, src.height, | |
161 dest.x, dest.y, dest.width, dest.height); | |
162 } | |
163 | |
164 /** | |
165 * Draws a line between the points <code>(x1,y1)</code> and <code>(x2,y2)</code> using the | |
166 * foreground color. | |
167 * @param x1 the x coordinate for the first point | |
168 * @param y1 the y coordinate for the first point | |
169 * @param x2 the x coordinate for the second point | |
170 * @param y2 the y coordinate for the second point | |
171 */ | |
172 public abstract void drawLine(int x1, int y1, int x2, int y2); | |
173 | |
174 /** | |
175 * @see #drawLine(int, int, int, int) | |
176 */ | |
177 public final void drawLine(Point p1, Point p2) { | |
178 drawLine(p1.x, p1.y, p2.x, p2.y); | |
179 } | |
180 | |
181 /** | |
182 * Draws the outline of an ellipse that fits inside the rectangle with the given | |
183 * properties using the foreground color. | |
184 * | |
185 * @param x the x coordinate | |
186 * @param y the y coordinate | |
187 * @param w the width | |
188 * @param h the height | |
189 */ | |
190 public abstract void drawOval(int x, int y, int w, int h); | |
191 | |
192 /** | |
193 * Draws an oval inside the given rectangle using the current foreground color. | |
194 * @param r the rectangle circumscribing the oval to be drawn | |
195 * @see #drawOval(int, int, int, int) | |
196 */ | |
197 public final void drawOval(Rectangle r) { | |
198 drawOval(r.x, r.y, r.width, r.height); | |
199 } | |
200 | |
201 /** | |
202 * Draws the given path. | |
203 * @param path the path to draw | |
204 * @since 3.1 | |
205 */ | |
206 public void drawPath(Path path) { | |
207 subclassFunctionMission(); | |
208 } | |
209 | |
210 /** | |
211 * Draws a pixel, using the foreground color, at the specified point (<code>x</code>, | |
212 * <code>y</code>). | |
213 * <p> | |
214 * Note that the current line attributes do not affect this | |
215 * operation. | |
216 * </p> | |
217 * | |
218 * @param x the point's x coordinate | |
219 * @param y the point's y coordinate | |
220 * | |
221 */ | |
222 public void drawPoint(int x, int y) { | |
223 drawLine(x, y, x, y); | |
224 } | |
225 | |
226 /** | |
227 * Draws a closed polygon defined by the given Integer array containing the vertices in | |
228 * x,y order. The first and last points in the list will be connected. | |
229 * @param points the vertices | |
230 */ | |
231 public void drawPolygon(int[] points) { | |
232 drawPolygon(getPointList(points)); | |
233 } | |
234 | |
235 /** | |
236 * Draws a closed polygon defined by the given <code>PointList</code> containing the | |
237 * vertices. The first and last points in the list will be connected. | |
238 * @param points the vertices | |
239 */ | |
240 public abstract void drawPolygon(PointList points); | |
241 | |
242 /** | |
243 * Draws a polyline defined by the given Integer array containing the vertices in x,y | |
244 * order. The first and last points in the list will <b>not</b> be connected. | |
245 * @param points the vertices | |
246 */ | |
247 public void drawPolyline(int[] points) { | |
248 drawPolyline(getPointList(points)); | |
249 } | |
250 | |
251 /** | |
252 * Draws a polyline defined by the given <code>PointList</code> containing the vertices. | |
253 * The first and last points in the list will <b>not</b> be connected. | |
254 * @param points the vertices | |
255 */ | |
256 public abstract void drawPolyline(PointList points); | |
257 | |
258 /** | |
259 * Draws a rectangle whose top-left corner is located at the point (x,y) with the given | |
260 * width and height. | |
261 * | |
262 * @param x the x coordinate | |
263 * @param y the y coordinate | |
264 * @param width the width | |
265 * @param height the height | |
266 */ | |
267 public abstract void drawRectangle(int x, int y, int width, int height); | |
268 | |
269 /** | |
270 * Draws the given rectangle using the current foreground color. | |
271 * @param r the rectangle to draw | |
272 * @see #drawRectangle(int, int, int, int) | |
273 */ | |
274 public final void drawRectangle(Rectangle r) { | |
275 drawRectangle(r.x, r.y, r.width, r.height); | |
276 } | |
277 | |
278 /** | |
279 * Draws a rectangle with rounded corners using the foreground color. <i>arcWidth</i> and | |
280 * <i>arcHeight</i> represent the horizontal and vertical diameter of the corners. | |
281 * | |
282 * @param r the rectangle | |
283 * @param arcWidth the arc width | |
284 * @param arcHeight the arc height | |
285 */ | |
286 public abstract void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight); | |
287 | |
288 /** | |
289 * Draws the given string using the current font and foreground color. No tab expansion or | |
290 * carriage return processing will be performed. The background of the string will be | |
291 * transparent. | |
292 * | |
293 * @param s the string | |
294 * @param x the x coordinate | |
295 * @param y the y coordinate | |
296 */ | |
297 public abstract void drawString(String s, int x, int y); | |
298 | |
299 /** | |
300 * @see #drawString(String, int, int) | |
301 */ | |
302 public final void drawString(String s, Point p) { | |
303 drawString(s, p.x, p.y); | |
304 } | |
305 | |
306 | |
307 /** | |
308 * Draws the given string using the current font and foreground color. Tab expansion and | |
309 * carriage return processing are performed. The background of the text will be | |
310 * transparent. | |
311 * | |
312 * @param s the text | |
313 * @param x the x coordinate | |
314 * @param y the y coordinate | |
315 */ | |
316 public abstract void drawText(String s, int x, int y); | |
317 | |
318 /** | |
319 * Draws a string using the specified styles. The styles are defined by {@link | |
320 * GC#drawText(String, int, int, int)}. | |
321 * @param s the String to draw | |
322 * @param x the x location | |
323 * @param y the y location | |
324 * @param style the styles used to render the string | |
325 * @since 3.0 | |
326 */ | |
327 public void drawText(String s, int x, int y, int style) { | |
328 subclassFunctionMission(); | |
329 } | |
330 | |
331 /** | |
332 * @see #drawText(String, int, int) | |
333 */ | |
334 public final void drawText(String s, Point p) { | |
335 drawText(s, p.x, p.y); | |
336 } | |
337 | |
338 /** | |
339 * Draws a string using the specified styles. The styles are defined by {@link | |
340 * GC#drawText(String, int, int, int)}. | |
341 * @param s the String to draw | |
342 * @param p the point at which to draw the string | |
343 * @param style the styles used to render the string | |
344 * @since 3.0 | |
345 */ | |
346 public final void drawText(String s, Point p, int style) { | |
347 drawText(s, p.x, p.y, style); | |
348 } | |
349 | |
350 /** | |
351 * Renders the specified TextLayout to this Graphics. | |
352 * @since 3.0 | |
353 * @param layout the TextLayout | |
354 * @param x the x coordinate | |
355 * @param y the y coordinate | |
356 */ | |
357 public final void drawTextLayout(TextLayout layout, int x, int y) { | |
358 drawTextLayout(layout, x, y, -1, -1, null, null); | |
359 } | |
360 | |
361 /** | |
362 * @param x the x location | |
363 * @param y the y location | |
364 * @param layout the TextLayout being rendered | |
365 * @param selectionStart the start of selection | |
366 * @param selectionEnd the end of selection | |
367 * @param selectionForeground the foreground selection color | |
368 * @param selectionBackground the background selection color | |
369 * @see Graphics#drawTextLayout(TextLayout, int, int) | |
370 */ | |
371 public void drawTextLayout(TextLayout layout, int x, int y, int selectionStart, | |
372 int selectionEnd, Color selectionForeground, Color selectionBackground) { | |
373 subclassFunctionMission(); | |
374 } | |
375 | |
376 /** | |
377 * Fills the interior of an arc located at (<i>x</i>,<i>y</i>) with width <i>w</i> and | |
378 * height <i>h</i>. The starting angle of the arc (specified in degrees) is <i>offset</i> | |
379 * and <i>length</i> is the arc's angle (specified in degrees). | |
380 * | |
381 * @param x the x coordinate | |
382 * @param y the y coordinate | |
383 * @param w the width | |
384 * @param h the height | |
385 * @param offset the start angle | |
386 * @param length the length of the arc | |
387 */ | |
388 public abstract void fillArc(int x, int y, int w, int h, int offset, int length); | |
389 | |
390 /** | |
391 * @see #fillArc(int, int, int, int, int, int) | |
392 */ | |
393 public final void fillArc(Rectangle r, int offset, int length) { | |
394 fillArc(r.x, r.y, r.width, r.height, offset, length); | |
395 } | |
396 | |
397 /** | |
398 * Fills the the given rectangle with a gradient from the foreground color to the | |
399 * background color. If <i>vertical</i> is <code>true</code>, the gradient will go from | |
400 * top to bottom. Otherwise, it will go from left to right. | |
401 * background color. | |
402 * | |
403 * @param x the x coordinate | |
404 * @param y the y coordinate | |
405 * @param w the width | |
406 * @param h the height | |
407 * @param vertical whether the gradient should be vertical | |
408 */ | |
409 public abstract void fillGradient(int x, int y, int w, int h, bool vertical); | |
410 | |
411 /** | |
412 * @see #fillGradient(int, int, int, int, bool) | |
413 */ | |
414 public final void fillGradient(Rectangle r, bool vertical) { | |
415 fillGradient(r.x, r.y, r.width, r.height, vertical); | |
416 } | |
417 | |
418 /** | |
419 * Fills an ellipse that fits inside the rectangle with the given properties using the | |
420 * background color. | |
421 * | |
422 * @param x the x coordinate | |
423 * @param y the y coordinate | |
424 * @param w the width | |
425 * @param h the height | |
426 */ | |
427 public abstract void fillOval(int x, int y, int w, int h); | |
428 | |
429 /** | |
430 * @see #fillOval(int, int, int, int) | |
431 */ | |
432 public final void fillOval(Rectangle r) { | |
433 fillOval(r.x, r.y, r.width, r.height); | |
434 } | |
435 | |
436 /** | |
437 * Fills the given path. | |
438 * @param path the path to fill | |
439 * @since 3.1 | |
440 */ | |
441 public void fillPath(Path path) { | |
442 subclassFunctionMission(); | |
443 } | |
444 | |
445 /** | |
446 * Fills a closed polygon defined by the given Integer array containing the | |
447 * vertices in x,y order. The first and last points in the list will be connected. | |
448 * @param points the vertices | |
449 */ | |
450 public void fillPolygon(int[] points) { | |
451 fillPolygon(getPointList(points)); | |
452 } | |
453 | |
454 /** | |
455 * Fills a closed polygon defined by the given <code>PointList</code> containing the | |
456 * vertices. The first and last points in the list will be connected. | |
457 * @param points the vertices | |
458 */ | |
459 public abstract void fillPolygon(PointList points); | |
460 | |
461 /** | |
462 * Fills a rectangle whose top-left corner is located at the point (x,y) with the given | |
463 * width and height. | |
464 * | |
465 * @param x the x coordinate | |
466 * @param y the y coordinate | |
467 * @param width the width | |
468 * @param height the height | |
469 */ | |
470 public abstract void fillRectangle(int x, int y, int width, int height); | |
471 | |
472 /** | |
473 * Fills the given rectangle using the current background color. | |
474 * @param r the rectangle to fill | |
475 * @see #fillRectangle(int, int, int, int) | |
476 */ | |
477 public final void fillRectangle(Rectangle r) { | |
478 fillRectangle(r.x, r.y, r.width, r.height); | |
479 } | |
480 | |
481 /** | |
482 * Fills a rectangle with rounded corners using the background color. <i>arcWidth</i> and | |
483 * <i>arcHeight</i> represent the horizontal and vertical diameter of the corners. | |
484 * | |
485 * @param r the rectangle | |
486 * @param arcWidth the arc width | |
487 * @param arcHeight the arc height | |
488 */ | |
489 public abstract void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight); | |
490 | |
491 /** | |
492 * Draws the given string using the current font and foreground color. No tab expansion or | |
493 * carriage return processing will be performed. The background of the string will be | |
494 * filled with the current background color. | |
495 * | |
496 * @param s the string | |
497 * @param x the x coordinate | |
498 * @param y the y coordinate | |
499 */ | |
500 public abstract void fillString(String s, int x, int y); | |
501 | |
502 /** | |
503 * @see #fillString(String, int, int) | |
504 */ | |
505 public final void fillString(String s, Point p) { | |
506 fillString(s, p.x, p.y); | |
507 } | |
508 | |
509 /** | |
510 * Draws the given string using the current font and foreground color. Tab expansion and | |
511 * carriage return processing are performed. The background of the text will be filled | |
512 * with the current background color. | |
513 * | |
514 * @param s the text | |
515 * @param x the x coordinate | |
516 * @param y the y coordinate | |
517 */ | |
518 public abstract void fillText(String s, int x, int y); | |
519 | |
520 /** | |
521 * @see #fillText(String, int, int) | |
522 */ | |
523 public final void fillText(String s, Point p) { | |
524 fillText(s, p.x, p.y); | |
525 } | |
526 | |
527 /** | |
528 * Returns the current absolute scaling which will be applied to the underlying Device | |
529 * when painting to this Graphics. The default value is 1.0. | |
530 * @since 3.0 | |
531 * @return the effective absolute scaling factor | |
532 */ | |
533 public double getAbsoluteScale() { | |
534 return 1.0; | |
535 } | |
536 | |
537 /** | |
538 * Returns the current alpha value of the graphics. | |
539 * @return the alpha value | |
540 * @since 3.1 | |
541 */ | |
542 public int getAlpha() { | |
543 subclassFunctionMission(); | |
544 return 255; | |
545 } | |
546 | |
547 /** | |
548 * Returns the anti-aliasing setting value, which will be one of <code>SWT.DEFAULT</code>, | |
549 * <code>SWT.OFF</code> or <code>SWT.ON</code>. Note that this controls anti-aliasing for | |
550 * all <em>non-text</em> drawing operations. | |
551 * @see #getTextAntialias() | |
552 * @return the anti-alias setting | |
553 * @since 3.1 | |
554 */ | |
555 public int getAntialias() { | |
556 subclassFunctionMission(); | |
557 return SWT.DEFAULT; | |
558 } | |
559 | |
560 /** | |
561 * Returns the background color used for filling. | |
562 * @return the background color | |
563 */ | |
564 public abstract Color getBackgroundColor(); | |
565 | |
566 /** | |
567 * Modifies the given rectangle to match the clip region and returns that rectangle. | |
568 * @param rect the rectangle to hold the clip region | |
569 * @return the clip rectangle | |
570 */ | |
571 public abstract Rectangle getClip(Rectangle rect); | |
572 | |
573 /** | |
574 * Returns the fill rule, which will be one of <code>SWT.FILL_EVEN_ODD</code> or | |
575 * <code>SWT.FILL_WINDING</code>. | |
576 * @return the fill rule | |
577 * @since 3.1 | |
578 */ | |
579 public int getFillRule() { | |
580 subclassFunctionMission(); | |
581 return 0; | |
582 } | |
583 | |
584 /** | |
585 * Returns the font used to draw and fill text. | |
586 * @return the font | |
587 */ | |
588 public abstract Font getFont(); | |
589 | |
590 /** | |
591 * Returns the font metrics for the current font. | |
592 * @return the font metrics | |
593 */ | |
594 public abstract FontMetrics getFontMetrics(); | |
595 | |
596 /** | |
597 * Returns the foreground color used to draw lines and text. | |
598 * @return the foreground color | |
599 */ | |
600 public abstract Color getForegroundColor(); | |
601 | |
602 /** | |
603 * Returns the interpolation setting, which will be one of <code>SWT.DEFAULT</code>, | |
604 * <code>SWT.NONE</code>, <code>SWT.LOW</code> or <code>SWT.HIGH</code>. | |
605 * @return the interpolation setting | |
606 * @since 3.1 | |
607 */ | |
608 public int getInterpolation() { | |
609 subclassFunctionMission(); | |
610 return 0; | |
611 } | |
612 | |
613 /** | |
614 * Returns the current line cap style, which will be one of the constants | |
615 * <code>SWT.CAP_FLAT</code>, <code>SWT.CAP_ROUND</code>, or <code>SWT.CAP_SQUARE</code>. | |
616 * | |
617 * @return the cap style used for drawing lines | |
618 * @since 3.1 | |
619 */ | |
620 public int getLineCap() { | |
621 subclassFunctionMission(); | |
622 return SWT.CAP_FLAT; | |
623 } | |
624 | |
625 | |
626 /** | |
627 * Returns the line join style, which will be one of the constants | |
628 * <code>SWT.JOIN_MITER</code>, <code>SWT.JOIN_ROUND</code>, or | |
629 * <code>SWT.JOIN_BEVEL</code>. | |
630 * | |
631 * @since 3.1 | |
632 * @return the join style used for drawing lines | |
633 */ | |
634 public int getLineJoin() { | |
635 subclassFunctionMission(); | |
636 return SWT.JOIN_MITER; | |
637 } | |
638 | |
639 /** | |
640 * Returns the line style. | |
641 * @return the line style | |
642 */ | |
643 public abstract int getLineStyle(); | |
644 /** | |
645 * Returns the current line width. | |
646 * @return the line width | |
647 */ | |
648 public abstract int getLineWidth(); | |
649 | |
650 /** | |
651 * Returns a pointlist containing all the points from the integer array. | |
652 * @param points an integer array of x,y points | |
653 * @return the corresponding pointlist | |
654 */ | |
655 private PointList getPointList(int[] points) { | |
656 PointList pointList = new PointList(points.length / 2); | |
657 for (int i = 0; (i + 1) < points.length; i += 2) | |
658 pointList.addPoint(points[i], points[i + 1]); | |
659 return pointList; | |
660 } | |
661 | |
662 /** | |
663 * Returns the textual anti-aliasing setting value, which will be one of | |
664 * <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or <code>SWT.ON</code>. Note that this | |
665 * controls anti-aliasing <em>only</em> for text drawing operations. | |
666 * | |
667 * @see #getAntialias() | |
668 * @return the anti-aliasing setting | |
669 * @since 3.1 | |
670 */ | |
671 public int getTextAntialias() { | |
672 subclassFunctionMission(); | |
673 return SWT.DEFAULT; | |
674 } | |
675 | |
676 /** | |
677 * Returns <code>true</code> if this graphics object should use XOR mode with painting. | |
678 * @return whether XOR mode is turned on | |
679 */ | |
680 public abstract bool getXORMode(); | |
681 | |
682 /** | |
683 * Pops the previous state of this graphics object off the stack (if {@link #pushState()} | |
684 * has previously been called) and restores the current state to that popped state. | |
685 */ | |
686 public abstract void popState(); | |
687 | |
688 /** | |
689 * Pushes the current state of this graphics object onto a stack. | |
690 */ | |
691 public abstract void pushState(); | |
692 | |
693 /** | |
694 * Restores the previous state of this graphics object. | |
695 */ | |
696 public abstract void restoreState(); | |
697 | |
698 /** | |
699 * Rotates the coordinates by the given counter-clockwise angle. All subsequent painting | |
700 * will be performed in the resulting coordinates. Some functions are illegal when a | |
701 * rotated coordinates system is in use. To restore access to those functions, it is | |
702 * necessary to call restore or pop to return to a non rotated state. | |
703 * @param degrees the degrees to rotate | |
704 * @since 3.1 | |
705 */ | |
706 public void rotate(float degrees) { | |
707 subclassFunctionMission(); | |
708 } | |
709 | |
710 /** | |
711 * Scales this graphics object by the given amount. | |
712 * @param amount the scale factor | |
713 */ | |
714 public abstract void scale(double amount); | |
715 | |
716 /** | |
717 * Scales the graphics by the given horizontal and vertical components. | |
718 * @param horizontal the horizontal scaling factor | |
719 * @param vertical the vertical scaling factor | |
720 * @since 3.1 | |
721 */ | |
722 public void scale(float horizontal, float vertical) { | |
723 subclassFunctionMission(); | |
724 } | |
725 | |
726 /** | |
727 * Sets the alpha to the given value. Values may range from 0 to 255. A value | |
728 * of 0 is completely transparent. | |
729 * | |
730 * @param alpha an alpha value (0-255) | |
731 * @since 3.1 | |
732 */ | |
733 public void setAlpha(int alpha) { | |
734 subclassFunctionMission(); | |
735 } | |
736 | |
737 /** | |
738 * Sets the anti-aliasing value to the parameter, which must be one of | |
739 * <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or <code>SWT.ON</code>. Note that this | |
740 * controls anti-aliasing for all <em>non-text drawing</em> operations. | |
741 * | |
742 * @param value the anti-alias value | |
743 */ | |
744 public void setAntialias(int value) { | |
745 subclassFunctionMission(); | |
746 } | |
747 | |
748 /** | |
749 * Sets the background color. | |
750 * @param rgb the new background color | |
751 */ | |
752 public abstract void setBackgroundColor(Color rgb); | |
753 | |
754 /** | |
755 * Sets the pattern used for fill-type graphics operations. The pattern must not be | |
756 * disposed while it is being used by the graphics. | |
757 * @param pattern the background pattern | |
758 * @since 3.1 | |
759 */ | |
760 public void setBackgroundPattern(Pattern pattern) { | |
761 subclassFunctionMission(); | |
762 } | |
763 | |
764 /** | |
765 * Sets the area which can be affected by drawing operations to the specified | |
766 * <code>Path</code>. | |
767 | |
768 * @param path the clipping path | |
769 * @since 3.1 | |
770 */ | |
771 public void setClip(Path path) { | |
772 subclassFunctionMission(); | |
773 } | |
774 | |
775 /** | |
776 * Sets the clip rectangle. Painting will <b>not</b> occur outside this area. | |
777 * @param r the new clip rectangle | |
778 */ | |
779 public abstract void setClip(Rectangle r); | |
780 | |
781 /** | |
782 * Sets the fill rule to the given value, which must be one of | |
783 * <code>SWT.FILL_EVEN_ODD</code> or <code>SWT.FILL_WINDING</code>. | |
784 * @param rule the fill rule | |
785 * @since 3.1 | |
786 */ | |
787 public void setFillRule(int rule) { | |
788 subclassFunctionMission(); | |
789 } | |
790 | |
791 /** | |
792 * Sets the font. | |
793 * @param f the new font | |
794 */ | |
795 public abstract void setFont(Font f); | |
796 | |
797 /** | |
798 * Sets the foreground color. | |
799 * @param rgb the new foreground color | |
800 */ | |
801 public abstract void setForegroundColor(Color rgb); | |
802 | |
803 /** | |
804 * Sets the foreground pattern for draw and text operations. The pattern must not be | |
805 * disposed while it is being referenced by the graphics. | |
806 * @param pattern the foreground pattern | |
807 * @since 3.1 | |
808 */ | |
809 public void setForegroundPattern(Pattern pattern) { | |
810 subclassFunctionMission(); | |
811 } | |
812 | |
813 /** | |
814 * Sets the interpolation setting to the given value, which must be one of | |
815 * <code>SWT.DEFAULT</code>, <code>SWT.NONE</code>, <code>SWT.LOW</code> or | |
816 * <code>SWT.HIGH</code>. This setting is relevant when working with Images. | |
817 * @param interpolation the interpolation | |
818 * @since 3.1 | |
819 */ | |
820 public void setInterpolation(int interpolation) { | |
821 subclassFunctionMission(); | |
822 } | |
823 | |
824 /** | |
825 * Sets the line cap style to the argument, which must be one of the constants | |
826 * <code>SWT.CAP_FLAT</code>, <code>SWT.CAP_ROUND</code>, or <code>SWT.CAP_SQUARE</code>. | |
827 * @param cap the line cap | |
828 * @since 3.1 | |
829 */ | |
830 public void setLineCap(int cap) { | |
831 subclassFunctionMission(); | |
832 } | |
833 | |
834 /** | |
835 * Sets the dash pattern when the custom line style is in use. Because this | |
836 * feature is rarely used, the dash pattern may not be preserved when calling | |
837 * {@link #pushState()} and {@link #popState()}. | |
838 * @param dash the pixel pattern | |
839 * @since 3.1 | |
840 */ | |
841 public void setLineDash(int dash[]) { | |
842 subclassFunctionMission(); | |
843 } | |
844 | |
845 /** | |
846 * Sets the line join style to the argument, which must be one of the constants | |
847 * <code>SWT.JOIN_MITER</code>, <code>SWT.JOIN_ROUND</code>, or | |
848 * <code>SWT.JOIN_BEVEL</code>. | |
849 * @param join the join type | |
850 * @since 3.1 | |
851 */ | |
852 public void setLineJoin(int join) { | |
853 subclassFunctionMission(); | |
854 } | |
855 | |
856 /** | |
857 * Sets the line style to the argument, which must be one of the constants | |
858 * <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>, <code>SWT.LINE_DOT</code>, | |
859 * <code>SWT.LINE_DASHDOT</code> or <code>SWT.LINE_DASHDOTDOT</code>. | |
860 * @param style the new style | |
861 */ | |
862 public abstract void setLineStyle(int style); | |
863 | |
864 /** | |
865 * Sets the line width. | |
866 * | |
867 * @param width the new width | |
868 */ | |
869 public abstract void setLineWidth(int width); | |
870 | |
871 /** | |
872 * Sets the textual anti-aliasing value to the parameter, which must be one of | |
873 * <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or <code>SWT.ON</code>. Note that this | |
874 * controls anti-aliasing only for all <em>text drawing</em> operations. | |
875 * | |
876 * @param value the textual anti-alias setting | |
877 * @since 3.1 | |
878 */ | |
879 public void setTextAntialias(int value) { | |
880 subclassFunctionMission(); | |
881 } | |
882 | |
883 /** | |
884 * Modifies the current transformation by shearing the graphics in the specified | |
885 * horizontal and vertical amounts. Shearing can be used to produce effects like Italic | |
886 * fonts. | |
887 * @param horz the horizontal shearing amount | |
888 * @param vert the vertical shearming amount | |
889 * @since 3.1 | |
890 */ | |
891 public void shear(float horz, float vert) { | |
892 subclassFunctionMission(); | |
893 } | |
894 | |
895 /** | |
896 * Sets the XOR mode. | |
897 * @param b the new XOR mode | |
898 */ | |
899 public abstract void setXORMode(bool b); | |
900 | |
901 private void subclassFunctionMission() { | |
902 throw new RuntimeException( "The class: " ~ this.classinfo.name //$NON-NLS-1$ | |
903 ~ " has not implemented this new graphics function"); //$NON-NLS-1$ | |
904 } | |
905 | |
906 /** | |
907 * Translates the receiver's coordinates by the specified x and y amounts. All | |
908 * subsequent painting will be performed in the resulting coordinate system. Integer | |
909 * translation used by itself does not require or start the use of the advanced | |
910 * graphics system in SWT. It is emulated until advanced graphics are triggered. | |
911 * @param dx the horizontal offset | |
912 * @param dy the vertical offset | |
913 */ | |
914 public abstract void translate(int dx, int dy); | |
915 | |
916 | |
917 /** | |
918 * Modifies the current transform by translating the given x and y amounts. All | |
919 * subsequent painting will be performed in the resulting coordinate system. | |
920 * @param dx the horizontal offset | |
921 * @param dy the vertical offset | |
922 */ | |
923 public void translate(float dx, float dy) { | |
924 subclassFunctionMission(); | |
925 } | |
926 | |
927 /** | |
928 * @see #translate(int, int) | |
929 */ | |
930 public final void translate(Point pt) { | |
931 translate(pt.x, pt.y); | |
932 } | |
933 | |
934 } |