summaryrefslogtreecommitdiffstats
path: root/awt/java/awt/Graphics.java
blob: 2d6e79fca4607dba40818f0ae2d9adafd6aa09db (plain)
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @author Alexey A. Petrenko
 * @version $Revision$
 */

package java.awt;

import java.awt.image.ImageObserver;
import java.text.AttributedCharacterIterator;

/**
 * The abstract Graphics class allows applications to draw on a screen or other
 * rendering target. There are several properties which define rendering
 * options: origin point, clipping area, color, font. <br>
 * <br>
 * The origin point specifies the beginning of the clipping area coordinate
 * system. All coordinates used in rendering operations are computed with
 * respect to this point. The clipping area defines the boundaries where
 * rendering operations can be performed. Rendering operations can't modify
 * pixels outside of the clipping area. <br>
 * <br>
 * The draw and fill methods allow applications to drawing shapes, text, images
 * with specified font and color options in the specified part of the screen.
 * 
 * @since Android 1.0
 */
public abstract class Graphics {

    // Constructors

    /**
     * Instantiates a new Graphics. This constructor is default for Graphics and
     * can not be called directly.
     */
    protected Graphics() {
    }

    // Public methods

    /**
     * Creates a copy of the Graphics object with a new origin and a new
     * specified clip area. The new clip area is the rectangle defined by the
     * origin point with coordinates X,Y and the given width and height. The
     * coordinates of all subsequent rendering operations will be computed with
     * respect to the new origin and can be performed only within the range of
     * the clipping area dimensions.
     * 
     * @param x
     *            the X coordinate of the original point.
     * @param y
     *            the Y coordinate of the original point.
     * @param width
     *            the width of clipping area.
     * @param height
     *            the height of clipping area.
     * @return the Graphics object with new origin point and clipping area.
     */
    public Graphics create(int x, int y, int width, int height) {
        Graphics res = create();
        res.translate(x, y);
        res.clipRect(0, 0, width, height);
        return res;
    }

    /**
     * Draws the highlighted outline of a rectangle.
     * 
     * @param x
     *            the X coordinate of the rectangle's top left corner.
     * @param y
     *            the Y coordinate of the rectangle's top left corner.
     * @param width
     *            the width of rectangle.
     * @param height
     *            the height of rectangle.
     * @param raised
     *            a boolean value that determines whether the rectangle is drawn
     *            as raised or indented.
     */
    public void draw3DRect(int x, int y, int width, int height, boolean raised) {
        // Note: lighter/darker colors should be used to draw 3d rect.
        // The resulting rect is (width+1)x(height+1). Stroke and paint
        // attributes of
        // the Graphics2D should be reset to the default values.
        // fillRect is used instead of drawLine to bypass stroke
        // reset/set and rasterization.

        Color color = getColor();
        Color colorUp, colorDown;
        if (raised) {
            colorUp = color.brighter();
            colorDown = color.darker();
        } else {
            colorUp = color.darker();
            colorDown = color.brighter();
        }

        setColor(colorUp);
        fillRect(x, y, width, 1);
        fillRect(x, y + 1, 1, height);

        setColor(colorDown);
        fillRect(x + width, y, 1, height);
        fillRect(x + 1, y + height, width, 1);
    }

    /**
     * Draws the text represented by byte array. This method uses the current
     * font and color for rendering.
     * 
     * @param bytes
     *            the byte array which contains the text to be drawn.
     * @param off
     *            the offset within the byte array of the text to be drawn.
     * @param len
     *            the number of bytes of text to draw.
     * @param x
     *            the X coordinate where the text is to be drawn.
     * @param y
     *            the Y coordinate where the text is to be drawn.
     */
    public void drawBytes(byte[] bytes, int off, int len, int x, int y) {
        drawString(new String(bytes, off, len), x, y);
    }

    /**
     * Draws the text represented by character array. This method uses the
     * current font and color for rendering.
     * 
     * @param chars
     *            the character array.
     * @param off
     *            the offset within the character array of the text to be drawn.
     * @param len
     *            the number of characters which will be drawn.
     * @param x
     *            the X coordinate where the text is to be drawn.
     * @param y
     *            the Y coordinate where the text is to be drawn.
     */
    public void drawChars(char[] chars, int off, int len, int x, int y) {
        drawString(new String(chars, off, len), x, y);
    }

    /**
     * Draws the outline of a polygon which is defined by Polygon object.
     * 
     * @param p
     *            the Polygon object.
     */
    public void drawPolygon(Polygon p) {
        drawPolygon(p.xpoints, p.ypoints, p.npoints);
    }

    /**
     * Draws the rectangle with the specified width and length and top left
     * corner coordinates.
     * 
     * @param x
     *            the X coordinate of the rectangle's top left corner.
     * @param y
     *            the Y coordinate of the rectangle's top left corner.
     * @param width
     *            the width of the rectangle.
     * @param height
     *            the height of the rectangle.
     */
    public void drawRect(int x, int y, int width, int height) {
        int[] xpoints = {
                x, x, x + width, x + width
        };
        int[] ypoints = {
                y, y + height, y + height, y
        };

        drawPolygon(xpoints, ypoints, 4);
    }

    /**
     * Fills the highlighted outline of a rectangle.
     * 
     * @param x
     *            the X coordinate of the rectangle's top left corner.
     * @param y
     *            the Y coordinate of the rectangle's top left corner.
     * @param width
     *            the width of the rectangle.
     * @param height
     *            the height of the rectangle.
     * @param raised
     *            a boolean value that determines whether the rectangle is drawn
     *            as raised or indented.
     */
    public void fill3DRect(int x, int y, int width, int height, boolean raised) {
        // Note: lighter/darker colors should be used to draw 3d rect.
        // The resulting rect is (width)x(height), same as fillRect.
        // Stroke and paint attributes of the Graphics2D should be reset
        // to the default values. fillRect is used instead of drawLine to
        // bypass stroke reset/set and line rasterization.

        Color color = getColor();
        Color colorUp, colorDown;
        if (raised) {
            colorUp = color.brighter();
            colorDown = color.darker();
            setColor(color);
        } else {
            colorUp = color.darker();
            colorDown = color.brighter();
            setColor(colorUp);
        }

        width--;
        height--;
        fillRect(x + 1, y + 1, width - 1, height - 1);

        setColor(colorUp);
        fillRect(x, y, width, 1);
        fillRect(x, y + 1, 1, height);

        setColor(colorDown);
        fillRect(x + width, y, 1, height);
        fillRect(x + 1, y + height, width, 1);
    }

    /**
     * Fills the polygon with the current color.
     * 
     * @param p
     *            the Polygon object.
     */
    public void fillPolygon(Polygon p) {
        fillPolygon(p.xpoints, p.ypoints, p.npoints);
    }

    /**
     * Disposes of the Graphics.
     */
    @Override
    public void finalize() {
    }

    /**
     * Gets the bounds of the current clipping area as a rectangle and copies it
     * to an existing rectangle.
     * 
     * @param r
     *            a Rectangle object where the current clipping area bounds are
     *            to be copied.
     * @return the bounds of the current clipping area.
     */
    public Rectangle getClipBounds(Rectangle r) {
        Shape clip = getClip();

        if (clip != null) {
            // TODO: Can we get shape bounds without creating Rectangle object?
            Rectangle b = clip.getBounds();
            r.x = b.x;
            r.y = b.y;
            r.width = b.width;
            r.height = b.height;
        }

        return r;
    }

    /**
     * Gets the bounds of the current clipping area as a rectangle.
     * 
     * @return a Rectangle object.
     * @deprecated Use {@link #getClipBounds()}
     */
    @Deprecated
    public Rectangle getClipRect() {
        return getClipBounds();
    }

    /**
     * Gets the font metrics of the current font. The font metrics object
     * contains information about the rendering of a particular font.
     * 
     * @return the font metrics of current font.
     */
    public FontMetrics getFontMetrics() {
        return getFontMetrics(getFont());
    }

    /**
     * Determines whether or not the specified rectangle intersects the current
     * clipping area.
     * 
     * @param x
     *            the X coordinate of the rectangle.
     * @param y
     *            the Y coordinate of the rectangle.
     * @param width
     *            the width of the rectangle.
     * @param height
     *            the height of the rectangle.
     * @return true, if the specified rectangle intersects the current clipping
     *         area, false otherwise.
     */
    public boolean hitClip(int x, int y, int width, int height) {
        // TODO: Create package private method Rectangle.intersects(int, int,
        // int, int);
        return getClipBounds().intersects(new Rectangle(x, y, width, height));
    }

    /**
     * Returns string which represents this Graphics object.
     * 
     * @return the string which represents this Graphics object.
     */
    @Override
    public String toString() {
        // TODO: Think about string representation of Graphics.
        return "Graphics"; //$NON-NLS-1$
    }

    // Abstract methods

    /**
     * Clears the specified rectangle. This method fills specified rectangle
     * with background color.
     * 
     * @param x
     *            the X coordinate of the rectangle.
     * @param y
     *            the Y coordinate of the rectangle.
     * @param width
     *            the width of the rectangle.
     * @param height
     *            the height of the rectangle.
     */
    public abstract void clearRect(int x, int y, int width, int height);

    /**
     * Intersects the current clipping area with a new rectangle. If the current
     * clipping area is not defined, the rectangle becomes a new clipping area.
     * Rendering operations are only allowed within the new the clipping area.
     * 
     * @param x
     *            the X coordinate of the rectangle for intersection.
     * @param y
     *            the Y coordinate of the rectangle for intersection.
     * @param width
     *            the width of the rectangle for intersection.
     * @param height
     *            the height of the rectangle for intersection.
     */
    public abstract void clipRect(int x, int y, int width, int height);

    /**
     * Copies the rectangle area to another area specified by a distance (dx,
     * dy) from the original rectangle's location. Positive dx and dy values
     * give a new location defined by translation to the right and down from the
     * original location, negative dx and dy values - to the left and up.
     * 
     * @param sx
     *            the X coordinate of the rectangle which will be copied.
     * @param sy
     *            the Y coordinate of the rectangle which will be copied.
     * @param width
     *            the width of the rectangle which will be copied.
     * @param height
     *            the height of the rectangle which will be copied.
     * @param dx
     *            the horizontal distance from the source rectangle's location
     *            to the copy's location.
     * @param dy
     *            the vertical distance from the source rectangle's location to
     *            the copy's location.
     */
    public abstract void copyArea(int sx, int sy, int width, int height, int dx, int dy);

    /**
     * Creates a new copy of this Graphics.
     * 
     * @return a new Graphics context which is a copy of this Graphics.
     */
    public abstract Graphics create();

    /**
     * Disposes of the Graphics. This Graphics object can not be used after
     * calling this method.
     */
    public abstract void dispose();

    /**
     * Draws the arc covering the specified rectangle and using the current
     * color. The rectangle is defined by the origin point (X, Y) and dimensions
     * (width and height). The arc center is the the center of specified
     * rectangle. The angle origin is 3 o'clock position, the positive angle is
     * counted as a counter-clockwise rotation, the negative angle is counted as
     * clockwise rotation.
     * 
     * @param x
     *            the X origin coordinate of the rectangle which scales the arc.
     * @param y
     *            the Y origin coordinate of the rectangle which scales the arc.
     * @param width
     *            the width of the rectangle which scales the arc.
     * @param height
     *            the height of the rectangle which scales the arc.
     * @param sa
     *            start angle - the origin angle of arc.
     * @param ea
     *            arc angle - the angular arc value relative to the start angle.
     */
    public abstract void drawArc(int x, int y, int width, int height, int sa, int ea);

    /**
     * Draws the specified image with the defined background color. The top left
     * corner of image will be drawn at point (x, y) in current coordinate
     * system. The image loading process notifies the specified Image Observer.
     * This method returns true if the image has loaded, otherwise it returns
     * false.
     * 
     * @param img
     *            the image which will be drawn.
     * @param x
     *            the X coordinate of the image top left corner.
     * @param y
     *            the Y coordinate of the image top left corner.
     * @param bgcolor
     *            the background color.
     * @param observer
     *            the ImageObserver object which should be notified about image
     *            loading process.
     * @return true, if loading image is successful or image is null, false
     *         otherwise.
     */
    public abstract boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer);

    /**
     * Draws the specified image. The top left corner of image will be drawn at
     * point (x, y) in current coordinate system. The image loading process
     * notifies the specified Image Observer. This method returns true if the
     * image has loaded, otherwise it returns false.
     * 
     * @param img
     *            the image which will be drawn.
     * @param x
     *            the X coordinate of the image top left corner.
     * @param y
     *            the Y coordinate of the image top left corner.
     * @param observer
     *            the ImageObserver object which should be notified about image
     *            loading process.
     * @return true, if loading image is successful or image is null, otherwise
     *         false.
     */
    public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer);

    /**
     * Scales the specified image to fit in the specified rectangle and draws it
     * with the defined background color. The top left corner of the image will
     * be drawn at the point (x, y) in current coordinate system. The non-opaque
     * pixels will be drawn in the background color. The image loading process
     * notifies the specified Image Observer. This method returns true if the
     * image has loaded, otherwise it returns false.
     * 
     * @param img
     *            the image which will be drawn.
     * @param x
     *            the X coordinate of the image's top left corner.
     * @param y
     *            the Y coordinate of the image's top left corner.
     * @param width
     *            the width of rectangle which scales the image.
     * @param height
     *            the height of rectangle which scales the image.
     * @param bgcolor
     *            the background color.
     * @param observer
     *            the ImageObserver object which should be notified about image
     *            loading process.
     * @return true, if loading image is successful or image is null, otherwise
     *         false.
     */
    public abstract boolean drawImage(Image img, int x, int y, int width, int height,
            Color bgcolor, ImageObserver observer);

    /**
     * Scales the specified image to fit in the specified rectangle and draws
     * it. The top left corner of the image will be drawn at the point (x, y) in
     * current coordinate system. The image loading process notifies the
     * specified Image Observer. This method returns true if the image has
     * loaded, otherwise it returns false.
     * 
     * @param img
     *            the image which will be drawn.
     * @param x
     *            the X coordinate of the image top left corner.
     * @param y
     *            the Y coordinate of the image top left corner.
     * @param width
     *            the width of rectangle which scales the image.
     * @param height
     *            the height of rectangle which scales the image.
     * @param observer
     *            the ImageObserver object which should be notified about image
     *            loading process.
     * @return true, if loading image is successful or image is null, otherwise
     *         false.
     */
    public abstract boolean drawImage(Image img, int x, int y, int width, int height,
            ImageObserver observer);

    /**
     * Scales the specified area of the specified image to fit in the rectangle
     * area defined by its corners coordinates and draws the sub-image with the
     * specified background color. The sub-image to be drawn is defined by its
     * top left corner coordinates (sx1, sy1) and bottom right corner
     * coordinates (sx2, sy2) computed with respect to the origin (top left
     * corner) of the source image. The non opaque pixels will be drawn in the
     * background color. The image loading process notifies specified Image
     * Observer. This method returns true if the image has loaded, otherwise it
     * returns false.
     * 
     * @param img
     *            the image which will be drawn.
     * @param dx1
     *            the X top left corner coordinate of the destination rectangle
     *            area.
     * @param dy1
     *            the Y top left corner coordinate of the destination rectangle
     *            area.
     * @param dx2
     *            the X bottom right corner coordinate of the destination
     *            rectangle area.
     * @param dy2
     *            the Y bottom right corner coordinate of the destination
     *            rectangle area.
     * @param sx1
     *            the X top left corner coordinate of the area to be drawn
     *            within the source image.
     * @param sy1
     *            the Y top left corner coordinate of the area to be drawn
     *            within the source image.
     * @param sx2
     *            the X bottom right corner coordinate of the area to be drawn
     *            within the source image.
     * @param sy2
     *            the Y bottom right corner coordinate of the area to be drawn
     *            within the source image.
     * @param bgcolor
     *            the background color.
     * @param observer
     *            the ImageObserver object which should be notified about image
     *            loading process.
     * @return true, if loading image is successful or image is null, false
     *         otherwise.
     */
    public abstract boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1,
            int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer);

    /**
     * Scales the specified area of the specified image to fit in the rectangle
     * area defined by its corners coordinates and draws the sub-image. The
     * sub-image to be drawn is defined by its top left corner coordinates (sx1,
     * sy1) and bottom right corner coordinates (sx2, sy2) computed with respect
     * to the origin (top left corner) of the source image. The image loading
     * process notifies specified Image Observer. This method returns true if
     * the image has loaded, otherwise it returns false.
     * 
     * @param img
     *            the image which will be drawn.
     * @param dx1
     *            the X top left corner coordinate of the destination rectangle
     *            area.
     * @param dy1
     *            the Y top left corner coordinate of the destination rectangle
     *            area.
     * @param dx2
     *            the X bottom right corner coordinate of the destination
     *            rectangle area.
     * @param dy2
     *            the Y bottom right corner coordinate of the destination
     *            rectangle area.
     * @param sx1
     *            the X top left corner coordinate of the area to be drawn
     *            within the source image.
     * @param sy1
     *            the Y top left corner coordinate of the area to be drawn
     *            within the source image.
     * @param sx2
     *            the X bottom right corner coordinate of the area to be drawn
     *            within the source image.
     * @param sy2
     *            the Y bottom right corner coordinate of the area to be drawn
     *            within the source image.
     * @param observer
     *            the ImageObserver object which should be notified about image
     *            loading process.
     * @return true, if loading image is successful or image is null, false
     *         otherwise.
     */
    public abstract boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1,
            int sy1, int sx2, int sy2, ImageObserver observer);

    /**
     * Draws a line from the point (x1, y1) to the point (x2, y2). This method
     * draws the line with current color which can be changed by setColor(Color
     * c) method.
     * 
     * @param x1
     *            the X coordinate of the first point.
     * @param y1
     *            the Y coordinate of the first point.
     * @param x2
     *            the X coordinate of the second point.
     * @param y2
     *            the Y coordinate of the second point.
     */
    public abstract void drawLine(int x1, int y1, int x2, int y2);

    /**
     * Draws the outline of an oval to fit in the rectangle defined by the given
     * width, height, and top left corner.
     * 
     * @param x
     *            the X top left corner oval coordinate.
     * @param y
     *            the Y top left corner oval coordinate.
     * @param width
     *            the oval width.
     * @param height
     *            the oval height.
     */
    public abstract void drawOval(int x, int y, int width, int height);

    /**
     * Draws the outline of a polygon. The polygon vertices are defined by
     * points with xpoints[i], ypoints[i] as coordinates. The polygon edges are
     * the lines from the points with (xpoints[i-1], ypoints[i-1]) coordinates
     * to the points with (xpoints[i], ypoints[i]) coordinates, for 0 < i <
     * npoints +1.
     * 
     * @param xpoints
     *            the array of X coordinates of the polygon vertices.
     * @param ypoints
     *            the array of Y coordinates of the polygon vertices.
     * @param npoints
     *            the number of polygon vertices/points.
     */
    public abstract void drawPolygon(int[] xpoints, int[] ypoints, int npoints);

    /**
     * Draws a set of connected lines which are defined by the x and y
     * coordinate arrays. The polyline is closed if coordinates of the first
     * point are the same as coordinates of the last point.
     * 
     * @param xpoints
     *            the array of X point coordinates.
     * @param ypoints
     *            the array of Y point coordinates.
     * @param npoints
     *            the number of points.
     */
    public abstract void drawPolyline(int[] xpoints, int[] ypoints, int npoints);

    /**
     * Draws the outline of a rectangle with round corners.
     * 
     * @param x
     *            the X coordinate of the rectangle's top left corner.
     * @param y
     *            the Y coordinate of the rectangle's top left corner.
     * @param width
     *            the width of the rectangle.
     * @param height
     *            the height of the rectangle.
     * @param arcWidth
     *            the arc width for the corners.
     * @param arcHeight
     *            the arc height for the corners.
     */
    public abstract void drawRoundRect(int x, int y, int width, int height, int arcWidth,
            int arcHeight);

    /**
     * Draws a text defined by an iterator. The iterator should specify the font
     * for every character.
     * 
     * @param iterator
     *            the iterator.
     * @param x
     *            the X coordinate of the first character.
     * @param y
     *            the Y coordinate of the first character.
     */
    public abstract void drawString(AttributedCharacterIterator iterator, int x, int y);

    /**
     * Draws a text defined by a string. This method draws the text with current
     * font and color.
     * 
     * @param str
     *            the string.
     * @param x
     *            the X coordinate of the first character.
     * @param y
     *            the Y coordinate of the first character.
     */
    public abstract void drawString(String str, int x, int y);

    /**
     * Fills the arc covering the rectangle and using the current color. The
     * rectangle is defined by the origin point (X, Y) and dimensions (width and
     * height). The arc center is the the center of specified rectangle. The
     * angle origin is at the 3 o'clock position, and a positive angle gives
     * counter-clockwise rotation, a negative angle gives clockwise rotation.
     * 
     * @param x
     *            the X origin coordinate of the rectangle which scales the arc.
     * @param y
     *            the Y origin coordinate of the rectangle which scales the arc.
     * @param width
     *            the width of the rectangle which scales the arc.
     * @param height
     *            the height of the rectangle which scales the arc.
     * @param sa
     *            start angle - the origin angle of arc.
     * @param ea
     *            arc angle - the angular arc value relative to the start angle.
     */
    public abstract void fillArc(int x, int y, int width, int height, int sa, int ea);

    /**
     * Fills an oval with the current color where the oval is defined by the
     * bounding rectangle with the given width, height, and top left corner.
     * 
     * @param x
     *            the X top left corner oval coordinate.
     * @param y
     *            the Y top left corner oval coordinate.
     * @param width
     *            the oval width.
     * @param height
     *            the oval height.
     */
    public abstract void fillOval(int x, int y, int width, int height);

    /**
     * Fills a polygon with the current color. The polygon vertices are defined
     * by the points with xpoints[i], ypoints[i] as coordinates. The polygon
     * edges are the lines from the points with (xpoints[i-1], ypoints[i-1])
     * coordinates to the points with (xpoints[i], ypoints[i]) coordinates, for
     * 0 < i < npoints +1.
     * 
     * @param xpoints
     *            the array of X coordinates of the polygon vertices.
     * @param ypoints
     *            the array of Y coordinates of the polygon vertices.
     * @param npoints
     *            the number of polygon vertices/points.
     */
    public abstract void fillPolygon(int[] xpoints, int[] ypoints, int npoints);

    /**
     * Fills a rectangle with the current color. The rectangle is defined by its
     * width and length and top left corner coordinates.
     * 
     * @param x
     *            the X coordinate of the rectangle's top left corner.
     * @param y
     *            the Y coordinate of the rectangle's top left corner.
     * @param width
     *            the width of rectangle.
     * @param height
     *            the height of rectangle.
     */
    public abstract void fillRect(int x, int y, int width, int height);

    /**
     * Fills a round cornered rectangle with the current color.
     * 
     * @param x
     *            the X coordinate of the top left corner of the bounding
     *            rectangle.
     * @param y
     *            the Y coordinate of the top left corner of the bounding
     *            rectangle.
     * @param width
     *            the width of the bounding rectangle.
     * @param height
     *            the height of the bounding rectangle.
     * @param arcWidth
     *            the arc width at the corners.
     * @param arcHeight
     *            the arc height at the corners.
     */
    public abstract void fillRoundRect(int x, int y, int width, int height, int arcWidth,
            int arcHeight);

    /**
     * Gets the clipping area. <br>
     * <br>
     * 
     * @return a Shape object of the clipping area or null if it is not set.
     */
    public abstract Shape getClip();

    /**
     * Gets the bounds of the current clipping area as a rectangle.
     * 
     * @return a Rectangle object which represents the bounds of the current
     *         clipping area.
     */
    public abstract Rectangle getClipBounds();

    /**
     * Gets the current color of Graphics.
     * 
     * @return the current color.
     */
    public abstract Color getColor();

    /**
     * Gets the current font of Graphics.
     * 
     * @return the current font.
     */
    public abstract Font getFont();

    /**
     * Gets the font metrics of the specified font. The font metrics object
     * contains information about the rendering of a particular font.
     * 
     * @param font
     *            the specified font.
     * @return the font metrics for the specified font.
     */
    public abstract FontMetrics getFontMetrics(Font font);

    /**
     * Sets the new clipping area specified by rectangle. The new clipping area
     * doesn't depend on the window's visibility. Rendering operations can't be
     * performed outside new clipping area.
     * 
     * @param x
     *            the X coordinate of the new clipping rectangle.
     * @param y
     *            the Y coordinate of the new clipping rectangle.
     * @param width
     *            the width of the new clipping rectangle.
     * @param height
     *            the height of the new clipping rectangle.
     */
    public abstract void setClip(int x, int y, int width, int height);

    /**
     * Sets the new clipping area to be the area specified by Shape object. The
     * new clipping area doesn't depend on the window's visibility. Rendering
     * operations can't be performed outside new clipping area.
     * 
     * @param clip
     *            the Shape object which represents new clipping area.
     */
    public abstract void setClip(Shape clip);

    /**
     * Sets the current Graphics color. All rendering operations with this
     * Graphics will use this color.
     * 
     * @param c
     *            the new color.
     */
    public abstract void setColor(Color c);

    /**
     * Sets the current Graphics font. All rendering operations with this
     * Graphics will use this font.
     * 
     * @param font
     *            the new font.
     */
    public abstract void setFont(Font font);

    /**
     * Sets the paint mode for the Graphics which overwrites all rendering
     * operations with the current color.
     */
    public abstract void setPaintMode();

    /**
     * Sets the XOR mode for the Graphics which changes a pixel from the current
     * color to the specified XOR color. <br>
     * <br>
     * 
     * @param color
     *            the new XOR mode.
     */
    public abstract void setXORMode(Color color);

    /**
     * Translates the origin of Graphics current coordinate system to the point
     * with X, Y coordinates in the current coordinate system. All rendering
     * operation in this Graphics will be related to the new origin.
     * 
     * @param x
     *            the X coordinate of the origin.
     * @param y
     *            the Y coordinate of the origin.
     */
    public abstract void translate(int x, int y);
}