java.awt
Interface Paint

All Superinterfaces:
Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency
All Known Implementing Classes:
Color sample code for java.awt.Color definition code for java.awt.Color , ColorUIResource sample code for javax.swing.plaf.ColorUIResource definition code for javax.swing.plaf.ColorUIResource , GradientPaint sample code for java.awt.GradientPaint definition code for java.awt.GradientPaint , SystemColor sample code for java.awt.SystemColor definition code for java.awt.SystemColor , TexturePaint sample code for java.awt.TexturePaint definition code for java.awt.TexturePaint

public interface Paint
extends Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency

This Paint interface defines how color patterns can be generated for Graphics2D sample code for java.awt.Graphics2D definition code for java.awt.Graphics2D operations. A class implementing the Paint interface is added to the Graphics2D context in order to define the color pattern used by the draw and fill methods.

Instances of classes implementing Paint must be read-only because the Graphics2D does not clone these objects when they are set as an attribute with the setPaint method or when the Graphics2D object is itself cloned.

See Also:
PaintContext sample code for java.awt.PaintContext definition code for java.awt.PaintContext , Color sample code for java.awt.Color definition code for java.awt.Color , GradientPaint sample code for java.awt.GradientPaint definition code for java.awt.GradientPaint , TexturePaint sample code for java.awt.TexturePaint definition code for java.awt.TexturePaint , Graphics2D.setPaint(java.awt.Paint) sample code for java.awt.Graphics2D.setPaint(java.awt.Paint) definition code for java.awt.Graphics2D.setPaint(java.awt.Paint)

Field Summary
 
Fields inherited from interface java.awt.Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency
BITMASK sample code for java.awt.Transparency.BITMASK definition code for java.awt.Transparency.BITMASK , OPAQUE sample code for java.awt.Transparency.OPAQUE definition code for java.awt.Transparency.OPAQUE , TRANSLUCENT sample code for java.awt.Transparency.TRANSLUCENT definition code for java.awt.Transparency.TRANSLUCENT
 
Method Summary
 PaintContext sample code for java.awt.PaintContext definition code for java.awt.PaintContext createContext sample code for java.awt.Paint.createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints) definition code for java.awt.Paint.createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints) (ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  cm, Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  deviceBounds, Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D  userBounds, AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform  xform, RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  hints)
          Creates and returns a PaintContext sample code for java.awt.PaintContext definition code for java.awt.PaintContext used to generate the color pattern.
 
Methods inherited from interface java.awt.Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency
getTransparency sample code for java.awt.Transparency.getTransparency() definition code for java.awt.Transparency.getTransparency()
 

Method Detail

createContext sample code for java.awt.Paint.createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints) definition code for java.awt.Paint.createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints)

PaintContext sample code for java.awt.PaintContext definition code for java.awt.PaintContext  createContext(ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  cm,
                           Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  deviceBounds,
                           Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D  userBounds,
                           AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform  xform,
                           RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  hints)
Creates and returns a PaintContext sample code for java.awt.PaintContext definition code for java.awt.PaintContext used to generate the color pattern. Since the ColorModel argument to createContext is only a hint, implementations of Paint should accept a null argument for ColorModel. Note that if the application does not prefer a specific ColorModel, the null ColorModel argument will give the Paint implementation full leeway in using the most efficient ColorModel it prefers for its raster processing.

Since the API documentation was not specific about this in releases before 1.4, there may be implementations of Paint that do not accept a null ColorModel argument. If a developer is writing code which passes a null ColorModel argument to the createContext method of Paint objects from arbitrary sources it would be wise to code defensively by manufacturing a non-null ColorModel for those objects which throw a NullPointerException.

Parameters:
cm - the ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel that receives the Paint data. This is used only as a hint.
deviceBounds - the device space bounding box of the graphics primitive being rendered
userBounds - the user space bounding box of the graphics primitive being rendered
xform - the AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform from user space into device space
hints - the hint that the context object uses to choose between rendering alternatives
Returns:
the PaintContext for generating color patterns
See Also:
PaintContext sample code for java.awt.PaintContext definition code for java.awt.PaintContext