JSR-62 (Final)

java.awt
Class Graphics2D

java.lang.Object
  |
  +--java.awt.Graphics
        |
        +--java.awt.Graphics2D

public abstract class Graphics2D
extends Graphics

This Graphics2D class extends the Graphics class to provide more sophisticated control over graphics operations.

Default Rendering Attributes

The default values for the Graphics2D rendering attributes are:
Composite
The AlphaComposite.SRC_OVER rule.

Restrictions

Implementations of Graphics2D in this Profile exhibit certain restrictions, specifically:


Constructor Summary
protected Graphics2D()
          Constructs a new Graphics2D object.
 
Method Summary
abstract  Composite getComposite()
          Returns the current Composite in the Graphics2D context.
abstract  GraphicsConfiguration getDeviceConfiguration()
          Returns the device configuration associated with this Graphics2D.
abstract  void setComposite(Composite comp)
          Sets the Composite for the Graphics2D context.
 
Methods inherited from class java.awt.Graphics
clearRect, clipRect, copyArea, create, create, dispose, draw3DRect, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, fill3DRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getColor, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, toString, translate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graphics2D

protected Graphics2D()
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, created by a Component, or obtained from images such as BufferedImage objects.

See Also:
Component.getGraphics(), Graphics.create()
Method Detail

getDeviceConfiguration

public abstract GraphicsConfiguration getDeviceConfiguration()
Returns the device configuration associated with this Graphics2D.


setComposite

public abstract void setComposite(Composite comp)
Sets the Composite for the Graphics2D context. The 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 during the rendering process.

Note: This operation is subject to restriction in this Profile. If the Composite is a custom object rather than an instance of the AlphaComposite class then IllegalArgumentException is thrown.

Parameters:
comp - the Composite object to be used for rendering
Throws:
IllegalArgumentException - If comp is not an instance of AlphaComposite.
See Also:
AlphaComposite

getComposite

public abstract Composite getComposite()
Returns the current Composite in the Graphics2D context.

Returns:
the current Graphics2D Composite, which defines a compositing style.
See Also:
setComposite(java.awt.Composite)

JSR-62 (Final)

Java and Java 2D are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Copyright 1993 - 2002 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All Rights Reserved.
Use of this specification is subject to this license.