Path: blob/master/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java
41153 views
/*1* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.print;2627import java.util.Map;2829import java.awt.Color;30import java.awt.Composite;31import java.awt.Graphics;32import java.awt.Graphics2D;33import java.awt.Font;34import java.awt.FontMetrics;35import java.awt.font.FontRenderContext;36import java.awt.Graphics;37import java.awt.GraphicsConfiguration;38import java.awt.Image;39import java.awt.Paint;40import java.awt.Rectangle;41import java.awt.Shape;42import java.awt.Stroke;43import java.awt.RenderingHints;44import java.awt.RenderingHints.Key;4546import java.awt.font.GlyphVector;4748import java.awt.geom.AffineTransform;49import java.awt.geom.Rectangle2D;50import java.awt.geom.NoninvertibleTransformException;51import java.awt.image.BufferedImage;52import java.awt.image.BufferedImageOp;53import java.awt.image.ImageObserver;54import java.awt.image.RenderedImage;55import java.awt.image.renderable.RenderContext;56import java.awt.image.renderable.RenderableImage;57import java.awt.print.PrinterGraphics;58import java.awt.print.PrinterJob;5960import java.text.AttributedCharacterIterator;6162public class ProxyGraphics2D extends Graphics2D implements PrinterGraphics {6364/**65* Drawing methods will be forwarded to this object.66*/67Graphics2D mGraphics;6869/**70* The PrinterJob controlling the current printing.71*/72PrinterJob mPrinterJob;7374/**75* The new ProxyGraphics2D will forward all graphics76* calls to 'graphics'.77*/78public ProxyGraphics2D(Graphics2D graphics, PrinterJob printerJob) {79mGraphics = graphics;80mPrinterJob = printerJob;81}8283/**84* Return the Graphics2D object that does the drawing85* for this instance.86*/87public Graphics2D getDelegate() {88return mGraphics;89}9091/**92* Set the Graphics2D instance which will do the93* drawing.94*/95public void setDelegate(Graphics2D graphics) {96mGraphics = graphics;97}9899public PrinterJob getPrinterJob() {100return mPrinterJob;101}102103/**104* Returns the device configuration associated with this Graphics2D.105*/106public GraphicsConfiguration getDeviceConfiguration() {107return ((RasterPrinterJob)mPrinterJob).getPrinterGraphicsConfig();108}109110/* The Delegated Graphics Methods */111112/**113* Creates a new {@code Graphics} object that is114* a copy of this {@code Graphics} object.115* @return a new graphics context that is a copy of116* this graphics context.117* @since 1.0118*/119public Graphics create() {120return new ProxyGraphics2D((Graphics2D) mGraphics.create(),121mPrinterJob);122}123124/**125* Translates the origin of the graphics context to the point126* (<i>x</i>, <i>y</i>) in the current coordinate system.127* Modifies this graphics context so that its new origin corresponds128* to the point (<i>x</i>, <i>y</i>) in this graphics context's129* original coordinate system. All coordinates used in subsequent130* rendering operations on this graphics context will be relative131* to this new origin.132* @param x the <i>x</i> coordinate.133* @param y the <i>y</i> coordinate.134* @since 1.0135*/136public void translate(int x, int y) {137mGraphics.translate(x, y);138}139140/**141* Concatenates the current transform of this Graphics2D with a142* translation transformation.143* This is equivalent to calling transform(T), where T is an144* AffineTransform represented by the following matrix:145* <pre>146* [ 1 0 tx ]147* [ 0 1 ty ]148* [ 0 0 1 ]149* </pre>150*/151public void translate(double tx, double ty) {152mGraphics.translate(tx, ty);153}154155/**156* Concatenates the current transform of this Graphics2D with a157* rotation transformation.158* This is equivalent to calling transform(R), where R is an159* AffineTransform represented by the following matrix:160* <pre>161* [ cos(theta) -sin(theta) 0 ]162* [ sin(theta) cos(theta) 0 ]163* [ 0 0 1 ]164* </pre>165* Rotating with a positive angle theta rotates points on the positive166* x axis toward the positive y axis.167* @param theta The angle of rotation in radians.168*/169public void rotate(double theta) {170mGraphics.rotate(theta);171}172173/**174* Concatenates the current transform of this Graphics2D with a175* translated rotation transformation.176* This is equivalent to the following sequence of calls:177* <pre>178* translate(x, y);179* rotate(theta);180* translate(-x, -y);181* </pre>182* Rotating with a positive angle theta rotates points on the positive183* x axis toward the positive y axis.184* @param theta The angle of rotation in radians.185* @param x The x coordinate of the origin of the rotation186* @param y The x coordinate of the origin of the rotation187*/188public void rotate(double theta, double x, double y) {189mGraphics.rotate(theta, x, y);190}191192/**193* Concatenates the current transform of this Graphics2D with a194* scaling transformation.195* This is equivalent to calling transform(S), where S is an196* AffineTransform represented by the following matrix:197* <pre>198* [ sx 0 0 ]199* [ 0 sy 0 ]200* [ 0 0 1 ]201* </pre>202*/203public void scale(double sx, double sy) {204mGraphics.scale(sx, sy);205}206207/**208* Concatenates the current transform of this Graphics2D with a209* shearing transformation.210* This is equivalent to calling transform(SH), where SH is an211* AffineTransform represented by the following matrix:212* <pre>213* [ 1 shx 0 ]214* [ shy 1 0 ]215* [ 0 0 1 ]216* </pre>217* @param shx The factor by which coordinates are shifted towards the218* positive X axis direction according to their Y coordinate219* @param shy The factor by which coordinates are shifted towards the220* positive Y axis direction according to their X coordinate221*/222public void shear(double shx, double shy) {223mGraphics.shear(shx, shy);224}225226/**227* Gets this graphics context's current color.228* @return this graphics context's current color.229* @see java.awt.Color230* @see java.awt.Graphics#setColor231* @since 1.0232*/233public Color getColor() {234return mGraphics.getColor();235}236237/**238* Sets this graphics context's current color to the specified239* color. All subsequent graphics operations using this graphics240* context use this specified color.241* @param c the new rendering color.242* @see java.awt.Color243* @see java.awt.Graphics#getColor244* @since 1.0245*/246public void setColor(Color c) {247mGraphics.setColor(c);248}249250/**251* Sets the paint mode of this graphics context to overwrite the252* destination with this graphics context's current color.253* This sets the logical pixel operation function to the paint or254* overwrite mode. All subsequent rendering operations will255* overwrite the destination with the current color.256* @since 1.0257*/258public void setPaintMode() {259mGraphics.setPaintMode();260}261262/**263* Sets the paint mode of this graphics context to alternate between264* this graphics context's current color and the new specified color.265* This specifies that logical pixel operations are performed in the266* XOR mode, which alternates pixels between the current color and267* a specified XOR color.268* <p>269* When drawing operations are performed, pixels which are the270* current color are changed to the specified color, and vice versa.271* <p>272* Pixels that are of colors other than those two colors are changed273* in an unpredictable but reversible manner; if the same figure is274* drawn twice, then all pixels are restored to their original values.275* @param c1 the XOR alternation color276* @since 1.0277*/278public void setXORMode(Color c1) {279mGraphics.setXORMode(c1);280}281282/**283* Gets the current font.284* @return this graphics context's current font.285* @see java.awt.Font286* @see java.awt.Graphics#setFont287* @since 1.0288*/289public Font getFont() {290return mGraphics.getFont();291}292293/**294* Sets this graphics context's font to the specified font.295* All subsequent text operations using this graphics context296* use this font.297* @param font the font.298* @see java.awt.Graphics#getFont299* @see java.awt.Graphics#drawChars(char[], int, int, int, int)300* @see java.awt.Graphics#drawString(String, int, int)301* @see java.awt.Graphics#drawBytes(byte[], int, int, int, int)302* @since 1.0303*/304public void setFont(Font font) {305mGraphics.setFont(font);306}307308/**309* Gets the font metrics for the specified font.310* @return the font metrics for the specified font.311* @param f the specified font312* @see java.awt.Graphics#getFont313* @see java.awt.FontMetrics314* @see java.awt.Graphics#getFontMetrics()315* @since 1.0316*/317public FontMetrics getFontMetrics(Font f) {318return mGraphics.getFontMetrics(f);319}320321/**322* Get the rendering context of the font323* within this Graphics2D context.324*/325public FontRenderContext getFontRenderContext() {326return mGraphics.getFontRenderContext();327}328329/**330* Returns the bounding rectangle of the current clipping area.331* The coordinates in the rectangle are relative to the coordinate332* system origin of this graphics context.333* @return the bounding rectangle of the current clipping area.334* @see java.awt.Graphics#getClip335* @see java.awt.Graphics#clipRect336* @see java.awt.Graphics#setClip(int, int, int, int)337* @see java.awt.Graphics#setClip(Shape)338* @since 1.1339*/340public Rectangle getClipBounds() {341return mGraphics.getClipBounds();342}343344345/**346* Intersects the current clip with the specified rectangle.347* The resulting clipping area is the intersection of the current348* clipping area and the specified rectangle.349* This method can only be used to make the current clip smaller.350* To set the current clip larger, use any of the setClip methods.351* Rendering operations have no effect outside of the clipping area.352* @param x the x coordinate of the rectangle to intersect the clip with353* @param y the y coordinate of the rectangle to intersect the clip with354* @param width the width of the rectangle to intersect the clip with355* @param height the height of the rectangle to intersect the clip with356* @see #setClip(int, int, int, int)357* @see #setClip(Shape)358*/359public void clipRect(int x, int y, int width, int height) {360mGraphics.clipRect(x, y, width, height);361}362363364/**365* Sets the current clip to the rectangle specified by the given366* coordinates.367* Rendering operations have no effect outside of the clipping area.368* @param x the <i>x</i> coordinate of the new clip rectangle.369* @param y the <i>y</i> coordinate of the new clip rectangle.370* @param width the width of the new clip rectangle.371* @param height the height of the new clip rectangle.372* @see java.awt.Graphics#clipRect373* @see java.awt.Graphics#setClip(Shape)374* @since 1.1375*/376public void setClip(int x, int y, int width, int height) {377mGraphics.setClip(x, y, width, height);378}379380/**381* Gets the current clipping area.382* @return a {@code Shape} object representing the383* current clipping area.384* @see java.awt.Graphics#getClipBounds385* @see java.awt.Graphics#clipRect386* @see java.awt.Graphics#setClip(int, int, int, int)387* @see java.awt.Graphics#setClip(Shape)388* @since 1.1389*/390public Shape getClip() {391return mGraphics.getClip();392}393394395/**396* Sets the current clipping area to an arbitrary clip shape.397* Not all objects which implement the {@code Shape}398* interface can be used to set the clip. The only399* {@code Shape} objects which are guaranteed to be400* supported are {@code Shape} objects which are401* obtained via the {@code getClip} method and via402* {@code Rectangle} objects.403* @see java.awt.Graphics#getClip()404* @see java.awt.Graphics#clipRect405* @see java.awt.Graphics#setClip(int, int, int, int)406* @since 1.1407*/408public void setClip(Shape clip) {409mGraphics.setClip(clip);410}411412413/**414* Copies an area of the component by a distance specified by415* {@code dx} and {@code dy}. From the point specified416* by {@code x} and {@code y}, this method417* copies downwards and to the right. To copy an area of the418* component to the left or upwards, specify a negative value for419* {@code dx} or {@code dy}.420* If a portion of the source rectangle lies outside the bounds421* of the component, or is obscured by another window or component,422* {@code copyArea} will be unable to copy the associated423* pixels. The area that is omitted can be refreshed by calling424* the component's {@code paint} method.425* @param x the <i>x</i> coordinate of the source rectangle.426* @param y the <i>y</i> coordinate of the source rectangle.427* @param width the width of the source rectangle.428* @param height the height of the source rectangle.429* @param dx the horizontal distance to copy the pixels.430* @param dy the vertical distance to copy the pixels.431* @since 1.0432*/433public void copyArea(int x, int y, int width, int height,434int dx, int dy) {435mGraphics.copyArea(x, y, width, height, dx, dy);436}437438/**439* Draws a line, using the current color, between the points440* <code>(x1, y1)</code> and <code>(x2, y2)</code>441* in this graphics context's coordinate system.442* @param x1 the first point's <i>x</i> coordinate.443* @param y1 the first point's <i>y</i> coordinate.444* @param x2 the second point's <i>x</i> coordinate.445* @param y2 the second point's <i>y</i> coordinate.446* @since 1.0447*/448public void drawLine(int x1, int y1, int x2, int y2) {449mGraphics.drawLine(x1, y1, x2, y2);450}451452453/**454* Fills the specified rectangle.455* The left and right edges of the rectangle are at456* {@code x} and <code>x + width - 1</code>.457* The top and bottom edges are at458* {@code y} and <code>y + height - 1</code>.459* The resulting rectangle covers an area460* {@code width} pixels wide by461* {@code height} pixels tall.462* The rectangle is filled using the graphics context's current color.463* @param x the <i>x</i> coordinate464* of the rectangle to be filled.465* @param y the <i>y</i> coordinate466* of the rectangle to be filled.467* @param width the width of the rectangle to be filled.468* @param height the height of the rectangle to be filled.469* @see java.awt.Graphics#fillRect470* @see java.awt.Graphics#clearRect471* @since 1.0472*/473public void fillRect(int x, int y, int width, int height) {474mGraphics.fillRect(x, y, width, height);475}476477/**478* Clears the specified rectangle by filling it with the background479* color of the current drawing surface. This operation does not480* use the current paint mode.481* <p>482* Beginning with Java 1.1, the background color483* of offscreen images may be system dependent. Applications should484* use {@code setColor} followed by {@code fillRect} to485* ensure that an offscreen image is cleared to a specific color.486* @param x the <i>x</i> coordinate of the rectangle to clear.487* @param y the <i>y</i> coordinate of the rectangle to clear.488* @param width the width of the rectangle to clear.489* @param height the height of the rectangle to clear.490* @see java.awt.Graphics#fillRect(int, int, int, int)491* @see java.awt.Graphics#drawRect492* @see java.awt.Graphics#setColor(java.awt.Color)493* @see java.awt.Graphics#setPaintMode494* @see java.awt.Graphics#setXORMode(java.awt.Color)495* @since 1.0496*/497public void clearRect(int x, int y, int width, int height) {498mGraphics.clearRect(x, y, width, height);499}500501/**502* Draws an outlined round-cornered rectangle using this graphics503* context's current color. The left and right edges of the rectangle504* are at {@code x} and <code>x + width</code>,505* respectively. The top and bottom edges of the rectangle are at506* {@code y} and <code>y + height</code>.507* @param x the <i>x</i> coordinate of the rectangle to be drawn.508* @param y the <i>y</i> coordinate of the rectangle to be drawn.509* @param width the width of the rectangle to be drawn.510* @param height the height of the rectangle to be drawn.511* @param arcWidth the horizontal diameter of the arc512* at the four corners.513* @param arcHeight the vertical diameter of the arc514* at the four corners.515* @see java.awt.Graphics#fillRoundRect516* @since 1.0517*/518public void drawRoundRect(int x, int y, int width, int height,519int arcWidth, int arcHeight) {520mGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);521}522523/**524* Fills the specified rounded corner rectangle with the current color.525* The left and right edges of the rectangle526* are at {@code x} and <code>x + width - 1</code>,527* respectively. The top and bottom edges of the rectangle are at528* {@code y} and <code>y + height - 1</code>.529* @param x the <i>x</i> coordinate of the rectangle to be filled.530* @param y the <i>y</i> coordinate of the rectangle to be filled.531* @param width the width of the rectangle to be filled.532* @param height the height of the rectangle to be filled.533* @param arcWidth the horizontal diameter534* of the arc at the four corners.535* @param arcHeight the vertical diameter536* of the arc at the four corners.537* @see java.awt.Graphics#drawRoundRect538* @since 1.0539*/540public void fillRoundRect(int x, int y, int width, int height,541int arcWidth, int arcHeight) {542mGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);543}544545/**546* Draws the outline of an oval.547* The result is a circle or ellipse that fits within the548* rectangle specified by the {@code x}, {@code y},549* {@code width}, and {@code height} arguments.550* <p>551* The oval covers an area that is552* <code>width + 1</code> pixels wide553* and <code>height + 1</code> pixels tall.554* @param x the <i>x</i> coordinate of the upper left555* corner of the oval to be drawn.556* @param y the <i>y</i> coordinate of the upper left557* corner of the oval to be drawn.558* @param width the width of the oval to be drawn.559* @param height the height of the oval to be drawn.560* @see java.awt.Graphics#fillOval561* @since 1.0562*/563public void drawOval(int x, int y, int width, int height) {564mGraphics.drawOval(x, y, width, height);565}566567/**568* Fills an oval bounded by the specified rectangle with the569* current color.570* @param x the <i>x</i> coordinate of the upper left corner571* of the oval to be filled.572* @param y the <i>y</i> coordinate of the upper left corner573* of the oval to be filled.574* @param width the width of the oval to be filled.575* @param height the height of the oval to be filled.576* @see java.awt.Graphics#drawOval577* @since 1.0578*/579public void fillOval(int x, int y, int width, int height) {580mGraphics.fillOval(x, y, width, height);581}582583/**584* Draws the outline of a circular or elliptical arc585* covering the specified rectangle.586* <p>587* The resulting arc begins at {@code startAngle} and extends588* for {@code arcAngle} degrees, using the current color.589* Angles are interpreted such that 0 degrees590* is at the 3 o'clock position.591* A positive value indicates a counter-clockwise rotation592* while a negative value indicates a clockwise rotation.593* <p>594* The center of the arc is the center of the rectangle whose origin595* is (<i>x</i>, <i>y</i>) and whose size is specified by the596* {@code width} and {@code height} arguments.597* <p>598* The resulting arc covers an area599* <code>width + 1</code> pixels wide600* by <code>height + 1</code> pixels tall.601* @param x the <i>x</i> coordinate of the602* upper-left corner of the arc to be drawn.603* @param y the <i>y</i> coordinate of the604* upper-left corner of the arc to be drawn.605* @param width the width of the arc to be drawn.606* @param height the height of the arc to be drawn.607* @param startAngle the beginning angle.608* @param arcAngle the angular extent of the arc,609* relative to the start angle.610* @see java.awt.Graphics#fillArc611* @since 1.0612*/613public void drawArc(int x, int y, int width, int height,614int startAngle, int arcAngle) {615mGraphics.drawArc(x, y, width, height, startAngle, arcAngle);616}617618/**619* Fills a circular or elliptical arc covering the specified rectangle.620* <p>621* The resulting arc begins at {@code startAngle} and extends622* for {@code arcAngle} degrees.623* Angles are interpreted such that 0 degrees624* is at the 3 o'clock position.625* A positive value indicates a counter-clockwise rotation626* while a negative value indicates a clockwise rotation.627* <p>628* The center of the arc is the center of the rectangle whose origin629* is (<i>x</i>, <i>y</i>) and whose size is specified by the630* {@code width} and {@code height} arguments.631* <p>632* The resulting arc covers an area633* <code>width + 1</code> pixels wide634* by <code>height + 1</code> pixels tall.635* @param x the <i>x</i> coordinate of the636* upper-left corner of the arc to be filled.637* @param y the <i>y</i> coordinate of the638* upper-left corner of the arc to be filled.639* @param width the width of the arc to be filled.640* @param height the height of the arc to be filled.641* @param startAngle the beginning angle.642* @param arcAngle the angular extent of the arc,643* relative to the start angle.644* @see java.awt.Graphics#drawArc645* @since 1.0646*/647public void fillArc(int x, int y, int width, int height,648int startAngle, int arcAngle) {649mGraphics.fillArc(x, y, width, height, startAngle, arcAngle);650}651652/**653* Draws a sequence of connected lines defined by654* arrays of <i>x</i> and <i>y</i> coordinates.655* Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.656* The figure is not closed if the first point657* differs from the last point.658* @param xPoints an array of <i>x</i> points659* @param yPoints an array of <i>y</i> points660* @param nPoints the total number of points661* @see java.awt.Graphics#drawPolygon(int[], int[], int)662* @since 1.1663*/664public void drawPolyline(int[] xPoints, int[] yPoints,665int nPoints) {666mGraphics.drawPolyline(xPoints, yPoints, nPoints);667}668669/**670* Draws a closed polygon defined by671* arrays of <i>x</i> and <i>y</i> coordinates.672* Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.673* <p>674* This method draws the polygon defined by {@code nPoint} line675* segments, where the first <code>nPoint - 1</code>676* line segments are line segments from677* <code>(xPoints[i - 1], yPoints[i - 1])</code>678* to <code>(xPoints[i], yPoints[i])</code>, for679* 1 ≤ <i>i</i> ≤ {@code nPoints}.680* The figure is automatically closed by drawing a line connecting681* the final point to the first point, if those points are different.682* @param xPoints a an array of {@code x} coordinates.683* @param yPoints a an array of {@code y} coordinates.684* @param nPoints a the total number of points.685* @see java.awt.Graphics#fillPolygon686* @see java.awt.Graphics#drawPolyline687* @since 1.0688*/689public void drawPolygon(int[] xPoints, int[] yPoints,690int nPoints) {691mGraphics.drawPolygon(xPoints, yPoints, nPoints);692}693694/**695* Fills a closed polygon defined by696* arrays of <i>x</i> and <i>y</i> coordinates.697* <p>698* This method draws the polygon defined by {@code nPoint} line699* segments, where the first <code>nPoint - 1</code>700* line segments are line segments from701* <code>(xPoints[i - 1], yPoints[i - 1])</code>702* to <code>(xPoints[i], yPoints[i])</code>, for703* 1 ≤ <i>i</i> ≤ {@code nPoints}.704* The figure is automatically closed by drawing a line connecting705* the final point to the first point, if those points are different.706* <p>707* The area inside the polygon is defined using an708* even-odd fill rule, also known as the alternating rule.709* @param xPoints a an array of {@code x} coordinates.710* @param yPoints a an array of {@code y} coordinates.711* @param nPoints a the total number of points.712* @see java.awt.Graphics#drawPolygon(int[], int[], int)713* @since 1.0714*/715public void fillPolygon(int[] xPoints, int[] yPoints,716int nPoints) {717mGraphics.fillPolygon(xPoints, yPoints, nPoints);718}719720/**721* Draws the text given by the specified string, using this722* graphics context's current font and color. The baseline of the723* first character is at position (<i>x</i>, <i>y</i>) in this724* graphics context's coordinate system.725* @param str the string to be drawn.726* @param x the <i>x</i> coordinate.727* @param y the <i>y</i> coordinate.728* @see java.awt.Graphics#drawBytes729* @see java.awt.Graphics#drawChars730* @since 1.0731*/732public void drawString(String str, int x, int y) {733mGraphics.drawString(str, x, y);734}735736/**737* Draws the text given by the specified iterator, using this738* graphics context's current color. The iterator has to specify a font739* for each character. The baseline of the740* first character is at position (<i>x</i>, <i>y</i>) in this741* graphics context's coordinate system.742* The rendering attributes applied include the clip, transform,743* paint or color, and composite attributes.744* For characters in script systems such as Hebrew and Arabic,745* the glyphs may be draw from right to left, in which case the746* coordinate supplied is the location of the leftmost character747* on the baseline.748* @param iterator the iterator whose text is to be drawn749* @param x,y the coordinates where the iterator's text should be drawn.750* @see #setPaint751* @see java.awt.Graphics#setColor752* @see #setTransform753* @see #setComposite754* @see #setClip755*/756public void drawString(AttributedCharacterIterator iterator,757int x, int y) {758mGraphics.drawString(iterator, x, y);759}760761/**762* Draws the text given by the specified iterator, using this763* graphics context's current color. The iterator has to specify a font764* for each character. The baseline of the765* first character is at position (<i>x</i>, <i>y</i>) in this766* graphics context's coordinate system.767* The rendering attributes applied include the clip, transform,768* paint or color, and composite attributes.769* For characters in script systems such as Hebrew and Arabic,770* the glyphs may be draw from right to left, in which case the771* coordinate supplied is the location of the leftmost character772* on the baseline.773* @param iterator the iterator whose text is to be drawn774* @param x,y the coordinates where the iterator's text should be drawn.775* @see #setPaint776* @see java.awt.Graphics#setColor777* @see #setTransform778* @see #setComposite779* @see #setClip780*/781public void drawString(AttributedCharacterIterator iterator,782float x, float y) {783mGraphics.drawString(iterator, x, y);784}785786/**787* Draws as much of the specified image as is currently available.788* The image is drawn with its top-left corner at789* (<i>x</i>, <i>y</i>) in this graphics context's coordinate790* space. Transparent pixels in the image do not affect whatever791* pixels are already there.792* <p>793* This method returns immediately in all cases, even if the794* complete image has not yet been loaded, and it has not been dithered795* and converted for the current output device.796* <p>797* If the image has not yet been completely loaded, then798* {@code drawImage} returns {@code false}. As more of799* the image becomes available, the process that draws the image notifies800* the specified image observer.801* @param img the specified image to be drawn.802* @param x the <i>x</i> coordinate.803* @param y the <i>y</i> coordinate.804* @param observer object to be notified as more of805* the image is converted.806* @see java.awt.Image807* @see java.awt.image.ImageObserver808* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)809* @since 1.0810*/811public boolean drawImage(Image img, int x, int y,812ImageObserver observer) {813814return mGraphics.drawImage(img, x, y, observer);815}816817/**818* Draws as much of the specified image as has already been scaled819* to fit inside the specified rectangle.820* <p>821* The image is drawn inside the specified rectangle of this822* graphics context's coordinate space, and is scaled if823* necessary. Transparent pixels do not affect whatever pixels824* are already there.825* <p>826* This method returns immediately in all cases, even if the827* entire image has not yet been scaled, dithered, and converted828* for the current output device.829* If the current output representation is not yet complete, then830* {@code drawImage} returns {@code false}. As more of831* the image becomes available, the process that draws the image notifies832* the image observer by calling its {@code imageUpdate} method.833* <p>834* A scaled version of an image will not necessarily be835* available immediately just because an unscaled version of the836* image has been constructed for this output device. Each size of837* the image may be cached separately and generated from the original838* data in a separate image production sequence.839* @param img the specified image to be drawn.840* @param x the <i>x</i> coordinate.841* @param y the <i>y</i> coordinate.842* @param width the width of the rectangle.843* @param height the height of the rectangle.844* @param observer object to be notified as more of845* the image is converted.846* @see java.awt.Image847* @see java.awt.image.ImageObserver848* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)849* @since 1.0850*/851public boolean drawImage(Image img, int x, int y,852int width, int height,853ImageObserver observer) {854855return mGraphics.drawImage(img, x, y, width, height, observer);856}857858/**859* Draws as much of the specified image as is currently available.860* The image is drawn with its top-left corner at861* (<i>x</i>, <i>y</i>) in this graphics context's coordinate862* space. Transparent pixels are drawn in the specified863* background color.864* <p>865* This operation is equivalent to filling a rectangle of the866* width and height of the specified image with the given color and then867* drawing the image on top of it, but possibly more efficient.868* <p>869* This method returns immediately in all cases, even if the870* complete image has not yet been loaded, and it has not been dithered871* and converted for the current output device.872* <p>873* If the image has not yet been completely loaded, then874* {@code drawImage} returns {@code false}. As more of875* the image becomes available, the process that draws the image notifies876* the specified image observer.877* @param img the specified image to be drawn.878* @param x the <i>x</i> coordinate.879* @param y the <i>y</i> coordinate.880* @param bgcolor the background color to paint under the881* non-opaque portions of the image.882* @param observer object to be notified as more of883* the image is converted.884* @see java.awt.Image885* @see java.awt.image.ImageObserver886* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)887* @since 1.0888*/889public boolean drawImage(Image img, int x, int y,890Color bgcolor,891ImageObserver observer) {892893if (img == null) {894return true;895}896897boolean result;898899if (needToCopyBgColorImage(img)) {900BufferedImage imageCopy = getBufferedImageCopy(img, bgcolor);901result = mGraphics.drawImage(imageCopy, x, y, null);902} else {903result = mGraphics.drawImage(img, x, y, bgcolor, observer);904}905906return result;907}908909/**910* Draws as much of the specified image as has already been scaled911* to fit inside the specified rectangle.912* <p>913* The image is drawn inside the specified rectangle of this914* graphics context's coordinate space, and is scaled if915* necessary. Transparent pixels are drawn in the specified916* background color.917* This operation is equivalent to filling a rectangle of the918* width and height of the specified image with the given color and then919* drawing the image on top of it, but possibly more efficient.920* <p>921* This method returns immediately in all cases, even if the922* entire image has not yet been scaled, dithered, and converted923* for the current output device.924* If the current output representation is not yet complete then925* {@code drawImage} returns {@code false}. As more of926* the image becomes available, the process that draws the image notifies927* the specified image observer.928* <p>929* A scaled version of an image will not necessarily be930* available immediately just because an unscaled version of the931* image has been constructed for this output device. Each size of932* the image may be cached separately and generated from the original933* data in a separate image production sequence.934* @param img the specified image to be drawn.935* @param x the <i>x</i> coordinate.936* @param y the <i>y</i> coordinate.937* @param width the width of the rectangle.938* @param height the height of the rectangle.939* @param bgcolor the background color to paint under the940* non-opaque portions of the image.941* @param observer object to be notified as more of942* the image is converted.943* @see java.awt.Image944* @see java.awt.image.ImageObserver945* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)946* @since 1.0947*/948public boolean drawImage(Image img, int x, int y,949int width, int height,950Color bgcolor,951ImageObserver observer) {952953if (img == null) {954return true;955}956957boolean result;958959if (needToCopyBgColorImage(img)) {960BufferedImage imageCopy = getBufferedImageCopy(img, bgcolor);961result = mGraphics.drawImage(imageCopy, x, y, width, height, null);962} else {963result = mGraphics.drawImage(img, x, y, width, height,964bgcolor, observer);965}966967return result;968}969970/**971* Draws as much of the specified area of the specified image as is972* currently available, scaling it on the fly to fit inside the973* specified area of the destination drawable surface. Transparent pixels974* do not affect whatever pixels are already there.975* <p>976* This method returns immediately in all cases, even if the977* image area to be drawn has not yet been scaled, dithered, and converted978* for the current output device.979* If the current output representation is not yet complete then980* {@code drawImage} returns {@code false}. As more of981* the image becomes available, the process that draws the image notifies982* the specified image observer.983* <p>984* This method always uses the unscaled version of the image985* to render the scaled rectangle and performs the required986* scaling on the fly. It does not use a cached, scaled version987* of the image for this operation. Scaling of the image from source988* to destination is performed such that the first coordinate989* of the source rectangle is mapped to the first coordinate of990* the destination rectangle, and the second source coordinate is991* mapped to the second destination coordinate. The subimage is992* scaled and flipped as needed to preserve those mappings.993* @param img the specified image to be drawn994* @param dx1 the <i>x</i> coordinate of the first corner of the995* destination rectangle.996* @param dy1 the <i>y</i> coordinate of the first corner of the997* destination rectangle.998* @param dx2 the <i>x</i> coordinate of the second corner of the999* destination rectangle.1000* @param dy2 the <i>y</i> coordinate of the second corner of the1001* destination rectangle.1002* @param sx1 the <i>x</i> coordinate of the first corner of the1003* source rectangle.1004* @param sy1 the <i>y</i> coordinate of the first corner of the1005* source rectangle.1006* @param sx2 the <i>x</i> coordinate of the second corner of the1007* source rectangle.1008* @param sy2 the <i>y</i> coordinate of the second corner of the1009* source rectangle.1010* @param observer object to be notified as more of the image is1011* scaled and converted.1012* @see java.awt.Image1013* @see java.awt.image.ImageObserver1014* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)1015* @since 1.11016*/1017public boolean drawImage(Image img,1018int dx1, int dy1, int dx2, int dy2,1019int sx1, int sy1, int sx2, int sy2,1020ImageObserver observer) {1021return mGraphics.drawImage(img, dx1, dy1, dx2, dy2,1022sx1, sy1, sx2, sy2,1023observer);1024}10251026/**1027* Draws as much of the specified area of the specified image as is1028* currently available, scaling it on the fly to fit inside the1029* specified area of the destination drawable surface.1030* <p>1031* Transparent pixels are drawn in the specified background color.1032* This operation is equivalent to filling a rectangle of the1033* width and height of the specified image with the given color and then1034* drawing the image on top of it, but possibly more efficient.1035* <p>1036* This method returns immediately in all cases, even if the1037* image area to be drawn has not yet been scaled, dithered, and converted1038* for the current output device.1039* If the current output representation is not yet complete then1040* {@code drawImage} returns {@code false}. As more of1041* the image becomes available, the process that draws the image notifies1042* the specified image observer.1043* <p>1044* This method always uses the unscaled version of the image1045* to render the scaled rectangle and performs the required1046* scaling on the fly. It does not use a cached, scaled version1047* of the image for this operation. Scaling of the image from source1048* to destination is performed such that the first coordinate1049* of the source rectangle is mapped to the first coordinate of1050* the destination rectangle, and the second source coordinate is1051* mapped to the second destination coordinate. The subimage is1052* scaled and flipped as needed to preserve those mappings.1053* @param img the specified image to be drawn1054* @param dx1 the <i>x</i> coordinate of the first corner of the1055* destination rectangle.1056* @param dy1 the <i>y</i> coordinate of the first corner of the1057* destination rectangle.1058* @param dx2 the <i>x</i> coordinate of the second corner of the1059* destination rectangle.1060* @param dy2 the <i>y</i> coordinate of the second corner of the1061* destination rectangle.1062* @param sx1 the <i>x</i> coordinate of the first corner of the1063* source rectangle.1064* @param sy1 the <i>y</i> coordinate of the first corner of the1065* source rectangle.1066* @param sx2 the <i>x</i> coordinate of the second corner of the1067* source rectangle.1068* @param sy2 the <i>y</i> coordinate of the second corner of the1069* source rectangle.1070* @param bgcolor the background color to paint under the1071* non-opaque portions of the image.1072* @param observer object to be notified as more of the image is1073* scaled and converted.1074* @see java.awt.Image1075* @see java.awt.image.ImageObserver1076* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)1077* @since 1.11078*/1079public boolean drawImage(Image img,1080int dx1, int dy1, int dx2, int dy2,1081int sx1, int sy1, int sx2, int sy2,1082Color bgcolor,1083ImageObserver observer) {10841085if (img == null) {1086return true;1087}10881089boolean result;1090if (needToCopyBgColorImage(img)) {1091BufferedImage imageCopy = getBufferedImageCopy(img, bgcolor);1092result = mGraphics.drawImage(imageCopy,1093dx1, dy1, dx2, dy2,1094sy1, sy1, sx2, sy2,1095null);1096} else {1097result = mGraphics.drawImage(img,1098dx1, dy1, dx2, dy2,1099sy1, sy1, sx2, sy2,1100bgcolor,1101observer);1102}11031104return result;1105}11061107/**1108* Return true if drawing {@code img} will1109* invoke a Java2D bug (#4258675). The bug in question1110* occurs when a draw image call with a background color1111* parameter tries to render a sheared1112* or rotated image. The portions of the bounding1113* rectangle not covered by the sheared image1114* are incorrectly drawn with the background color.1115*/1116private boolean needToCopyBgColorImage(Image img) {11171118boolean needToCopy;11191120AffineTransform transform = getTransform();11211122return (transform.getType()1123& (AffineTransform.TYPE_GENERAL_ROTATION1124| AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0;1125}11261127/**1128* Return a new {@code BufferedImage}1129* that contains a copy of the provided1130* {@code Image} where its1131* transparent pixels have been replaced by1132* {@code bgcolor}. If the new1133* {@code BufferedImage} can not be created,1134* probably because the original image has not1135* finished loading, then {@code null} is1136* returned.1137*/1138private BufferedImage getBufferedImageCopy(Image img, Color bgcolor) {11391140BufferedImage imageCopy = null;11411142int width = img.getWidth(null);1143int height = img.getHeight(null);11441145if (width > 0 && height > 0) {11461147int imageType;11481149/* Try to minimize the depth of the BufferedImage1150* we are about to create by, if possible, making1151* it the same depth as the original image.1152*/1153if (img instanceof BufferedImage) {1154BufferedImage bufImage = (BufferedImage) img;1155imageType = bufImage.getType();1156} else {1157imageType = BufferedImage.TYPE_INT_ARGB;1158}11591160imageCopy = new BufferedImage(width, height, imageType);11611162/* Copy the original image into the new buffer1163* without any transformations.1164* This will replace the transparent pixels1165* in the original with background color.1166*/1167Graphics g = imageCopy.createGraphics();1168g.drawImage(img, 0, 0, bgcolor, null);1169g.dispose();11701171/* We couldn't get the width or height of the image1172* so just return null.1173*/1174} else {1175imageCopy = null;1176}11771178return imageCopy;1179}11801181/**1182* Draws an image, applying a transform from image space into user space1183* before drawing.1184* The transformation from user space into device space is done with1185* the current transform in the Graphics2D.1186* The given transformation is applied to the image before the1187* transform attribute in the Graphics2D state is applied.1188* The rendering attributes applied include the clip, transform,1189* and composite attributes. Note that the result is1190* undefined, if the given transform is noninvertible.1191* @param img The image to be drawn.1192* @param xform The transformation from image space into user space.1193* @see #transform1194* @see #setTransform1195* @see #setComposite1196* @see #clip1197* @see #setClip1198*/1199public void drawRenderedImage(RenderedImage img,1200AffineTransform xform) {1201mGraphics.drawRenderedImage(img, xform);1202}1203120412051206public void drawRenderableImage(RenderableImage img,1207AffineTransform xform) {12081209if (img == null) {1210return;1211}12121213AffineTransform pipeTransform = getTransform();1214AffineTransform concatTransform = new AffineTransform(xform);1215concatTransform.concatenate(pipeTransform);1216AffineTransform reverseTransform;12171218RenderContext rc = new RenderContext(concatTransform);12191220try {1221reverseTransform = pipeTransform.createInverse();1222} catch (NoninvertibleTransformException nte) {1223rc = new RenderContext(pipeTransform);1224reverseTransform = new AffineTransform();1225}12261227RenderedImage rendering = img.createRendering(rc);1228drawRenderedImage(rendering,reverseTransform);1229}12301231/**1232* Disposes of this graphics context and releases1233* any system resources that it is using.1234* A {@code Graphics} object cannot be used after1235* {@code dispose} has been called.1236* <p>1237* When a Java program runs, a large number of {@code Graphics}1238* objects can be created within a short time frame.1239* Although the finalization process of the garbage collector1240* also disposes of the same system resources, it is preferable1241* to manually free the associated resources by calling this1242* method rather than to rely on a finalization process which1243* may not run to completion for a long period of time.1244* <p>1245* Graphics objects which are provided as arguments to the1246* {@code paint} and {@code update} methods1247* of components are automatically released by the system when1248* those methods return. For efficiency, programmers should1249* call {@code dispose} when finished using1250* a {@code Graphics} object only if it was created1251* directly from a component or another {@code Graphics} object.1252* @see java.awt.Graphics#finalize1253* @see java.awt.Component#paint1254* @see java.awt.Component#update1255* @see java.awt.Component#getGraphics1256* @see java.awt.Graphics#create1257* @since 1.01258*/1259public void dispose() {1260mGraphics.dispose();1261}12621263/**1264* Empty finalizer as no clean up needed here.1265*/1266@SuppressWarnings("deprecation")1267public void finalize() {1268}126912701271/* The Delegated Graphics2D Methods */12721273/**1274* Strokes the outline of a Shape using the settings of the current1275* graphics state. The rendering attributes applied include the1276* clip, transform, paint or color, composite and stroke attributes.1277* @param s The shape to be drawn.1278* @see #setStroke1279* @see #setPaint1280* @see java.awt.Graphics#setColor1281* @see #transform1282* @see #setTransform1283* @see #clip1284* @see #setClip1285* @see #setComposite1286*/1287public void draw(Shape s) {1288mGraphics.draw(s);1289}12901291/**1292* Draws an image, applying a transform from image space into user space1293* before drawing.1294* The transformation from user space into device space is done with1295* the current transform in the Graphics2D.1296* The given transformation is applied to the image before the1297* transform attribute in the Graphics2D state is applied.1298* The rendering attributes applied include the clip, transform,1299* and composite attributes. Note that the result is1300* undefined, if the given transform is noninvertible.1301* @param img The image to be drawn.1302* @param xform The transformation from image space into user space.1303* @param obs The image observer to be notified as more of the image1304* is converted.1305* @see #transform1306* @see #setTransform1307* @see #setComposite1308* @see #clip1309* @see #setClip1310*/1311public boolean drawImage(Image img,1312AffineTransform xform,1313ImageObserver obs) {13141315return mGraphics.drawImage(img, xform, obs);1316}13171318/**1319* Draws a BufferedImage that is filtered with a BufferedImageOp.1320* The rendering attributes applied include the clip, transform1321* and composite attributes. This is equivalent to:1322* <pre>1323* img1 = op.filter(img, null);1324* drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);1325* </pre>1326* @param op The filter to be applied to the image before drawing.1327* @param img The BufferedImage to be drawn.1328* @param x,y The location in user space where the image should be drawn.1329* @see #transform1330* @see #setTransform1331* @see #setComposite1332* @see #clip1333* @see #setClip1334*/1335public void drawImage(BufferedImage img,1336BufferedImageOp op,1337int x,1338int y) {13391340mGraphics.drawImage(img, op, x, y);1341}134213431344/**1345* Draws a string of text.1346* The rendering attributes applied include the clip, transform,1347* paint or color, font and composite attributes.1348* @param str The string to be drawn.1349* @param x,y The coordinates where the string should be drawn.1350* @see #setPaint1351* @see java.awt.Graphics#setColor1352* @see java.awt.Graphics#setFont1353* @see #transform1354* @see #setTransform1355* @see #setComposite1356* @see #clip1357* @see #setClip1358*/1359public void drawString(String str,1360float x,1361float y) {1362mGraphics.drawString(str, x, y);1363}13641365/**1366* Draws a GlyphVector.1367* The rendering attributes applied include the clip, transform,1368* paint or color, and composite attributes. The GlyphVector specifies1369* individual glyphs from a Font.1370* @param g The GlyphVector to be drawn.1371* @param x,y The coordinates where the glyphs should be drawn.1372* @see #setPaint1373* @see java.awt.Graphics#setColor1374* @see #transform1375* @see #setTransform1376* @see #setComposite1377* @see #clip1378* @see #setClip1379*/1380public void drawGlyphVector(GlyphVector g,1381float x,1382float y) {1383mGraphics.drawGlyphVector(g, x, y);1384}13851386/**1387* Fills the interior of a Shape using the settings of the current1388* graphics state. The rendering attributes applied include the1389* clip, transform, paint or color, and composite.1390* @see #setPaint1391* @see java.awt.Graphics#setColor1392* @see #transform1393* @see #setTransform1394* @see #setComposite1395* @see #clip1396* @see #setClip1397*/1398public void fill(Shape s) {1399mGraphics.fill(s);1400}14011402/**1403* Checks to see if the outline of a Shape intersects the specified1404* Rectangle in device space.1405* The rendering attributes taken into account include the1406* clip, transform, and stroke attributes.1407* @param rect The area in device space to check for a hit.1408* @param s The shape to check for a hit.1409* @param onStroke Flag to choose between testing the stroked or1410* the filled shape.1411* @return True if there is a hit, false otherwise.1412* @see #setStroke1413* @see #fill1414* @see #draw1415* @see #transform1416* @see #setTransform1417* @see #clip1418* @see #setClip1419*/1420public boolean hit(Rectangle rect,1421Shape s,1422boolean onStroke) {14231424return mGraphics.hit(rect, s, onStroke);1425}14261427/**1428* Sets the Composite in the current graphics state. Composite is used1429* in all drawing methods such as drawImage, drawString, draw,1430* and fill. It specifies how new pixels are to be combined with1431* the existing pixels on the graphics device in the rendering process.1432* @param comp The Composite object to be used for drawing.1433* @see java.awt.Graphics#setXORMode1434* @see java.awt.Graphics#setPaintMode1435* @see java.awt.AlphaComposite1436*/1437public void setComposite(Composite comp) {1438mGraphics.setComposite(comp);1439}144014411442/**1443* Sets the Paint in the current graphics state.1444* @param paint The Paint object to be used to generate color in1445* the rendering process.1446* @see java.awt.Graphics#setColor1447* @see java.awt.GradientPaint1448* @see java.awt.TexturePaint1449*/1450public void setPaint(Paint paint) {1451mGraphics.setPaint(paint);1452}14531454/**1455* Sets the Stroke in the current graphics state.1456* @param s The Stroke object to be used to stroke a Shape in1457* the rendering process.1458* @see java.awt.BasicStroke1459*/1460public void setStroke(Stroke s) {1461mGraphics.setStroke(s);1462}14631464/**1465* Sets the preferences for the rendering algorithms.1466* Hint categories include controls for rendering quality and1467* overall time/quality trade-off in the rendering process.1468* @param hintCategory The category of hint to be set.1469* @param hintValue The value indicating preferences for the specified1470* hint category.1471* @see RenderingHints1472*/1473public void setRenderingHint(Key hintCategory, Object hintValue) {1474mGraphics.setRenderingHint(hintCategory, hintValue);1475}14761477/**1478* Returns the preferences for the rendering algorithms.1479* @param hintCategory The category of hint to be set.1480* @return The preferences for rendering algorithms.1481* @see RenderingHints1482*/1483public Object getRenderingHint(Key hintCategory) {1484return mGraphics.getRenderingHint(hintCategory);1485}14861487/**1488* Sets the preferences for the rendering algorithms.1489* Hint categories include controls for rendering quality and1490* overall time/quality trade-off in the rendering process.1491* @param hints The rendering hints to be set1492* @see RenderingHints1493*/1494public void setRenderingHints(Map<?,?> hints) {1495mGraphics.setRenderingHints(hints);1496}14971498/**1499* Adds a number of preferences for the rendering algorithms.1500* Hint categories include controls for rendering quality and1501* overall time/quality trade-off in the rendering process.1502* @param hints The rendering hints to be set1503* @see RenderingHints1504*/1505public void addRenderingHints(Map<?,?> hints) {1506mGraphics.addRenderingHints(hints);1507}15081509/**1510* Gets the preferences for the rendering algorithms.1511* Hint categories include controls for rendering quality and1512* overall time/quality trade-off in the rendering process.1513* @see RenderingHints1514*/1515public RenderingHints getRenderingHints() {1516return mGraphics.getRenderingHints();1517}15181519/**1520* Composes a Transform object with the transform in this1521* Graphics2D according to the rule last-specified-first-applied.1522* If the currrent transform is Cx, the result of composition1523* with Tx is a new transform Cx'. Cx' becomes the current1524* transform for this Graphics2D.1525* Transforming a point p by the updated transform Cx' is1526* equivalent to first transforming p by Tx and then transforming1527* the result by the original transform Cx. In other words,1528* Cx'(p) = Cx(Tx(p)).1529* A copy of the Tx is made, if necessary, so further1530* modifications to Tx do not affect rendering.1531* @param Tx The Transform object to be composed with the current1532* transform.1533* @see #setTransform1534* @see AffineTransform1535*/1536public void transform(AffineTransform Tx) {1537mGraphics.transform(Tx);1538}15391540/**1541* Sets the Transform in the current graphics state.1542* @param Tx The Transform object to be used in the rendering process.1543* @see #transform1544* @see AffineTransform1545*/1546public void setTransform(AffineTransform Tx) {1547mGraphics.setTransform(Tx);1548}15491550/**1551* Returns the current Transform in the Graphics2D state.1552* @see #transform1553* @see #setTransform1554*/1555public AffineTransform getTransform() {1556return mGraphics.getTransform();1557}15581559/**1560* Returns the current Paint in the Graphics2D state.1561* @see #setPaint1562* @see java.awt.Graphics#setColor1563*/1564public Paint getPaint() {1565return mGraphics.getPaint();1566}15671568/**1569* Returns the current Composite in the Graphics2D state.1570* @see #setComposite1571*/1572public Composite getComposite() {1573return mGraphics.getComposite();1574}15751576/**1577* Sets the background color in this context used for clearing a region.1578* When Graphics2D is constructed for a component, the backgroung color is1579* inherited from the component. Setting the background color in the1580* Graphics2D context only affects the subsequent clearRect() calls and1581* not the background color of the component. To change the background1582* of the component, use appropriate methods of the component.1583* @param color The background color that should be used in1584* subsequent calls to clearRect().1585* @see #getBackground1586* @see Graphics#clearRect1587*/1588public void setBackground(Color color) {1589mGraphics.setBackground(color);1590}15911592/**1593* Returns the background color used for clearing a region.1594* @see #setBackground1595*/1596public Color getBackground() {1597return mGraphics.getBackground();1598}15991600/**1601* Returns the current Stroke in the Graphics2D state.1602* @see #setStroke1603*/1604public Stroke getStroke() {1605return mGraphics.getStroke();1606}16071608/**1609* Intersects the current clip with the interior of the specified Shape1610* and sets the current clip to the resulting intersection.1611* The indicated shape is transformed with the current transform in the1612* Graphics2D state before being intersected with the current clip.1613* This method is used to make the current clip smaller.1614* To make the clip larger, use any setClip method.1615* @param s The Shape to be intersected with the current clip.1616*/1617public void clip(Shape s) {1618mGraphics.clip(s);1619}1620}162116221623