| 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 int | cycleMethod
The method to use when painting out of the gradient bounds. |
| protected int | fastGradientArraySize
Size of gradients array for scaling the 0-1 index when looking up colors the fast way. |
| private float[] | fractions
Fractions array. |
| protected int[] | gradient
Array which contains the interpolated color values for each interval, used by calculateSingleArrayGradient(). |
| protected static final int | GRADIENT_SIZE
Constant number of max colors between any 2 arbitrary colors. |
| protected static final int | |
| private int[][] | gradients
Array of gradient arrays, one array for each interval. |
| protected boolean | isSimpleLookup
This boolean specifies whether 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 final int | MAX_GRADIENT_ARRAY_SIZE
Maximum length of the fast single-array. |
| private float[] | normalizedIntervals
Normalized intervals array. |
| private int | transparencyTest
Used to determine if gradient colors are all opaque. |
| Access | Constructor and Description |
|---|---|
| protected | MultipleGradientContext(Gradient mgp, BaseTransform t, float[] fractions, Color[] colors, int cycleMethod)
Constructor for MultipleGradientContext superclass. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | calculateMultipleArrayGradient(Color[] colors)
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(Color[] colors, float
the size of the smallest interval Imin)FAST LOOKUP METHOD This method calculates the gradient color values and places them in a single int array, gradient[]. |
| protected abstract void | |
| protected final int | Returns: integer color to displaythe unmanipulated position, which will be mapped
into the range 0 to 1 position)Helper function to index into the gradients array. |
| private void | interpolate(int
the start color rgb1, int the end color rgb2, int[] the output array of colors; must not be null output)Yet another helper function. |
| a00 | back to summary |
|---|---|
| protected float a00 Elements of the inverse transform matrix. | |
| a01 | back to summary |
|---|---|
| protected float a01 Elements of the inverse transform matrix. | |
| a02 | back to summary |
|---|---|
| protected float a02 Elements of the inverse transform matrix. | |
| a10 | back to summary |
|---|---|
| protected float a10 Elements of the inverse transform matrix. | |
| a11 | back to summary |
|---|---|
| protected float a11 Elements of the inverse transform matrix. | |
| a12 | back to summary |
|---|---|
| protected float a12 Elements of the inverse transform matrix. | |
| cycleMethod | back to summary |
|---|---|
| protected int cycleMethod The method to use when painting out of the gradient bounds. | |
| fastGradientArraySize | back to summary |
|---|---|
| protected int fastGradientArraySize Size of gradients array for scaling the 0-1 index when looking up colors the fast way. | |
| fractions | back to summary |
|---|---|
| private float[] fractions Fractions array. | |
| gradient | back to summary |
|---|---|
| protected int[] gradient Array which contains the interpolated color values for each interval, used by calculateSingleArrayGradient(). It is protected for possible direct access by subclasses. | |
| GRADIENT_SIZE | back to summary |
|---|---|
| protected static final int GRADIENT_SIZE Constant number of max colors between any 2 arbitrary colors. Used for creating and indexing gradients arrays. | |
| GRADIENT_SIZE_INDEX | back to summary |
|---|---|
| protected static final int GRADIENT_SIZE_INDEX | |
| gradients | back to summary |
|---|---|
| private int[][] gradients Array of gradient arrays, one array for each interval. Used by calculateMultipleArrayGradient(). | |
| isSimpleLookup | back to summary |
|---|---|
| protected boolean isSimpleLookup This boolean specifies whether 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. If this boolean value is false, then we have to use a 2-step process where we have to determine which gradient array we fall into, then determine the index into that array. | |
| MAX_GRADIENT_ARRAY_SIZE | back to summary |
|---|---|
| private static final int MAX_GRADIENT_ARRAY_SIZE Maximum length of the fast single-array. If the estimated array size is greater than this, switch over to the slow lookup method. No particular reason for choosing this number, but it seems to provide satisfactory performance for the common case (fast lookup). | |
| normalizedIntervals | back to summary |
|---|---|
| private float[] normalizedIntervals Normalized intervals array. | |
| transparencyTest | back to summary |
|---|---|
| private int transparencyTest Used to determine if gradient colors are all opaque. | |
| MultipleGradientContext | back to summary |
|---|---|
| protected MultipleGradientContext(Gradient mgp, BaseTransform t, float[] fractions, Color[] colors, int cycleMethod) Constructor for MultipleGradientContext superclass. | |
| calculateLookupData | back to summary |
|---|---|
| private void calculateLookupData(Color[] colors) This function is the meat of this class. It calculates an array of gradient colors based on an array of fractions and color values at those fractions. | |
| calculateMultipleArrayGradient | back to summary |
|---|---|
| private void calculateMultipleArrayGradient(Color[] colors) SLOW LOOKUP METHOD This method calculates the gradient color values for each interval and places each into its own 255 size array. The arrays are stored in gradients[][]. (255 is used because this is the maximum number of unique colors between 2 arbitrary colors in a 24 bit color system.) This method uses the minimum amount of space (only 255 * number of intervals), but it aggravates the lookup procedure, because now we have to find out which interval to select, then calculate the index within that interval. This causes a significant performance hit, because it requires this calculation be done for every point in the rendering loop. For those of you who are interested, this is a classic example of the time-space tradeoff. | |
| calculateSingleArrayGradient | back to summary |
|---|---|
| private void calculateSingleArrayGradient(Color[] colors, float Imin) FAST LOOKUP METHOD This method calculates the gradient color values and places them in a single int array, gradient[]. It does this by allocating space for each interval based on its size relative to the smallest interval in the array. The smallest interval is allocated 255 interpolated values (the maximum number of unique in-between colors in a 24 bit color system), and all other intervals are allocated size = (255 * the ratio of their size to the smallest interval). This scheme expedites a speedy retrieval because the colors are distributed along the array according to their user-specified distribution. All that is needed is a relative index from 0 to 1. The only problem with this method is that the possibility exists for the array size to balloon in the case where there is a disproportionately small gradient interval. In this case the other intervals will be allocated huge space, but much of that data is redundant. We thus need to use the space conserving scheme below.
| |
| fillRaster | back to summary |
|---|---|
| protected abstract void fillRaster(int[] pixels, int off, int adjust, int x, int y, int w, int h) | |
| indexIntoGradientsArrays | back to summary |
|---|---|
| protected final int indexIntoGradientsArrays(float position) Helper function to index into the gradients array. This is necessary because each interval has an array of colors with uniform size 255. However, the color intervals are not necessarily of uniform length, so a conversion is required.
| |
| interpolate | back to summary |
|---|---|
| private void interpolate(int rgb1, int rgb2, int[] output) Yet another helper function. This one linearly interpolates between 2 colors, filling up the output array.
| |