home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 32.4 KB | 843 lines |
- /*
- * @(#)Graphics2D.java 1.35 98/03/18
- *
- * Copyright 1996-1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- package java.awt;
-
- import java.awt.geom.AffineTransform;
- import java.awt.image.ImageObserver;
- import java.awt.image.BufferedImageOp;
- import java.awt.image.BufferedImage;
- import java.awt.image.RenderedImage;
- import java.util.Hashtable;
- import java.awt.image.renderable.RenderableImage;
- import java.awt.font.StyledString;
- import java.awt.font.GlyphSet;
- import java.awt.font.TextLayout;
- import java.util.Vector;
-
- /**
- * This is the fundamental class for 2D rendering in Java. This
- * class extends the original java.awt.Graphics class to provide
- * more sophisticated control over geometry, coordinate
- * transformation, color management, and text layout.
- *
- * <h2>Coordinate Spaces</h2>
- * All coordinates that are given to a Graphics2D object are treated
- * as being in a virtual coordinate system which is called the User
- * Coordinate Space, or User Space. The Graphics2D object contains
- * an AffineTransform object as part of its rendering state that defines
- * how to convert coordinates from this user space to coordinates
- * in the Device Coordinate Space, or Device Space.
- * <p>
- * Coordinates in device space usually refer to individual device pixels
- * and are aligned in the infinitely thin gaps between these pixels.
- * Some Graphics2D objects may be used to capture rendering operations
- * for storage into a graphics metafile for playback on a concrete
- * device of unknown physical resolution at a later time. Since the
- * resolution may not be known when the rendering operations are
- * captured, the Transform will be set up to transform user coordinates
- * to a virtual device space that typically approximates the expected
- * resolution of the target device, though further transformation may
- * need to be applied at playback time if the estimate is incorrect.
- * <p>
- * Some of the operations performed by the rendering attribute objects
- * may operate in the device space, but all methods that are defined
- * on the Graphics2D object work with user space coordinates.
- * <p>
- * The <a name="#deftransform">default transform</a> when a Graphics2D
- * object is created will be specified by the GraphicsConfiguration for
- * the target of the Graphics2D (a Component or Image).
- * This default transform will map the user space coordinate system
- * to screen and printer device coordinates such that the origin
- * maps to the upper left hand corner of the
- * target region of the device with increasing X coordinates extending
- * to the right and increasing Y coordinates extending downward.
- * The scaling of the default transform for screen devices will be set
- * to identity for screen devices.
- * The scaling of the default transform for printers and other high
- * resolution devices will be set to approximate 72 user space coordinates
- * per device inch.
- * For image buffers, the default transform will be the Identity transform.
- *
- * <h2>Rendering Outline</h2>
- * Rendering in the Java 2D API can be described by a 4-step conceptual process
- * controlled by the various rendering attributes in the Graphics2D object.
- * The renderer may optimize many of these steps, either by caching the
- * results for future calls, by collapsing multiple virtual steps into
- * a single operation, or by recognizing various attributes as common
- * simple cases that can be eliminated by modifying other parts of the
- * operation.
- * <p>
- * As a behavioral reference, the steps can be described in the following
- * way:
- * <ol>
- * <li>
- * Determine where to render. This step can be further broken down
- * according to the type of rendering operation as follows:
- * <br>
- * <b><a name="#rendershape">Shape operations</a></b>
- * <ol>
- * <li>
- * If the operation is a draw(Shape) operation, then the shape is converted
- * into a shape to fill using the
- * <a href=java.awt.Stroke.html#createStrokedShape>createStrokedShape()</a>
- * method on the current <a href=java.awt.Stroke.html>Stroke</a>.
- * <li>
- * The shape is transformed from user space to device space using the
- * current <a href=java.awt.geom.AffineTransform.html>Transform</a>.
- * <li>
- * The outline of the Shape is extracted using a
- * <a href=java.awt.geom.PathIterator.html>PathIterator</a> using the
- * <a href=java.awt.Shape.html#getPathIterator>Shape.getPathIterator()</a>
- * method.
- * <li>
- * If the Graphics2D object is not able to handle the curved segments
- * that a PathIterator object can return, then it may call the alternat
- * getPathIterator() method which flattens the shape.
- * </ol>
- * <b><a name=#rendertext>Text operations</a></b>
- * <ol>
- * <li>
- * The set of glyphs required to render the indicated string
- * are determined as follows:
- * <ul>
- * <li>
- * If the argument is a String, then the current
- * <a href=java.awt.Font.html>Font</a> is asked to convert the
- * Unicode characters in the String into a GlyphSet with whatever
- * basic layout algorithm the font implements.
- * <li>
- * If the argument is a
- * <a href=java.awt.font.StyledString.html>StyledString</a>,
- * the StyledString is asked to convert itself to a GlyphSet
- * according to its embedded font attributes. The StyledString
- * may implement more sophisticated glyph layout algorithms that
- * perform Unicode bi-directional layout adjustments automatically
- * for multiple fonts of differing writing directions.
- * <li>
- * If the argument is a
- * <a href=java.awt.font.GlyphSet.html>GlyphSet</a>, then the GlyphSet
- * object already contains the appropriate font-specific glyph codes
- * with explicit coordinates for the position of each glyph.
- * </ul>
- * <li>
- * The current Font is queried to obtain outlines for the indicated
- * glyphs. These outlines are treated as shapes in user space relative
- * to the position of each glyph that was determined in step 1.
- * <li>
- * The outline of the characters are filled as indicated above
- * under <a href="#rendershape">Shape operations</a>
- * </ol>
- * <b><a name=#renderimg>Image operations</a></b>
- * <ol>
- * <li>
- * The bounding box of the source image defines the region of interest
- * in a coordinate system local to the Image object, called Image Space.
- * <li>
- * If an optional transform is supplied to the
- * <a href="#drawImage(java.awt.Image, java.awt.geom.AffineTransform, java.awt.image.ImageObserver)">drawImage()</a>
- * method call, then this transform is used to transform the bounding
- * box from image space to user space, otherwise the bounding box is
- * treated as if it already was in user space.
- * <li>
- * The bounding box of the source image is then transformed from user
- * space into device space using the current transform of the Graphics2D.
- * Note that the result of transforming the bounding box will not
- * necessarily result in a rectangular region in device space and
- * for some custom transforms may not even result in a quadrilateral
- * region.
- * </ol>
- * <li>
- * Constrain the rendering operation to the current Clip. The clip
- * was originally specified by a shape in user space and was converted
- * into device space by the Transform in effect at the time it was
- * modified.
- * <li>
- * Determine what colors to render as the renderer scan converts the
- * associated shape in device space.
- * <ul>
- * <li>
- * For image operations, the colors are determined from the Image
- * object itself sampled according to the source to destination
- * coordinate mapping specified by the current transform and the
- * optional image transform.
- * <li>
- * For all other operations, the current
- * <a href=java.awt.Paint.html>Paint</a> or
- * <a href=java.awt.Color.html>Color</a> object is queried for a
- * <a href=java.awt.PaintContext.html>PaintContext</a> which specifies
- * what colors are to be rendered in device space.
- * </ul>
- * <li>
- * Apply the colors to the destination drawing surface using the current
- * <a href=java.awt.Composite.html>Composite</a> object.
- * </ol>
- *
- * <h2>Default values</h2>
- * The default values for the various rendering attributes are:
- * <dl compact>
- * <dt><i>Color</i>
- * <dd>The color of the Component.
- * <dt><i>Font</i>
- * <dd>The font of the Component.
- * <dt><i>Stroke</i>
- * <dd>A square pen with a linewidth of 1, no dashing, miter segment joins
- * and non-projecting end caps.
- * <dt><i>Transform</i>
- * <dd>The <a href="java.awt.GraphicsConfiguration#getDefaultTransform">default</a> for the
- * GraphicsConfiguration of the Component.
- * <dt><i>Composite</i>
- * <dd>The Porter-Duff
- * <a href=java.awt.AlphaComposite.html#SRC_OVER>Source Over
- * Destination</a> rule.
- * <dt><i>Clip</i>
- * <dd>No rendering clip, output is clipped to the Component
- * </dl>
- *
- * <h2>Rendering compatibility issue</h2>
- * The rendering model presented by the pre-Java 2D API Graphics class
- * was based on a pixelization model that specified that coordinates
- * were infinitely thin, lying between the pixels, and that drawing
- * operations were performed by dragging a one-pixel square Pen along
- * the path hanging down and to the right of the anchor point on the
- * path.
- * <p>
- * The behavior of these operations given the model presented here is
- * unclear if the current Stroke specifies a wide pen, or if there
- * is a non-identity Transform being applied.
- * <p>
- * That rendering model was consistent with the capabilities of most
- * of the existing class of platform renderers that needed to resolve
- * integer coordinates to a discrete pen that must fall completely on
- * a given number of pixels. Since the Java 2D API is capable of driving an
- * antialiasing renderer it no longer makes sense to choose a bias
- * direction for a wide pen since sub-pixel positioning of the pen
- * can be made visible to the user via the blending that occurs along
- * the edges of the traversal of the pen. It is thus, no longer true
- * that a 1-pixel wide pen must choose to fall on pixel N as opposed
- * to pixel N+1; it can now fall partially on both pixels.
- * <p>
- * When antialiasing is turned off with the ANTIALIAS_OFF hint, the
- * underlying renderer may still need to apply a bias in order to
- * resolve the conflict of which pixel to modify when the pen is
- * exactly straddling a pixel boundary (such as when it is drawn
- * along an integer coordinate in device space). But when
- * antialiasing is enabled, no biasing of the pen needs to occur
- * and so no bias should be explicitly specified by the rendering
- * model.
- * <p>
- * Thus, there remains the problem of how to define the operation of
- * the legacy rendering operations inherited from the Graphics class
- * to be compatible with existing rendering behavior and to be
- * predictable and unsurprising under all possible settings of the
- * latest rendering attributes.
- * <p>
- * To provide predictability we will define operations for all of the
- * legacy methods that map onto the more general draw(Shape) and fill(Shape)
- * methods. Such a specification will thus be clear how it extends
- * based on various settings of Stroke and Transform attributes,
- * and rendering hints.
- * <p>
- * To provide compatibility with previous rendering behavior it is
- * important to specify a definition that performs identically under
- * the default attribute settings. In particular, the default Stroke
- * is a <a href=java.awt.BasicStroke.html>BasicStroke</a>
- * with a width of 1 and no dashing, and the default
- * Transform for screen drawing is an Identity transform. Unfortunately,
- * the default antialiasing rendering hint is ANTIALIAS_DEFAULT which
- * may be enabled on some implementations and not on others. This
- * means that the definition of these operations needs to be invariant
- * under antialiasing.
- * <p>
- * We now define the following generalizations of the various legacy
- * methods which can be shown to be identical to the previously
- * specified behavior under the default attributes:
- * <ul>
- * <li>
- * For fill operations, which include fillRect, fillRoundRect, fillOval,
- * fillArc, fillPolygon, and clearRect, we could create a GeneralPath, gp,
- * that traverses the same integer coordinates and call:
- * <pre>
- * fill(gp);
- * </pre>
- * <li>
- * For draw operations, which include drawLine, drawRect, drawRoundRect,
- * drawOval, drawArc, drawPolyline, and drawPolygon, we could create a
- * GeneralPath, gp, that traverses the same integer coordinates and call:
- * <pre>
- * AffineTransform at = new AffineTransform(1f,0f,0f,1f,0.5f,0.5f);
- * draw(at.createTransformedShape(bp));
- * </pre>
- * <li>
- * The draw3DRect and fill3DRect methods were implemented in terms
- * of the drawLine and fillRect methods and their behavior is thus
- * extended as well.
- * </ul>
- * The existing Graphics class defined only the single setColor
- * method to control the color to be painted. Since the Java 2D API extends
- * the Color object to implement the new Paint interface, the existing
- * setColor method is now a convenience method for setting the current
- * Paint to a Color object. <tt>setColor(c)</tt> is thus equivalent to
- * <tt>setPaint(c)</tt>.
- * <p>
- * The existing Graphics class defined two methods for controlling
- * how colors were applied to the destination.
- * The setPaintMode() method will now be implemented as a convenience
- * method to set the default Composite, equivalent to
- * <tt>setComposite(new AlphaComposite(SRC_OVER))</tt>.
- * The setXORMode(Color xorcolor) method will now be implemented
- * as a convenience method to set a special Composite object which
- * ignores the Alpha components of source colors and sets the
- * destination color to the value:
- * <pre>
- * dstpixel = (PixelOf(srccolor) ^ PixelOf(xorcolor) ^ dstpixel);
- * </pre>
- *
- * @version 10-Feb-97
- * @author Jim Graham
- */
- public abstract class Graphics2D extends Graphics {
-
- /**
- * Antialiasing hint category.
- */
- public static final int ANTIALIASING = 0;
-
- /**
- * Rendering is done with antialiasing.
- */
- public static final int ANTIALIAS_ON = 1;
-
- /**
- * Rendering is done without antialiasing.
- */
- public static final int ANTIALIAS_OFF = 2;
-
- /**
- * Rendering is done with the platform default antialiasing mode.
- */
- public static final int ANTIALIAS_DEFAULT = 3;
-
- /**
- * Rendering hint category.
- */
- public static final int RENDERING = 1;
-
- /**
- * Appropriate rendering algorithms are chosen with a preference
- * for output speed.
- */
- public static final int RENDER_SPEED = 4;
-
- /**
- * Appropriate rendering algorithms are chosen with a preference
- * for output quality.
- */
- public static final int RENDER_QUALITY = 5;
-
- /**
- * The platform default algorithms are chosen for rendering.
- */
- public static final int RENDER_DEFAULT = 6;
-
- /**
- * Text antialiasing hint category. The values for this category
- * ANTIALIAS_ON, ANTIALIAS_OFF, ANTIALIAS_DEFAULT.
- */
- public static final int TEXT_ANTIALIASING = 2;
-
- /**
- * Constructs a new Graphics2D object. Since Graphics2D is an abstract
- * class, and since it must be customized by subclasses for different
- * output devices, Graphics2D objects cannot be created directly.
- * Instead, Graphics2D objects must be obtained from another Graphics2D
- * object or created by a Component.
- * @see java.awt.Component#getGraphics
- * @see java.awt.Graphics#create
- */
- protected Graphics2D() {
- }
-
- /**
- * Strokes the outline of a Shape using the settings of the current
- * graphics state. The rendering attributes applied include the
- * clip, transform, paint or color, composite and stroke attributes.
- * @param s The shape to be drawn.
- * @see #setStroke
- * @see #setPaint
- * @see java.awt.Graphics#setColor
- * @see #transform
- * @see #setTransform
- * @see #clip
- * @see #setClip
- * @see #setComposite
- */
- public abstract void draw(Shape s);
-
- /**
- * Draws an image, applying a transform from image space into user space
- * before drawing.
- * The transformation from user space into device space is done with
- * the current transform in the Graphics2D.
- * The given transformation is applied to the image before the
- * transform attribute in the Graphics2D state is applied.
- * The rendering attributes applied include the clip, transform,
- * and composite attributes. Note that the result is
- * undefined, if the given transform is noninvertible.
- * @param img The image to be drawn.
- * @param xform The transformation from image space into user space.
- * @param obs The image observer to be notified as more of the image
- * is converted.
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- */
- public abstract void drawImage(Image img,
- AffineTransform xform,
- ImageObserver obs);
-
- /**
- * Draws a BufferedImage that is filtered with a BufferedImageOp.
- * The rendering attributes applied include the clip, transform
- * and composite attributes. This is equivalent to:
- * <pre>
- * img1 = op.filter(img, null);
- * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
- * </pre>
- * @param op The filter to be applied to the image before drawing.
- * @param img The BufferedImage to be drawn.
- * @param x,y The location in user space where the image should be drawn.
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- */
- public abstract void drawImage(BufferedImage img,
- BufferedImageOp op,
- int x,
- int y);
-
- /**
- * Draws an image, applying a transform from image space into user space
- * before drawing.
- * The transformation from user space into device space is done with
- * the current transform in the Graphics2D.
- * The given transformation is applied to the image before the
- * transform attribute in the Graphics2D state is applied.
- * The rendering attributes applied include the clip, transform,
- * and composite attributes. Note that the result is
- * undefined, if the given transform is noninvertible.
- * @param img The image to be drawn.
- * @param xform The transformation from image space into user space.
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- */
- public abstract void drawRenderedImage(RenderedImage img,
- AffineTransform xform);
-
- public abstract void drawRenderableImage(RenderableImage img,
- AffineTransform xfrom,
- Hashtable renderHints,
- Hashtable renderHintsObserved);
-
- /**
- * Draws the text given by the specified string, using this
- * graphics context's current font and color. The baseline of the
- * first character is at position (<i>x</i>, <i>y</i>) in this
- * graphics context's coordinate system.
- * @param str the string to be drawn.
- * @param x the <i>x</i> coordinate.
- * @param y the <i>y</i> coordinate.
- * @see java.awt.Graphics#drawBytes
- * @see java.awt.Graphics#drawChars
- * @since JDK1.0
- */
- public abstract void drawString(String str, int x, int y);
-
- /**
- * Draws a string of text.
- * The rendering attributes applied include the clip, transform,
- * paint or color, font and composite attributes.
- * @param s The string to be drawn.
- * @param x,y The coordinates where the string should be drawn.
- * @see #setPaint
- * @see java.awt.Graphics#setColor
- * @see java.awt.Graphics#setFont
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- */
- public abstract void drawString(String s,
- float x,
- float y);
-
- /**
- * Draws a StyledString.
- * The rendering attributes applied include the clip, transform,
- * paint or color, and composite attributes. A Font is associated
- * with each character in the StyledString.
- * @param s The StyledString to be drawn.
- * @param x,y The coordinates where the StyledString should be drawn.
- * @see #setPaint
- * @see java.awt.Graphics#setColor
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- * @see Font
- */
- public abstract void drawString(StyledString s,
- float x,
- float y);
-
- /**
- * Draws a GlyphSet.
- * The rendering attributes applied include the clip, transform,
- * paint or color, and composite attributes. The glyphSet specifies
- * individual glyphs from a Font.
- * @param g The GlyphSet to be drawn.
- * @param x,y The coordinates where the glyphs should be drawn.
- * @see #setPaint
- * @see java.awt.Graphics#setColor
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- */
- public abstract void drawString(GlyphSet g,
- float x,
- float y);
-
- public abstract void drawString(TextLayout text, float x, float y);
- /**
- * Fills the interior of a Shape using the settings of the current
- * graphics state. The rendering attributes applied include the
- * clip, transform, paint or color, and composite.
- * @see #setPaint
- * @see java.awt.Graphics#setColor
- * @see #transform
- * @see #setTransform
- * @see #setComposite
- * @see #clip
- * @see #setClip
- */
- public abstract void fill(Shape s);
-
- /**
- * Checks to see if the outline of a Shape intersects the specified
- * Rectangle in device space.
- * The rendering attributes taken into account include the
- * clip, transform, and stroke attributes.
- * @param rect The area in device space to check for a hit.
- * @param s The shape to check for a hit.
- * @param onStroke Flag to choose between testing the stroked or
- * the filled shape.
- * @return True if there is a hit, false otherwise.
- * @see #setStroke
- * @see #fill
- * @see #draw
- * @see #transform
- * @see #setTransform
- * @see #clip
- * @see #setClip
- */
- public abstract boolean hit(Rectangle rect,
- Shape s,
- boolean onStroke);
-
- /**
- * Checks to see if the StyledString intersects the specified Rectangle
- * in device space.
- * The rendering attributes taken into account include the clip
- * and transform.
- * @param rect The area in device space to check for a hit.
- * @param s The StyledString to check for a hit.
- * @param x,y The coordinates where the StyledString should be
- * hit tested.
- * @return True if there is a hit, false otherwise.
- * @see #drawString(StyledString, float, float)
- * @see #transform
- * @see #setTransform
- * @see #clip
- * @see #setClip
- */
- public abstract boolean hitString(Rectangle rect,
- StyledString s,
- float x,
- float y);
-
- /**
- * Returns the device configuration associated with this Graphics2D.
- */
- public abstract GraphicsConfiguration getDeviceConfiguration();
-
- /**
- * Sets the Composite in the current graphics state. Composite is used
- * in all drawing methods such as drawImage, drawString, draw,
- * and fill. It specifies how new pixels are to be combined with
- * the existing pixels on the graphics device in the rendering process.
- * @param comp The Composite object to be used for drawing.
- * @see java.awt.Graphics#setXORMode
- * @see java.awt.Graphics#setPaintMode
- * @see AlphaComposite
- */
- public abstract void setComposite(Composite comp);
-
- /**
- * Sets the Paint in the current graphics state.
- * @param paint The Paint object to be used to generate color in
- * the rendering process.
- * @see java.awt.Graphics#setColor
- * @see GradientPaint
- * @see TexturePaint
- */
- public abstract void setPaint( Paint paint );
-
- /**
- * Sets the Stroke in the current graphics state.
- * @param s The Stroke object to be used to stroke a Shape in
- * the rendering process.
- * @see BasicStroke
- */
- public abstract void setStroke(Stroke s);
-
- /**
- * Sets the preferences for the rendering algorithms.
- * Hint categories include controls for rendering quality and
- * overall time/quality trade-off in the rendering process.
- * @param hintCategory The category of hint to be set. Possible values
- * are ANTIALIASING and RENDERING.
- * @param hintValue The value indicating preferences for the specified
- * hint category. Possible values for the ANTIALIASING category are
- * ANTIALIAS_ON, ANTIALIAS_OFF, ANTIALIAS_DEFAULT. Possible values for
- * the RENDERING hint are RENDER_SPEED, RENDER_QUALITY, RENDER_DEFAULT.
- * @see #ANTIALIASING
- * @see #RENDERING
- * @see #ANTIALIAS_ON
- * @see #ANTIALIAS_OFF
- * @see #ANTIALIAS_DEFAULT
- * @see #RENDER_SPEED
- * @see #RENDER_QUALITY
- * @see #RENDER_DEFAULT
- */
- public abstract void setRenderingHints(int hintCategory, int hintValue);
-
- /**
- * Returns the preferences for the rendering algorithms.
- * @param hintCategory The category of hint to be set. Possible values
- * are ANTIALIASING and RENDERING.
- * @return The preferences for rendering algorithms. Possible values for
- * the ANTIALIASING category are ANTIALIAS_ON, ANTIALIAS_OFF,
- * ANTIALIAS_DEFAULT. Possible values for the RENDERING hint are
- * RENDER_SPEED, RENDER_QUALITY, RENDER_DEFAULT.
- * @see #ANTIALIASING
- * @see #RENDERING
- * @see #ANTIALIAS_ON
- * @see #ANTIALIAS_OFF
- * @see #ANTIALIAS_DEFAULT
- * @see #RENDER_SPEED
- * @see #RENDER_QUALITY
- * @see #RENDER_DEFAULT
- */
- public abstract int getRenderingHints(int hintCategory);
-
- /**
- * Translates the origin of the graphics context to the point
- * (<i>x</i>, <i>y</i>) in the current coordinate system.
- * Modifies this graphics context so that its new origin corresponds
- * to the point (<i>x</i>, <i>y</i>) in this graphics context's
- * original coordinate system. All coordinates used in subsequent
- * rendering operations on this graphics context will be relative
- * to this new origin.
- * @param x the <i>x</i> coordinate.
- * @param y the <i>y</i> coordinate.
- * @since JDK1.0
- */
- public abstract void translate(int x, int y);
-
- /**
- * Concatenates the current transform of this Graphics2D with a
- * translation transformation.
- * This is equivalent to calling transform(T), where T is an
- * AffineTransform represented by the following matrix:
- * <pre>
- * [ 1 0 tx ]
- * [ 0 1 ty ]
- * [ 0 0 1 ]
- * </pre>
- */
- public abstract void translate(double tx, double ty);
-
- /**
- * Concatenates the current transform of this Graphics2D with a
- * rotation transformation.
- * This is equivalent to calling transform(R), where R is an
- * AffineTransform represented by the following matrix:
- * <pre>
- * [ cos(theta) -sin(theta) 0 ]
- * [ sin(theta) cos(theta) 0 ]
- * [ 0 0 1 ]
- * </pre>
- * Rotating with a positive angle theta rotates points on the positive
- * x axis toward the positive y axis.
- * @param theta The angle of rotation in radians.
- */
- public abstract void rotate(double theta);
-
- /**
- * Concatenates the current transform of this Graphics2D with a
- * translated rotation transformation.
- * This is equivalent to the following sequence of calls:
- * <pre>
- * translate(x, y);
- * rotate(theta);
- * translate(-x, -y);
- * </pre>
- * Rotating with a positive angle theta rotates points on the positive
- * x axis toward the positive y axis.
- * @param theta The angle of rotation in radians.
- * @param x The x coordinate of the origin of the rotation
- * @param y The x coordinate of the origin of the rotation
- */
- public abstract void rotate(double theta, double x, double y);
-
- /**
- * Concatenates the current transform of this Graphics2D with a
- * scaling transformation.
- * This is equivalent to calling transform(S), where S is an
- * AffineTransform represented by the following matrix:
- * <pre>
- * [ sx 0 0 ]
- * [ 0 sy 0 ]
- * [ 0 0 1 ]
- * </pre>
- */
- public abstract void scale(double sx, double sy);
-
- /**
- * Concatenates the current transform of this Graphics2D with a
- * shearing transformation.
- * This is equivalent to calling transform(SH), where SH is an
- * AffineTransform represented by the following matrix:
- * <pre>
- * [ 1 shx 0 ]
- * [ shy 1 0 ]
- * [ 0 0 1 ]
- * </pre>
- * @param shx The factor by which coordinates are shifted towards the
- * positive X axis direction according to their Y coordinate
- * @param shy The factor by which coordinates are shifted towards the
- * positive Y axis direction according to their X coordinate
- */
- public abstract void shear(double shx, double shy);
-
- /**
- * Composes an AffineTransform object with the transform in this
- * Graphics2D according to the rule last-specified-first-applied.
- * If the currrent transform is Cx, the result of composition
- * with Tx is a new transform Cx'. Cx' becomes the current
- * transform for this Graphics2D.
- * Transforming a point p by the updated transform Cx' is
- * equivalent to first transforming p by Tx and then transforming
- * the result by the original transform Cx. In other words,
- * Cx'(p) = Cx(Tx(p)).
- * A copy of the Tx is made, if necessary, so further
- * modifications to Tx do not affect rendering.
- * @param Tx The AffineTransform object to be composed with the current
- * transform.
- * @see #setTransform
- * @see TransformChain
- * @see AffineTransform
- */
- public abstract void transform(AffineTransform Tx);
-
- /**
- * Sets the transform in the current graphics state.
- * @param Tx The AffineTransform object to be used in the
- * rendering process.
- * @see #transform
- * @see TransformChain
- * @see AffineTransform
- */
- public abstract void setTransform(AffineTransform Tx);
-
- /**
- * Returns the current transform in the Graphics2D state.
- * @see #transform
- * @see #setTransform
- */
- public abstract AffineTransform getTransform();
-
- /**
- * Returns the current Paint in the Graphics2D state.
- * @see #setPaint
- * @see java.awt.Graphics#setColor
- */
- public abstract Paint getPaint();
-
- /**
- * Returns the current Composite in the Graphics2D state.
- * @see #setComposite
- */
- public abstract Composite getComposite();
-
- /**
- * Sets the background color in this context used for clearing a region.
- * When Graphics2D is constructed for a component, the backgroung color is
- * inherited from the component. Setting the background color in the
- * Graphics2D context only affects the subsequent clearRect() calls and
- * not the background color of the component. To change the background
- * of the component, use appropriate methods of the component.
- * @param color The background color that should be used in
- * subsequent calls to clearRect().
- * @see getBackground
- * @see Graphics.clearRect()
- */
- public abstract void setBackground(Color color);
-
- /**
- * Returns the background color used for clearing a region.
- * @see setBackground
- */
- public abstract Color getBackground();
-
- /**
- * Returns the current Stroke in the Graphics2D state.
- * @see setStroke
- */
- public abstract Stroke getStroke();
-
- /**
- * Intersects the current clip with the interior of the specified Shape
- * and sets the current clip to the resulting intersection.
- * The indicated shape is transformed with the current transform in the
- * Graphics2D state before being intersected with the current clip.
- * This method is used to make the current clip smaller.
- * To make the clip larger, use any setClip method.
- * @param s The Shape to be intersected with the current clip.
- */
- public abstract void clip(Shape s);
-
- }
-