abstract class MultipleGradientPaintContext
extends java.lang.Object
implements java.awt.PaintContext
Modifier and Type | Field and Description |
---|---|
protected float |
a00
Elements of the inverse transform matrix.
|
protected float |
a01
Elements of the inverse transform matrix.
|
protected float |
a02
Elements of the inverse transform matrix.
|
protected float |
a10
Elements of the inverse transform matrix.
|
protected float |
a11
Elements of the inverse transform matrix.
|
protected float |
a12
Elements of the inverse transform matrix.
|
protected static java.lang.ref.WeakReference |
cached
The cached raster, which is reusable among instances
|
protected static java.awt.image.ColorModel |
cachedModel
The cached colorModel
|
protected MultipleGradientPaint.ColorSpaceEnum |
colorSpace
The colorSpace in which to perform the interpolation
|
protected MultipleGradientPaint.CycleMethodEnum |
cycleMethod
The method to use when painting out of the gradient bounds.
|
protected java.awt.image.ColorModel |
dataModel
The color model data is generated in (always un premult).
|
protected static boolean |
DEBUG |
protected int |
fastGradientArraySize
Size of gradients array for scaling the 0-1 index when looking up
colors the fast way.
|
protected float[] |
fractions
fractions array
|
protected int[] |
gradient
Array which contains the interpolated color values for each interval,
used by calculateSingleArrayGradient().
|
protected static int |
GRADIENT_SIZE
Constant number of max colors between any 2 arbitrary colors.
|
protected static int |
GRADIENT_SIZE_INDEX |
protected int |
gradientAverage
This holds the blend of all colors in the gradient.
|
protected int |
gradientOverflow
This holds the color to use when we are off the top of the
gradient
|
protected int[][] |
gradients
Array of gradient arrays, one array for each interval.
|
protected int |
gradientsLength
Length of the 2D slow lookup gradients array.
|
protected int |
gradientUnderflow
This holds the color to use when we are off the bottom of the
gradient
|
protected boolean |
hasDiscontinuity
This boolean indicates if the gradient appears to have sudden
discontinuities in it, this may be because of multiple stops
at the same location or use of the REPEATE mode.
|
protected boolean |
isSimpleLookup
This boolean specifies wether we are in simple lookup mode, where an
input value between 0 and 1 may be used to directly index into a single
array of gradient colors.
|
private static int[] |
LinearRGBtoSRGB |
private static java.awt.image.ColorModel |
lrgbmodel_A
Color model used if some gradient colors are transparent
|
private static java.awt.image.ColorModel |
lrgbmodel_NA
Color model used if gradient colors are all opaque
|
private static int |
MAX_GRADIENT_ARRAY_SIZE
Maximum length of the fast single-array.
|
protected java.awt.image.ColorModel |
model
PaintContext's output ColorModel ARGB if colors are not all
opaque, RGB otherwise.
|
protected float[] |
normalizedIntervals
Normalized intervals array
|
protected java.awt.image.WritableRaster |
saved
Raster is reused whenever possible
|
private static java.awt.image.ColorModel |
srgbmodel_A |
private static java.awt.image.ColorModel |
srgbmodel_NA |
private static int[] |
SRGBtoLinearRGB
Colorspace conversion lookup tables
|
private int |
transparencyTest
Used to determine if gradient colors are all opaque
|
Modifier | Constructor and Description |
---|---|
protected |
MultipleGradientPaintContext(java.awt.image.ColorModel cm,
java.awt.Rectangle deviceBounds,
java.awt.geom.Rectangle2D userBounds,
java.awt.geom.AffineTransform t,
java.awt.RenderingHints hints,
float[] fractions,
java.awt.Color[] colors,
MultipleGradientPaint.CycleMethodEnum cycleMethod,
MultipleGradientPaint.ColorSpaceEnum colorSpace)
Constructor for superclass.
|
Modifier and Type | Method and Description |
---|---|
protected void |
calculateGradientFractions(java.awt.Color[] loColors,
java.awt.Color[] hiColors)
This function is the meat of this class.
|
private void |
calculateMultipleArrayGradient(java.awt.Color[] loColors,
java.awt.Color[] hiColors)
SLOW LOOKUP METHOD
This method calculates the gradient color values for each interval and
places each into its own 255 size array.
|
private void |
calculateSingleArrayGradient(java.awt.Color[] loColors,
java.awt.Color[] hiColors,
float Imin)
FAST LOOKUP METHOD
This method calculates the gradient color values and places them in a
single int array, gradient[].
|
private static int |
convertEntireColorLinearRGBtoSRGB(int rgb)
Yet another helper function.
|
private static int |
convertEntireColorSRGBtoLinearRGB(int rgb)
Yet another helper function.
|
private static int |
convertLinearRGBtoSRGB(int color)
Helper function to convert a color component in linear RGB space to
SRGB space.
|
private static int |
convertSRGBtoLinearRGB(int color)
Helper function to convert a color component in sRGB space to linear
RGB space.
|
void |
dispose()
Release the resources allocated for the operation.
|
protected abstract void |
fillRaster(int[] pixels,
int off,
int adjust,
int x,
int y,
int w,
int h)
Subclasses should implement this.
|
private int |
getAntiAlias(float p1,
boolean p1_up,
float p2,
boolean p2_up,
float sz,
float weight) |
protected static java.awt.image.WritableRaster |
getCachedRaster(java.awt.image.ColorModel cm,
int w,
int h)
Took this cacheRaster code from GradientPaint.
|
java.awt.image.ColorModel |
getColorModel()
Return the ColorModel of the output.
|
java.awt.image.Raster |
getRaster(int x,
int y,
int w,
int h)
Superclass getRaster...
|
protected int |
indexGradientAntiAlias(float position,
float sz)
Helper function to index into the gradients array.
|
protected int |
indexIntoGradientsArrays(float position)
Helper function to index into the gradients array.
|
private void |
interpolate(int rgb1,
int rgb2,
int[] output)
Yet another helper function.
|
private static java.awt.Color |
interpolateColor(int[] workTbl,
java.awt.Color inColor)
We assume, that we always generate valid colors.
|
protected static void |
putCachedRaster(java.awt.image.ColorModel cm,
java.awt.image.WritableRaster ras)
Took this cacheRaster code from GradientPaint.
|
protected static final boolean DEBUG
protected java.awt.image.ColorModel dataModel
protected java.awt.image.ColorModel model
private static java.awt.image.ColorModel lrgbmodel_NA
private static java.awt.image.ColorModel srgbmodel_NA
private static java.awt.image.ColorModel lrgbmodel_A
private static java.awt.image.ColorModel srgbmodel_A
protected static java.awt.image.ColorModel cachedModel
protected static java.lang.ref.WeakReference cached
protected java.awt.image.WritableRaster saved
protected MultipleGradientPaint.CycleMethodEnum cycleMethod
protected MultipleGradientPaint.ColorSpaceEnum colorSpace
protected float a00
protected float a01
protected float a10
protected float a11
protected float a02
protected float a12
protected boolean isSimpleLookup
protected boolean hasDiscontinuity
protected int fastGradientArraySize
protected int[] gradient
protected int[][] gradients
protected int gradientAverage
protected int gradientUnderflow
protected int gradientOverflow
protected int gradientsLength
protected float[] normalizedIntervals
protected float[] fractions
private int transparencyTest
private static final int[] SRGBtoLinearRGB
private static final int[] LinearRGBtoSRGB
protected static final int GRADIENT_SIZE
protected static final int GRADIENT_SIZE_INDEX
private static final int MAX_GRADIENT_ARRAY_SIZE
protected MultipleGradientPaintContext(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform t, java.awt.RenderingHints hints, float[] fractions, java.awt.Color[] colors, MultipleGradientPaint.CycleMethodEnum cycleMethod, MultipleGradientPaint.ColorSpaceEnum colorSpace) throws java.awt.geom.NoninvertibleTransformException
java.awt.geom.NoninvertibleTransformException
protected final void calculateGradientFractions(java.awt.Color[] loColors, java.awt.Color[] hiColors)
private static java.awt.Color interpolateColor(int[] workTbl, java.awt.Color inColor)
workTbl
- typically SRGBtoLinearRGBinColor
- the color to interpolateprivate void calculateSingleArrayGradient(java.awt.Color[] loColors, java.awt.Color[] hiColors, float Imin)
Imin
- the size of the smallest intervalprivate void calculateMultipleArrayGradient(java.awt.Color[] loColors, java.awt.Color[] hiColors)
private void interpolate(int rgb1, int rgb2, int[] output)
rgb1
- the start colorrgb2
- the end coloroutput
- the output array of colors... assuming this is not null or length 0.private static int convertEntireColorLinearRGBtoSRGB(int rgb)
private static int convertEntireColorSRGBtoLinearRGB(int rgb)
protected final int indexIntoGradientsArrays(float position)
position
- the unmanipulated position. want to map this into the
range 0 to 1protected final int indexGradientAntiAlias(float position, float sz)
position
- the unmanipulated position. want to map this into the
range 0 to 1sz
- the size in gradient space to average.private final int getAntiAlias(float p1, boolean p1_up, float p2, boolean p2_up, float sz, float weight)
private static int convertSRGBtoLinearRGB(int color)
private static int convertLinearRGBtoSRGB(int color)
public final java.awt.image.Raster getRaster(int x, int y, int w, int h)
getRaster
in interface java.awt.PaintContext
protected abstract void fillRaster(int[] pixels, int off, int adjust, int x, int y, int w, int h)
protected static final java.awt.image.WritableRaster getCachedRaster(java.awt.image.ColorModel cm, int w, int h)
protected static final void putCachedRaster(java.awt.image.ColorModel cm, java.awt.image.WritableRaster ras)
public final void dispose()
dispose
in interface java.awt.PaintContext
public final java.awt.image.ColorModel getColorModel()
getColorModel
in interface java.awt.PaintContext