APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt

public Class TexturePaint

extends Object
implements Paint
Class Inheritance
All Implemented Interfaces
java.awt.Paint, java.awt.Transparency
Imports
java.awt.geom.Rectangle2D, .AffineTransform, java.awt.image.BufferedImage, .ColorModel

The TexturePaint class provides a way to fill a Shape with a texture that is specified as a BufferedImage. The size of the BufferedImage object should be small because the BufferedImage data is copied by the TexturePaint object. At construction time, the texture is anchored to the upper left corner of a Rectangle2D that is specified in user space. Texture is computed for locations in the device space by conceptually replicating the specified Rectangle2D infinitely in all directions in user space and mapping the BufferedImage to each replicated Rectangle2D.
Version
1.48, 06/05/07
See Also
Paint, Graphics2D#setPaint

Field Summary

Modifier and TypeField and Description
pack-priv BufferedImage
pack-priv double
pack-priv double
pack-priv double
pack-priv double

Constructor Summary

AccessConstructor and Description
public
TexturePaint(BufferedImage
the BufferedImage object with the texture used for painting
txtr
,
Rectangle2D
the Rectangle2D in user space used to anchor and replicate the texture
anchor
)

Constructs a TexturePaint object.

Method Summary

Modifier and TypeMethod and Description
public PaintContext

Returns:

the PaintContext for generating color patterns.
createContext
(ColorModel
the preferred ColorModel which represents the most convenient format for the caller to receive the pixel data, or null if there is no preference.
cm
,
Rectangle
the device space bounding box of the graphics primitive being rendered.
deviceBounds
,
Rectangle2D
the user space bounding box of the graphics primitive being rendered.
userBounds
,
AffineTransform
the AffineTransform from user space into device space.
xform
,
RenderingHints
the set of hints that the context object can use to choose between rendering alternatives.
hints
)

Implements java.awt.Paint.createContext.

Creates and returns a PaintContext used to generate a tiled image pattern.

public Rectangle2D

Returns:

the Rectangle2D used to anchor and size this TexturePaint.
getAnchorRect
()

Returns a copy of the anchor rectangle which positions and sizes the textured image.

public BufferedImage

Returns:

a BufferedImage.
getImage
()

Returns the BufferedImage texture used to fill the shapes.

public int

Returns:

the transparency mode for this TexturePaint as an integer value.
getTransparency
()

Implements java.awt.Transparency.getTransparency.

Returns the transparency mode for this TexturePaint.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufImgback to summary
pack-priv BufferedImage bufImg
sxback to summary
pack-priv double sx
syback to summary
pack-priv double sy
txback to summary
pack-priv double tx
tyback to summary
pack-priv double ty

Constructor Detail

TexturePaintback to summary
public TexturePaint(BufferedImage txtr, Rectangle2D anchor)

Constructs a TexturePaint object.

Parameters
txtr:BufferedImage

the BufferedImage object with the texture used for painting

anchor:Rectangle2D

the Rectangle2D in user space used to anchor and replicate the texture

Method Detail

createContextback to summary
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)

Implements java.awt.Paint.createContext.

Creates and returns a PaintContext used to generate a tiled image pattern. See the specification of the method in the Paint interface for information on null parameter handling.

Parameters
cm:ColorModel

the preferred ColorModel which represents the most convenient format for the caller to receive the pixel data, or null if there is no preference.

deviceBounds:Rectangle

the device space bounding box of the graphics primitive being rendered.

userBounds:Rectangle2D

the user space bounding box of the graphics primitive being rendered.

xform:AffineTransform

the AffineTransform from user space into device space.

hints:RenderingHints

the set of hints that the context object can use to choose between rendering alternatives.

Returns:PaintContext

the PaintContext for generating color patterns.

See Also
Paint, PaintContext, ColorModel, Rectangle, Rectangle2D, AffineTransform, RenderingHints
getAnchorRectback to summary
public Rectangle2D getAnchorRect()

Returns a copy of the anchor rectangle which positions and sizes the textured image.

Returns:Rectangle2D

the Rectangle2D used to anchor and size this TexturePaint.

getImageback to summary
public BufferedImage getImage()

Returns the BufferedImage texture used to fill the shapes.

Returns:BufferedImage

a BufferedImage.

getTransparencyback to summary
public int getTransparency()

Implements java.awt.Transparency.getTransparency.

Returns the transparency mode for this TexturePaint.

Returns:int

the transparency mode for this TexturePaint as an integer value.

See Also
Transparency