jdk/src/share/classes/sun/print/ProxyGraphics2D.java
author dav
Mon, 07 Apr 2008 14:53:51 +0400
changeset 438 2ae294e4518c
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6613529: Avoid duplicate object creation within JDK packages Summary: avoid using constructors when unique values are not necessary Reviewed-by: volk, igor, peterz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.print;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Composite;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Graphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.FontMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.font.FontRenderContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.Image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.Paint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.awt.Shape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.awt.Stroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.awt.RenderingHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.RenderingHints.Key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.awt.font.GlyphVector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.awt.geom.Rectangle2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.awt.geom.NoninvertibleTransformException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.awt.image.BufferedImageOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.awt.image.RenderedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.awt.image.renderable.RenderContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.awt.image.renderable.RenderableImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.awt.print.PrinterGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import java.awt.print.PrinterJob;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import java.text.AttributedCharacterIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public class ProxyGraphics2D extends Graphics2D implements PrinterGraphics {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Drawing methods will be forwarded to this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    Graphics2D mGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * The PrinterJob controlling the current printing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    PrinterJob mPrinterJob;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * The new ProxyGraphics2D will forward all graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * calls to 'graphics'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public ProxyGraphics2D(Graphics2D graphics, PrinterJob printerJob) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        mGraphics = graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        mPrinterJob = printerJob;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Return the Graphics2D object that does the drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * for this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public Graphics2D getDelegate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        return mGraphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Set the Graphics2D instance which will do the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public void setDelegate(Graphics2D graphics) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        mGraphics = graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public PrinterJob getPrinterJob() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return mPrinterJob;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Returns the device configuration associated with this Graphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public GraphicsConfiguration getDeviceConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return ((RasterPrinterJob)mPrinterJob).getPrinterGraphicsConfig();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
/* The Delegated Graphics Methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Creates a new <code>Graphics</code> object that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * a copy of this <code>Graphics</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return     a new graphics context that is a copy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *                       this graphics context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @since      JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public Graphics create() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return new ProxyGraphics2D((Graphics2D) mGraphics.create(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                                   mPrinterJob);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Translates the origin of the graphics context to the point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * (<i>x</i>,&nbsp;<i>y</i>) in the current coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Modifies this graphics context so that its new origin corresponds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * to the point (<i>x</i>,&nbsp;<i>y</i>) in this graphics context's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * original coordinate system.  All coordinates used in subsequent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * rendering operations on this graphics context will be relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * to this new origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param  x   the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param  y   the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public void translate(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        mGraphics.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Concatenates the current transform of this Graphics2D with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * translation transformation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * This is equivalent to calling transform(T), where T is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * AffineTransform represented by the following matrix:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *          [   1    0    tx  ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *          [   0    1    ty  ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *          [   0    0    1   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public void translate(double tx, double ty) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        mGraphics.translate(tx, ty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Concatenates the current transform of this Graphics2D with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * rotation transformation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * This is equivalent to calling transform(R), where R is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * AffineTransform represented by the following matrix:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *          [   cos(theta)    -sin(theta)    0   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *          [   sin(theta)     cos(theta)    0   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *          [       0              0         1   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Rotating with a positive angle theta rotates points on the positive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * x axis toward the positive y axis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param theta The angle of rotation in radians.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public void rotate(double theta) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        mGraphics.rotate(theta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Concatenates the current transform of this Graphics2D with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * translated rotation transformation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * This is equivalent to the following sequence of calls:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *          translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *          rotate(theta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *          translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Rotating with a positive angle theta rotates points on the positive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * x axis toward the positive y axis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @param theta The angle of rotation in radians.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param x The x coordinate of the origin of the rotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param y The x coordinate of the origin of the rotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public void rotate(double theta, double x, double y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        mGraphics.rotate(theta, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Concatenates the current transform of this Graphics2D with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * scaling transformation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * This is equivalent to calling transform(S), where S is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * AffineTransform represented by the following matrix:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *          [   sx   0    0   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *          [   0    sy   0   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *          [   0    0    1   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public void scale(double sx, double sy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        mGraphics.scale(sx, sy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Concatenates the current transform of this Graphics2D with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * shearing transformation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * This is equivalent to calling transform(SH), where SH is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * AffineTransform represented by the following matrix:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *          [   1   shx   0   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *          [  shy   1    0   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *          [   0    0    1   ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param shx The factor by which coordinates are shifted towards the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * positive X axis direction according to their Y coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @param shy The factor by which coordinates are shifted towards the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * positive Y axis direction according to their X coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public void shear(double shx, double shy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        mGraphics.shear(shx, shy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * Gets this graphics context's current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @return    this graphics context's current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @see       java.awt.Color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @see       java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @since     JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public Color getColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return mGraphics.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Sets this graphics context's current color to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * color. All subsequent graphics operations using this graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * context use this specified color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @param     c   the new rendering color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @see       java.awt.Color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @see       java.awt.Graphics#getColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @since     JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public void setColor(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        mGraphics.setColor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * Sets the paint mode of this graphics context to overwrite the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * destination with this graphics context's current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * This sets the logical pixel operation function to the paint or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * overwrite mode.  All subsequent rendering operations will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * overwrite the destination with the current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public void setPaintMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        mGraphics.setPaintMode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * Sets the paint mode of this graphics context to alternate between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * this graphics context's current color and the new specified color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * This specifies that logical pixel operations are performed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * XOR mode, which alternates pixels between the current color and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * a specified XOR color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * When drawing operations are performed, pixels which are the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * current color are changed to the specified color, and vice versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Pixels that are of colors other than those two colors are changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * in an unpredictable but reversible manner; if the same figure is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * drawn twice, then all pixels are restored to their original values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param     c1 the XOR alternation color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @since     JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public void setXORMode(Color c1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        mGraphics.setXORMode(c1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * Gets the current font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @return    this graphics context's current font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @see       java.awt.Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @see       java.awt.Graphics#setFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @since     JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        return mGraphics.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Sets this graphics context's font to the specified font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * All subsequent text operations using this graphics context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * use this font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param  font   the font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @see     java.awt.Graphics#getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @see     java.awt.Graphics#drawChars(java.lang.String, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see     java.awt.Graphics#drawString(byte[], int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see     java.awt.Graphics#drawBytes(char[], int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    public void setFont(Font font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        mGraphics.setFont(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * Gets the font metrics for the specified font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @return    the font metrics for the specified font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @param     f the specified font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @see       java.awt.Graphics#getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @see       java.awt.FontMetrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @see       java.awt.Graphics#getFontMetrics()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @since     JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        return mGraphics.getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    * Get the rendering context of the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    * within this Graphics2D context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    public FontRenderContext getFontRenderContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        return mGraphics.getFontRenderContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Returns the bounding rectangle of the current clipping area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * The coordinates in the rectangle are relative to the coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * system origin of this graphics context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @return      the bounding rectangle of the current clipping area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @see         java.awt.Graphics#getClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @see         java.awt.Graphics#clipRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @see         java.awt.Graphics#setClip(int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @see         java.awt.Graphics#setClip(Shape)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    public Rectangle getClipBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        return mGraphics.getClipBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * Intersects the current clip with the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * The resulting clipping area is the intersection of the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * clipping area and the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * This method can only be used to make the current clip smaller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * To set the current clip larger, use any of the setClip methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * Rendering operations have no effect outside of the clipping area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @param x the x coordinate of the rectangle to intersect the clip with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @param y the y coordinate of the rectangle to intersect the clip with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @param width the width of the rectangle to intersect the clip with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param height the height of the rectangle to intersect the clip with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @see #setClip(int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @see #setClip(Shape)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    public void clipRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        mGraphics.clipRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Sets the current clip to the rectangle specified by the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * Rendering operations have no effect outside of the clipping area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @param       x the <i>x</i> coordinate of the new clip rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @param       y the <i>y</i> coordinate of the new clip rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @param       width the width of the new clip rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @param       height the height of the new clip rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @see         java.awt.Graphics#clipRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @see         java.awt.Graphics#setClip(Shape)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public void setClip(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        mGraphics.setClip(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * Gets the current clipping area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @return      a <code>Shape</code> object representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     *                      current clipping area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @see         java.awt.Graphics#getClipBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @see         java.awt.Graphics#clipRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @see         java.awt.Graphics#setClip(int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @see         java.awt.Graphics#setClip(Shape)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    public Shape getClip() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        return mGraphics.getClip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Sets the current clipping area to an arbitrary clip shape.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * Not all objects which implement the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * interface can be used to set the clip.  The only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * <code>Shape</code> objects which are guaranteed to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * supported are <code>Shape</code> objects which are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * obtained via the <code>getClip</code> method and via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * <code>Rectangle</code> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @see         java.awt.Graphics#getClip()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @see         java.awt.Graphics#clipRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * @see         java.awt.Graphics#setClip(int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public void setClip(Shape clip) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        mGraphics.setClip(clip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Copies an area of the component by a distance specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <code>dx</code> and <code>dy</code>. From the point specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * by <code>x</code> and <code>y</code>, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * copies downwards and to the right.  To copy an area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * component to the left or upwards, specify a negative value for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * <code>dx</code> or <code>dy</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * If a portion of the source rectangle lies outside the bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * of the component, or is obscured by another window or component,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * <code>copyArea</code> will be unable to copy the associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * pixels. The area that is omitted can be refreshed by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * the component's <code>paint</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @param       x the <i>x</i> coordinate of the source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * @param       y the <i>y</i> coordinate of the source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * @param       width the width of the source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @param       height the height of the source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @param       dx the horizontal distance to copy the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @param       dy the vertical distance to copy the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    public void copyArea(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                         int dx, int dy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        mGraphics.copyArea(x, y, width, height, dx, dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * Draws a line, using the current color, between the points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * <code>(x1,&nbsp;y1)</code> and <code>(x2,&nbsp;y2)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * in this graphics context's coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param   x1  the first point's <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @param   y1  the first point's <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @param   x2  the second point's <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @param   y2  the second point's <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    public void drawLine(int x1, int y1, int x2, int y2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        mGraphics.drawLine(x1, y1, x2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Fills the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * The left and right edges of the rectangle are at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * <code>x</code> and <code>x&nbsp;+&nbsp;width&nbsp;-&nbsp;1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * The top and bottom edges are at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * <code>y</code> and <code>y&nbsp;+&nbsp;height&nbsp;-&nbsp;1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * The resulting rectangle covers an area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * <code>width</code> pixels wide by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * <code>height</code> pixels tall.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * The rectangle is filled using the graphics context's current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @param         x   the <i>x</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *                         of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * @param         y   the <i>y</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *                         of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @param         width   the width of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @param         height   the height of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @see           java.awt.Graphics#fillRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @see           java.awt.Graphics#clearRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @since         JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    public void fillRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        mGraphics.fillRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * Clears the specified rectangle by filling it with the background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * color of the current drawing surface. This operation does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * use the current paint mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * Beginning with Java&nbsp;1.1, the background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * of offscreen images may be system dependent. Applications should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * use <code>setColor</code> followed by <code>fillRect</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * ensure that an offscreen image is cleared to a specific color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param       x the <i>x</i> coordinate of the rectangle to clear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @param       y the <i>y</i> coordinate of the rectangle to clear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @param       width the width of the rectangle to clear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @param       height the height of the rectangle to clear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @see         java.awt.Graphics#fillRect(int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @see         java.awt.Graphics#drawRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see         java.awt.Graphics#setColor(java.awt.Color)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see         java.awt.Graphics#setPaintMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see         java.awt.Graphics#setXORMode(java.awt.Color)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public void clearRect(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        mGraphics.clearRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * Draws an outlined round-cornered rectangle using this graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * context's current color. The left and right edges of the rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * are at <code>x</code> and <code>x&nbsp;+&nbsp;width</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * respectively. The top and bottom edges of the rectangle are at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * <code>y</code> and <code>y&nbsp;+&nbsp;height</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @param      x the <i>x</i> coordinate of the rectangle to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @param      y the <i>y</i> coordinate of the rectangle to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @param      width the width of the rectangle to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @param      height the height of the rectangle to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @param      arcWidth the horizontal diameter of the arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *                    at the four corners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @param      arcHeight the vertical diameter of the arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *                    at the four corners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @see        java.awt.Graphics#fillRoundRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @since      JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    public void drawRoundRect(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                              int arcWidth, int arcHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        mGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * Fills the specified rounded corner rectangle with the current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * The left and right edges of the rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * are at <code>x</code> and <code>x&nbsp;+&nbsp;width&nbsp;-&nbsp;1</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * respectively. The top and bottom edges of the rectangle are at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * <code>y</code> and <code>y&nbsp;+&nbsp;height&nbsp;-&nbsp;1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * @param       x the <i>x</i> coordinate of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @param       y the <i>y</i> coordinate of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @param       width the width of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @param       height the height of the rectangle to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @param       arcWidth the horizontal diameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     *                     of the arc at the four corners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @param       arcHeight the vertical diameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *                     of the arc at the four corners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @see         java.awt.Graphics#drawRoundRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    public void fillRoundRect(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                       int arcWidth, int arcHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        mGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * Draws the outline of an oval.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * The result is a circle or ellipse that fits within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * rectangle specified by the <code>x</code>, <code>y</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * <code>width</code>, and <code>height</code> arguments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * The oval covers an area that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * <code>width&nbsp;+&nbsp;1</code> pixels wide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * and <code>height&nbsp;+&nbsp;1</code> pixels tall.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @param       x the <i>x</i> coordinate of the upper left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *                     corner of the oval to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @param       y the <i>y</i> coordinate of the upper left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *                     corner of the oval to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @param       width the width of the oval to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * @param       height the height of the oval to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @see         java.awt.Graphics#fillOval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    public void drawOval(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        mGraphics.drawOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * Fills an oval bounded by the specified rectangle with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @param       x the <i>x</i> coordinate of the upper left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *                     of the oval to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @param       y the <i>y</i> coordinate of the upper left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *                     of the oval to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * @param       width the width of the oval to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @param       height the height of the oval to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * @see         java.awt.Graphics#drawOval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    public void fillOval(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        mGraphics.fillOval(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * Draws the outline of a circular or elliptical arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * covering the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * The resulting arc begins at <code>startAngle</code> and extends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * for <code>arcAngle</code> degrees, using the current color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * Angles are interpreted such that 0&nbsp;degrees
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * is at the 3&nbsp;o'clock position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * A positive value indicates a counter-clockwise rotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * while a negative value indicates a clockwise rotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * The center of the arc is the center of the rectangle whose origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * is (<i>x</i>,&nbsp;<i>y</i>) and whose size is specified by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * <code>width</code> and <code>height</code> arguments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * The resulting arc covers an area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * <code>width&nbsp;+&nbsp;1</code> pixels wide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * by <code>height&nbsp;+&nbsp;1</code> pixels tall.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * @param        x the <i>x</i> coordinate of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *                    upper-left corner of the arc to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @param        y the <i>y</i>  coordinate of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *                    upper-left corner of the arc to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @param        width the width of the arc to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @param        height the height of the arc to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * @param        startAngle the beginning angle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @param        arcAngle the angular extent of the arc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     *                    relative to the start angle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * @see         java.awt.Graphics#fillArc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    public void drawArc(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                                 int startAngle, int arcAngle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        mGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * Fills a circular or elliptical arc covering the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * The resulting arc begins at <code>startAngle</code> and extends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * for <code>arcAngle</code> degrees.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * Angles are interpreted such that 0&nbsp;degrees
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * is at the 3&nbsp;o'clock position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * A positive value indicates a counter-clockwise rotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * while a negative value indicates a clockwise rotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * The center of the arc is the center of the rectangle whose origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * is (<i>x</i>,&nbsp;<i>y</i>) and whose size is specified by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * <code>width</code> and <code>height</code> arguments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * The resulting arc covers an area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * <code>width&nbsp;+&nbsp;1</code> pixels wide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * by <code>height&nbsp;+&nbsp;1</code> pixels tall.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @param        x the <i>x</i> coordinate of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *                    upper-left corner of the arc to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * @param        y the <i>y</i>  coordinate of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *                    upper-left corner of the arc to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * @param        width the width of the arc to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * @param        height the height of the arc to be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @param        startAngle the beginning angle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @param        arcAngle the angular extent of the arc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     *                    relative to the start angle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @see         java.awt.Graphics#drawArc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    public void fillArc(int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                        int startAngle, int arcAngle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        mGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * Draws a sequence of connected lines defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * arrays of <i>x</i> and <i>y</i> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * The figure is not closed if the first point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * differs from the last point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @param       xPoints an array of <i>x</i> points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * @param       yPoints an array of <i>y</i> points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * @param       nPoints the total number of points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    public void drawPolyline(int xPoints[], int yPoints[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                             int nPoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        mGraphics.drawPolyline(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * Draws a closed polygon defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * arrays of <i>x</i> and <i>y</i> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * This method draws the polygon defined by <code>nPoint</code> line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * segments, where the first <code>nPoint&nbsp;-&nbsp;1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * line segments are line segments from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * <code>(xPoints[i&nbsp;-&nbsp;1],&nbsp;yPoints[i&nbsp;-&nbsp;1])</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * to <code>(xPoints[i],&nbsp;yPoints[i])</code>, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * 1&nbsp;&le;&nbsp;<i>i</i>&nbsp;&le;&nbsp;<code>nPoints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * The figure is automatically closed by drawing a line connecting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * the final point to the first point, if those points are different.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @param        xPoints   a an array of <code>x</code> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @param        yPoints   a an array of <code>y</code> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @param        nPoints   a the total number of points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @see          java.awt.Graphics#fillPolygon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * @see          java.awt.Graphics#drawPolyline
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * @since        JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    public void drawPolygon(int xPoints[], int yPoints[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                            int nPoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        mGraphics.drawPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * Fills a closed polygon defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * arrays of <i>x</i> and <i>y</i> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * This method draws the polygon defined by <code>nPoint</code> line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * segments, where the first <code>nPoint&nbsp;-&nbsp;1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * line segments are line segments from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * <code>(xPoints[i&nbsp;-&nbsp;1],&nbsp;yPoints[i&nbsp;-&nbsp;1])</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * to <code>(xPoints[i],&nbsp;yPoints[i])</code>, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * 1&nbsp;&le;&nbsp;<i>i</i>&nbsp;&le;&nbsp;<code>nPoints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * The figure is automatically closed by drawing a line connecting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * the final point to the first point, if those points are different.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * The area inside the polygon is defined using an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * even-odd fill rule, also known as the alternating rule.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * @param        xPoints   a an array of <code>x</code> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * @param        yPoints   a an array of <code>y</code> coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @param        nPoints   a the total number of points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * @since        JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    public void fillPolygon(int xPoints[], int yPoints[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                            int nPoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        mGraphics.fillPolygon(xPoints, yPoints, nPoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * Draws the text given by the specified string, using this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * graphics context's current font and color. The baseline of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * graphics context's coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * @param       str      the string to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * @param       x        the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @param       y        the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * @see         java.awt.Graphics#drawBytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @see         java.awt.Graphics#drawChars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    public void drawString(String str, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        mGraphics.drawString(str, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * Draws the text given by the specified iterator, using this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * graphics context's current color. The iterator has to specify a font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * for each character. The baseline of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * graphics context's coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * The rendering attributes applied include the clip, transform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * paint or color, and composite attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * For characters in script systems such as Hebrew and Arabic,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * the glyphs may be draw from right to left, in which case the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * coordinate supplied is the the location of the leftmost character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * on the baseline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * @param iterator the iterator whose text is to be drawn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * @param x,y the coordinates where the iterator's text should be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    public void drawString(AttributedCharacterIterator iterator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                                    int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        mGraphics.drawString(iterator, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * Draws the text given by the specified iterator, using this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * graphics context's current color. The iterator has to specify a font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * for each character. The baseline of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * graphics context's coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * The rendering attributes applied include the clip, transform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * paint or color, and composite attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * For characters in script systems such as Hebrew and Arabic,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * the glyphs may be draw from right to left, in which case the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * coordinate supplied is the the location of the leftmost character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * on the baseline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @param iterator the iterator whose text is to be drawn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @param x,y the coordinates where the iterator's text should be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    public void drawString(AttributedCharacterIterator iterator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                                    float x, float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        mGraphics.drawString(iterator, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * Draws as much of the specified image as is currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * The image is drawn with its top-left corner at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * (<i>x</i>,&nbsp;<i>y</i>) in this graphics context's coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * space. Transparent pixels in the image do not affect whatever
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * pixels are already there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * This method returns immediately in all cases, even if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * complete image has not yet been loaded, and it has not been dithered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * and converted for the current output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * If the image has not yet been completely loaded, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * <code>drawImage</code> returns <code>false</code>. As more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * the image becomes available, the process that draws the image notifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * the specified image observer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * @param    img the specified image to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * @param    x   the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @param    y   the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @param    observer    object to be notified as more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     *                          the image is converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @see      java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @see      java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * @since    JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    public boolean drawImage(Image img, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return mGraphics.drawImage(img, x, y, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * Draws as much of the specified image as has already been scaled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * to fit inside the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * The image is drawn inside the specified rectangle of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * graphics context's coordinate space, and is scaled if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * necessary. Transparent pixels do not affect whatever pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * are already there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * This method returns immediately in all cases, even if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * entire image has not yet been scaled, dithered, and converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * for the current output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * If the current output representation is not yet complete, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * <code>drawImage</code> returns <code>false</code>. As more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * the image becomes available, the process that draws the image notifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * the image observer by calling its <code>imageUpdate</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * A scaled version of an image will not necessarily be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * available immediately just because an unscaled version of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * image has been constructed for this output device.  Each size of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * the image may be cached separately and generated from the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * data in a separate image production sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * @param    img    the specified image to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * @param    x      the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * @param    y      the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * @param    width  the width of the rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @param    height the height of the rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * @param    observer    object to be notified as more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     *                          the image is converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * @see      java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * @see      java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * @since    JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    public boolean drawImage(Image img, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                             int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        return mGraphics.drawImage(img, x, y, width, height, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * Draws as much of the specified image as is currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * The image is drawn with its top-left corner at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * (<i>x</i>,&nbsp;<i>y</i>) in this graphics context's coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     * space.  Transparent pixels are drawn in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     * This operation is equivalent to filling a rectangle of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * width and height of the specified image with the given color and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * drawing the image on top of it, but possibly more efficient.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * This method returns immediately in all cases, even if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * complete image has not yet been loaded, and it has not been dithered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * and converted for the current output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * If the image has not yet been completely loaded, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * <code>drawImage</code> returns <code>false</code>. As more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * the image becomes available, the process that draws the image notifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * the specified image observer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * @param    img    the specified image to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * @param    x      the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * @param    y      the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * @param    bgcolor the background color to paint under the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     *                         non-opaque portions of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * @param    observer    object to be notified as more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     *                          the image is converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * @see      java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * @see      java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * @since    JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    public boolean drawImage(Image img, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                             Color bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        if (img == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        boolean result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        if (needToCopyBgColorImage(img)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            BufferedImage imageCopy = getBufferedImageCopy(img, bgcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            result = mGraphics.drawImage(imageCopy, x, y, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            result = mGraphics.drawImage(img, x, y, bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * Draws as much of the specified image as has already been scaled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * to fit inside the specified rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * The image is drawn inside the specified rectangle of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * graphics context's coordinate space, and is scaled if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * necessary. Transparent pixels are drawn in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * This operation is equivalent to filling a rectangle of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * width and height of the specified image with the given color and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * drawing the image on top of it, but possibly more efficient.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     * This method returns immediately in all cases, even if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     * entire image has not yet been scaled, dithered, and converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * for the current output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * If the current output representation is not yet complete then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * <code>drawImage</code> returns <code>false</code>. As more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * the image becomes available, the process that draws the image notifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * the specified image observer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     * A scaled version of an image will not necessarily be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     * available immediately just because an unscaled version of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     * image has been constructed for this output device.  Each size of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * the image may be cached separately and generated from the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * data in a separate image production sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * @param    img       the specified image to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * @param    x         the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * @param    y         the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     * @param    width     the width of the rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * @param    height    the height of the rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * @param    bgcolor   the background color to paint under the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     *                         non-opaque portions of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * @param    observer    object to be notified as more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     *                          the image is converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * @see      java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * @see      java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * @since    JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    public boolean drawImage(Image img, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                             int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                             Color bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        if (img == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        boolean result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        if (needToCopyBgColorImage(img)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            BufferedImage imageCopy = getBufferedImageCopy(img, bgcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            result = mGraphics.drawImage(imageCopy, x, y, width, height, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            result = mGraphics.drawImage(img, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                                         bgcolor, observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * Draws as much of the specified area of the specified image as is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * currently available, scaling it on the fly to fit inside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * specified area of the destination drawable surface. Transparent pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * do not affect whatever pixels are already there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * This method returns immediately in all cases, even if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * image area to be drawn has not yet been scaled, dithered, and converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * for the current output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * If the current output representation is not yet complete then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * <code>drawImage</code> returns <code>false</code>. As more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * the image becomes available, the process that draws the image notifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * the specified image observer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * This method always uses the unscaled version of the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * to render the scaled rectangle and performs the required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * scaling on the fly. It does not use a cached, scaled version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * of the image for this operation. Scaling of the image from source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * to destination is performed such that the first coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * of the source rectangle is mapped to the first coordinate of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * the destination rectangle, and the second source coordinate is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * mapped to the second destination coordinate. The subimage is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * scaled and flipped as needed to preserve those mappings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * @param       img the specified image to be drawn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * @param       dx1 the <i>x</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * @param       dy1 the <i>y</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * @param       dx2 the <i>x</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * @param       dy2 the <i>y</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * @param       sx1 the <i>x</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * @param       sy1 the <i>y</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @param       sx2 the <i>x</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * @param       sy2 the <i>y</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     * @param       observer object to be notified as more of the image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     *                    scaled and converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     * @see         java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     * @see         java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    public boolean drawImage(Image img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                                      int dx1, int dy1, int dx2, int dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                                      int sx1, int sy1, int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                                      ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        return mGraphics.drawImage(img, dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                                   sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                                   observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * Draws as much of the specified area of the specified image as is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * currently available, scaling it on the fly to fit inside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * specified area of the destination drawable surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * Transparent pixels are drawn in the specified background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * This operation is equivalent to filling a rectangle of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * width and height of the specified image with the given color and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     * drawing the image on top of it, but possibly more efficient.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * This method returns immediately in all cases, even if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * image area to be drawn has not yet been scaled, dithered, and converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * for the current output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * If the current output representation is not yet complete then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * <code>drawImage</code> returns <code>false</code>. As more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * the image becomes available, the process that draws the image notifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * the specified image observer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     * This method always uses the unscaled version of the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     * to render the scaled rectangle and performs the required
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     * scaling on the fly. It does not use a cached, scaled version
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     * of the image for this operation. Scaling of the image from source
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     * to destination is performed such that the first coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * of the source rectangle is mapped to the first coordinate of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     * the destination rectangle, and the second source coordinate is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     * mapped to the second destination coordinate. The subimage is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * scaled and flipped as needed to preserve those mappings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * @param       img the specified image to be drawn
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * @param       dx1 the <i>x</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     * @param       dy1 the <i>y</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * @param       dx2 the <i>x</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * @param       dy2 the <i>y</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     *                    destination rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * @param       sx1 the <i>x</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * @param       sy1 the <i>y</i> coordinate of the first corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     * @param       sx2 the <i>x</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     * @param       sy2 the <i>y</i> coordinate of the second corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     *                    source rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * @param       bgcolor the background color to paint under the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     *                    non-opaque portions of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     * @param       observer object to be notified as more of the image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     *                    scaled and converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * @see         java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * @see         java.awt.image.ImageObserver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    public boolean drawImage(Image img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                             int dx1, int dy1, int dx2, int dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                             int sx1, int sy1, int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                             Color bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                             ImageObserver observer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        if (img == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        boolean result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        if (needToCopyBgColorImage(img)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            BufferedImage imageCopy = getBufferedImageCopy(img, bgcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            result = mGraphics.drawImage(imageCopy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                                         dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                                         sy1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
                                         null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
            result = mGraphics.drawImage(img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                                         dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                                         sy1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                                         bgcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                                         observer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     * Return true if drawing <code>img</code> will
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * invoke a Java2D bug (#4258675). The bug in question
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     * occurs when a draw image call with a background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     * parameter tries to render a sheared
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     * or rotated image. The portions of the bounding
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * rectangle not covered by the sheared image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     * are incorrectly drawn with the background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    private boolean needToCopyBgColorImage(Image img) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        boolean needToCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        AffineTransform transform = getTransform();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        return (transform.getType()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                & (AffineTransform.TYPE_GENERAL_ROTATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                   | AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * Return a new <code>BufferedImage</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     * that contains a copy of the provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * <code>Image</code> where its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * transparent pixels have been replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     * <code>bgcolor</code>. If the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
     * <code>BufferedImage</code> can not be created,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     * probably because the original image has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     * finished loading, then <code>null</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    private BufferedImage getBufferedImageCopy(Image img, Color bgcolor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        BufferedImage imageCopy = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        int width = img.getWidth(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        int height = img.getHeight(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        if (width > 0 && height > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
            int imageType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
            /* Try to minimize the depth of the BufferedImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
             * we are about to create by, if possible, making
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
             * it the same depth as the original image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            if (img instanceof BufferedImage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                BufferedImage bufImage = (BufferedImage) img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                imageType = bufImage.getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                imageType = BufferedImage.TYPE_INT_ARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
            imageCopy = new BufferedImage(width, height, imageType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
            /* Copy the original image into the new buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
             * without any transformations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
             * This will replace the transparent pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
             * in the original with background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            Graphics g = imageCopy.createGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
            g.drawImage(img, 0, 0, bgcolor, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
            g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
        /* We couldn't get the width or height of the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
         * so just return null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
            imageCopy = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
        return imageCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * Draws an image, applying a transform from image space into user space
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     * before drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     * The transformation from user space into device space is done with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     * the current transform in the Graphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     * The given transformation is applied to the image before the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
     * transform attribute in the Graphics2D state is applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
     * The rendering attributes applied include the clip, transform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
     * and composite attributes. Note that the result is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
     * undefined, if the given transform is noninvertible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * @param img The image to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     * @param xform The transformation from image space into user space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    public void drawRenderedImage(RenderedImage img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                                  AffineTransform xform) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        mGraphics.drawRenderedImage(img, xform);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    public void drawRenderableImage(RenderableImage img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                                    AffineTransform xform) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        if (img == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        AffineTransform pipeTransform = getTransform();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        AffineTransform concatTransform = new AffineTransform(xform);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
        concatTransform.concatenate(pipeTransform);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        AffineTransform reverseTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        RenderContext rc = new RenderContext(concatTransform);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            reverseTransform = pipeTransform.createInverse();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        } catch (NoninvertibleTransformException nte) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
            rc = new RenderContext(pipeTransform);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            reverseTransform = new AffineTransform();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        RenderedImage rendering = img.createRendering(rc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        drawRenderedImage(rendering,reverseTransform);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     * Disposes of this graphics context and releases
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     * any system resources that it is using.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
     * A <code>Graphics</code> object cannot be used after
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     * <code>dispose</code>has been called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     * When a Java program runs, a large number of <code>Graphics</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
     * objects can be created within a short time frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * Although the finalization process of the garbage collector
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     * also disposes of the same system resources, it is preferable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
     * to manually free the associated resources by calling this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     * method rather than to rely on a finalization process which
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
     * may not run to completion for a long period of time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     * Graphics objects which are provided as arguments to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
     * <code>paint</code> and <code>update</code> methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
     * of components are automatically released by the system when
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
     * those methods return. For efficiency, programmers should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     * call <code>dispose</code> when finished using
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     * a <code>Graphics</code> object only if it was created
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
     * directly from a component or another <code>Graphics</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
     * @see         java.awt.Graphics#finalize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
     * @see         java.awt.Component#paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
     * @see         java.awt.Component#update
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     * @see         java.awt.Component#getGraphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
     * @see         java.awt.Graphics#create
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
     * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        mGraphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     * Empty finalizer as no clean up needed here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
    public void finalize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
/* The Delegated Graphics2D Methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     * Strokes the outline of a Shape using the settings of the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     * graphics state.  The rendering attributes applied include the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     * clip, transform, paint or color, composite and stroke attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     * @param s The shape to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * @see #setStroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    public void draw(Shape s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        mGraphics.draw(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     * Draws an image, applying a transform from image space into user space
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
     * before drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
     * The transformation from user space into device space is done with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
     * the current transform in the Graphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
     * The given transformation is applied to the image before the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
     * transform attribute in the Graphics2D state is applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
     * The rendering attributes applied include the clip, transform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
     * and composite attributes. Note that the result is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
     * undefined, if the given transform is noninvertible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
     * @param img The image to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
     * @param xform The transformation from image space into user space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
     * @param obs The image observer to be notified as more of the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
     * is converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
    public boolean drawImage(Image img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
                             AffineTransform xform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
                             ImageObserver obs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
        return mGraphics.drawImage(img, xform, obs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     * Draws a BufferedImage that is filtered with a BufferedImageOp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
     * The rendering attributes applied include the clip, transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
     * and composite attributes.  This is equivalent to:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
     * img1 = op.filter(img, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
     * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
     * @param op The filter to be applied to the image before drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
     * @param img The BufferedImage to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
     * @param x,y The location in user space where the image should be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
    public void drawImage(BufferedImage img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
                          BufferedImageOp op,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
                          int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
                          int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
        mGraphics.drawImage(img, op, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
     * Draws a string of text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
     * The rendering attributes applied include the clip, transform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
     * paint or color, font and composite attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
     * @param s The string to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
     * @param x,y The coordinates where the string should be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
     * @see java.awt.Graphics#setFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    public void drawString(String str,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
                           float x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
                           float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
        mGraphics.drawString(str, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * Draws a GlyphVector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * The rendering attributes applied include the clip, transform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * paint or color, and composite attributes.  The GlyphVector specifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * individual glyphs from a Font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     * @param g The GlyphVector to be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     * @param x,y The coordinates where the glyphs should be drawn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
    public void drawGlyphVector(GlyphVector g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
                                float x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
                                float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
        mGraphics.drawGlyphVector(g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * Fills the interior of a Shape using the settings of the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     * graphics state. The rendering attributes applied include the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * clip, transform, paint or color, and composite.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    public void fill(Shape s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
        mGraphics.fill(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     * Checks to see if the outline of a Shape intersects the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
     * Rectangle in device space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
     * The rendering attributes taken into account include the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
     * clip, transform, and stroke attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
     * @param rect The area in device space to check for a hit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
     * @param s The shape to check for a hit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
     * @param onStroke Flag to choose between testing the stroked or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
     * the filled shape.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
     * @return True if there is a hit, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
     * @see #setStroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
     * @see #fill
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
     * @see #draw
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
     * @see #clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
     * @see #setClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
    public boolean hit(Rectangle rect,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                       Shape s,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                       boolean onStroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
        return mGraphics.hit(rect, s, onStroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
     * Sets the Composite in the current graphics state. Composite is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
     * in all drawing methods such as drawImage, drawString, draw,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
     * and fill.  It specifies how new pixels are to be combined with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
     * the existing pixels on the graphics device in the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
     * @param comp The Composite object to be used for drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
     * @see java.awt.Graphics#setXORMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
     * @see java.awt.Graphics#setPaintMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
     * @see AlphaComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    public void setComposite(Composite comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
        mGraphics.setComposite(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
     * Sets the Paint in the current graphics state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
     * @param paint The Paint object to be used to generate color in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
     * the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
     * @see GradientPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
     * @see TexturePaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
    public void setPaint(Paint paint) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
        mGraphics.setPaint(paint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
     * Sets the Stroke in the current graphics state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
     * @param s The Stroke object to be used to stroke a Shape in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
     * the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
     * @see BasicStroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
    public void setStroke(Stroke s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
        mGraphics.setStroke(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
     * Sets the preferences for the rendering algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
     * Hint categories include controls for rendering quality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
     * overall time/quality trade-off in the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
     * @param hintCategory The category of hint to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
     * @param hintValue The value indicating preferences for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
     * hint category.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
     * @see RenderingHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
    public void setRenderingHint(Key hintCategory, Object hintValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
        mGraphics.setRenderingHint(hintCategory, hintValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
     * Returns the preferences for the rendering algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
     * @param hintCategory The category of hint to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
     * @return The preferences for rendering algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
     * @see RenderingHings
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
    public Object getRenderingHint(Key hintCategory) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        return mGraphics.getRenderingHint(hintCategory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
     * Sets the preferences for the rendering algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
     * Hint categories include controls for rendering quality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
     * overall time/quality trade-off in the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
     * @param hints The rendering hints to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     * @see RenderingHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
    public void setRenderingHints(Map<?,?> hints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
        mGraphics.setRenderingHints(hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     * Adds a number of preferences for the rendering algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
     * Hint categories include controls for rendering quality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
     * overall time/quality trade-off in the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
     * @param hints The rendering hints to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
     * @see RenderingHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
    public void addRenderingHints(Map<?,?> hints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        mGraphics.addRenderingHints(hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
     * Gets the preferences for the rendering algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
     * Hint categories include controls for rendering quality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
     * overall time/quality trade-off in the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
     * @see RenderingHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
    public RenderingHints getRenderingHints() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        return mGraphics.getRenderingHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
     * Composes a Transform object with the transform in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
     * Graphics2D according to the rule last-specified-first-applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
     * If the currrent transform is Cx, the result of composition
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
     * with Tx is a new transform Cx'.  Cx' becomes the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
     * transform for this Graphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
     * Transforming a point p by the updated transform Cx' is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
     * equivalent to first transforming p by Tx and then transforming
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
     * the result by the original transform Cx.  In other words,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
     * Cx'(p) = Cx(Tx(p)).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
     * A copy of the Tx is made, if necessary, so further
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
     * modifications to Tx do not affect rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
     * @param Tx The Transform object to be composed with the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
     * transform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
     * @see TransformChain
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
     * @see AffineTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
    public void transform(AffineTransform Tx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
        mGraphics.transform(Tx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
     * Sets the Transform in the current graphics state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
     * @param Tx The Transform object to be used in the rendering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
     * @see TransformChain
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
     * @see AffineTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
    public void setTransform(AffineTransform Tx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        mGraphics.setTransform(Tx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * Returns the current Transform in the Graphics2D state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * @see #transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     * @see #setTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
    public AffineTransform getTransform() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
        return mGraphics.getTransform();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
     * Returns the current Paint in the Graphics2D state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
     * @see #setPaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
     * @see java.awt.Graphics#setColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
    public Paint getPaint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
        return mGraphics.getPaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
     * Returns the current Composite in the Graphics2D state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
     * @see #setComposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
    public Composite getComposite() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
        return mGraphics.getComposite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
     * Sets the background color in this context used for clearing a region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
     * When Graphics2D is constructed for a component, the backgroung color is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
     * inherited from the component. Setting the background color in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
     * Graphics2D context only affects the subsequent clearRect() calls and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
     * not the background color of the component. To change the background
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
     * of the component, use appropriate methods of the component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
     * @param color The background color that should be used in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
     * subsequent calls to clearRect().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
     * @see getBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
     * @see Graphics.clearRect()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
    public void setBackground(Color color) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
        mGraphics.setBackground(color);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
     * Returns the background color used for clearing a region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
     * @see setBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
    public Color getBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
        return mGraphics.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
     * Returns the current Stroke in the Graphics2D state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
     * @see setStroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
    public Stroke getStroke() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
        return mGraphics.getStroke();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
     * Intersects the current clip with the interior of the specified Shape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
     * and sets the current clip to the resulting intersection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
     * The indicated shape is transformed with the current transform in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
     * Graphics2D state before being intersected with the current clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
     * This method is used to make the current clip smaller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
     * To make the clip larger, use any setClip method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
     * @param s The Shape to be intersected with the current clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
     public void clip(Shape s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
        mGraphics.clip(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
}