public class GradientTexturePaint extends Objectimplements Paint
java.awt.TexturePaint.
This goes to extra lengths to reduce color banding more than Java's default gradient implementation, and is generally comparable in performance.
| Modifier and Type | Class and Description |
|---|---|
static class |
GradientTexturePaint
|
| Modifier and Type | Field and Description |
|---|---|
protected Color |
colors
|
protected GradientTexturePaint |
cycle
|
protected float[] |
fractions
|
protected boolean |
hasAlpha
|
protected boolean |
needsDiffusion
|
protected static boolean |
seedingEnabled
This is an advanced option only used for testing/debugging.
|
protected AffineTransform |
transform
|
protected float |
x1
|
protected float |
x2
|
protected float |
y1
|
protected float |
y2
|
BITMASK, OPAQUE, TRANSLUCENT| Constructor and Description |
|---|
GradientTexturePaint(Color
Creates a new
GradientTexturePaint.
|
GradientTexturePaint(Color
Creates a new
GradientTexturePaint.
|
GradientTexturePaint(float x1, float y1, Color
Create a 2-color gradient using
Cycle.NONE.
|
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
containsAlpha(Color
Return true if any of these colors are not opaque.
|
PaintContext |
createContext(ColorModel
|
Color |
getColors()
Return the colors in this gradient.
|
float[] |
getFractions()
Return the fractions in this gradient.
|
int |
getTransparency()
Return
Transparency.OPAQUE if all the colors in this gradient are opaque, otherwise this returns
Transparency.TRANSLUCENT.
|
static boolean |
needsDiffusion(Color
Return true if this combination of colors and fractions should apply error diffusion prevent
color banding.
|
protected static boolean seedingEnabled
protected Color[] colors
protected GradientTexturePaint.Cycle cycle
protected float[] fractions
protected boolean hasAlpha
protected boolean needsDiffusion
protected AffineTransformtransform
protected float x1
protected float y1
protected float x2
protected float y2
public GradientTexturePaint(float x1,
float y1,
Color c1,
float x2,
float y2,
Color c2)
Cycle.NONE.
x1 - the x-coordinate of first point
y1 - the y-coordinate of first point
c1 - the first color
x2 - the x-coordinate of second point
y2 - the y-coordinate of second point
c2 - the second color
public GradientTexturePaint(Color[] colors, float[] fractions, float x1, float y1, float x2, float y2, GradientTexturePaint .Cycle cycle)
GradientTexturePaint.
colors - the colors to use in this gradient.
fractions - the fractions to use in this gradient. These must be ascending fractions from [0,1]. Each fraction corresponds to a color.
x1 - the x-value of the first coordinate.
y1 - the y-value of the first coordinate.
x2 - the x-value of the second coordinate.
y2 - the y-value of the second coordinate.
cycle - TILE is recommended for best performance.
public GradientTexturePaint(Color[] colors, float[] fractions, Point2D p1, Point2D p2, GradientTexturePaint .Cycle cycle)
GradientTexturePaint.
colors - the colors to use in this gradient.
fractions - the fractions to use in this gradient. These must be ascending fractions from [0,1]. Each fraction corresponds to a color.
p1 - the first point.
p2 - the second point.
cycle - TILE is recommended for best performance.
protected static boolean containsAlpha(Color[] colors)
colors - the colors to check for alpha components
public static boolean needsDiffusion(Color[] colors, float[] fractions, float x1, float y1, float x2, float y2)
colors - the colors to use in this gradient.
fractions - the fractions to use in this gradient. These must be ascending fractions from [0,1]. Each fraction corresponds to a color.
x1 - the x-value of the first coordinate.
y1 - the y-value of the first coordinate.
x2 - the x-value of the second coordinate.
y2 - the y-value of the second coordinate.
public PaintContextcreateContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
public Color[] getColors()
public float[] getFractions()
public int getTransparency()
Transparency.OPAQUE if all the colors in this gradient are opaque, otherwise this returns
Transparency.TRANSLUCENT.
getTransparency in interface
Transparency