APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt

public abstract sealed Class MultipleGradientPaint

extends Object
implements Paint
permits LinearGradientPaint, RadialGradientPaint
Class Inheritance
All Implemented Interfaces
java.awt.Paint, java.awt.Transparency
Known Direct Subclasses
java.awt.RadialGradientPaint, java.awt.LinearGradientPaint
Imports
java.awt.geom.AffineTransform, java.awt.image.ColorModel, java.lang.ref.SoftReference, java.util.Arrays

This is the superclass for Paints which use a multiple color gradient to fill in their raster. It provides storage for variables and enumerated values common to LinearGradientPaint and RadialGradientPaint.
Author
Nicholas Talian, Vincent Hardy, Jim Graham, Jerry Evans
Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
MultipleGradientPaint.ColorSpaceType

The color space in which to perform the gradient interpolation.

public static enum
MultipleGradientPaint.CycleMethod

The method to use when painting outside the gradient bounds.

Field Summary

Modifier and TypeField and Description
pack-priv final Color[]
colors

Gradient colors.

pack-priv final MultipleGradientPaint.ColorSpaceType
colorSpace

The color space in which to perform the gradient interpolation.

pack-priv final MultipleGradientPaint.CycleMethod
cycleMethod

The method to use when painting outside the gradient bounds.

pack-priv int
pack-priv final float[]
fractions

Gradient keyframe values in the range 0 to 1.

pack-priv SoftReference<int[]>
pack-priv SoftReference<int[][]>
pack-priv final AffineTransform
gradientTransform

Transform to apply to gradient.

pack-priv boolean
pack-priv ColorModel
model

The following fields are used only by MultipleGradientPaintContext to cache certain values that remain constant and do not need to be recalculated for each context created from this paint instance.

pack-priv float[]
pack-priv final int
transparency

The transparency of this paint object.

Constructor Summary

AccessConstructor and Description
pack-priv
MultipleGradientPaint(float[]
numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient
fractions
,
Color[]
array of colors corresponding to each fractional value
colors
,
MultipleGradientPaint.CycleMethod
either NO_CYCLE, REFLECT, or REPEAT
cycleMethod
,
MultipleGradientPaint.ColorSpaceType
which color space to use for interpolation, either SRGB or LINEAR_RGB
colorSpace
,
AffineTransform
transform to apply to the gradient
gradientTransform
)

Package-private constructor.

Method Summary

Modifier and TypeMethod and Description
public final Color[]

Returns:

a copy of the array of colors used by this gradient
getColors
()

Returns a copy of the array of colors used by this gradient.

public final MultipleGradientPaint.ColorSpaceType

Returns:

the enumerated type which specifies color space for interpolation
getColorSpace
()

Returns the enumerated type which specifies color space for interpolation.

public final MultipleGradientPaint.CycleMethod

Returns:

the enumerated type which specifies cycling behavior
getCycleMethod
()

Returns the enumerated type which specifies cycling behavior.

public final float[]

Returns:

a copy of the array of floats used by this gradient to calculate color distribution
getFractions
()

Returns a copy of the array of floats used by this gradient to calculate color distribution.

public final AffineTransform

Returns:

a copy of the transform applied to the gradient
getTransform
()

Returns a copy of the transform applied to the gradient.

public final int

Returns:

OPAQUE if all colors used by this Paint object are opaque, TRANSLUCENT if at least one of the colors used by this Paint object is not opaque.
getTransparency
()

Implements java.awt.Transparency.getTransparency.

Returns the transparency mode for this Paint object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

colorsback to summary
pack-priv final Color[] colors

Gradient colors.

colorSpaceback to summary
pack-priv final MultipleGradientPaint.ColorSpaceType colorSpace

The color space in which to perform the gradient interpolation.

cycleMethodback to summary
pack-priv final MultipleGradientPaint.CycleMethod cycleMethod

The method to use when painting outside the gradient bounds.

fastGradientArraySizeback to summary
pack-priv int fastGradientArraySize
fractionsback to summary
pack-priv final float[] fractions

Gradient keyframe values in the range 0 to 1.

gradientback to summary
pack-priv SoftReference<int[]> gradient
gradientsback to summary
pack-priv SoftReference<int[][]> gradients
gradientTransformback to summary
pack-priv final AffineTransform gradientTransform

Transform to apply to gradient.

isSimpleLookupback to summary
pack-priv boolean isSimpleLookup
modelback to summary
pack-priv ColorModel model

The following fields are used only by MultipleGradientPaintContext to cache certain values that remain constant and do not need to be recalculated for each context created from this paint instance.

normalizedIntervalsback to summary
pack-priv float[] normalizedIntervals
transparencyback to summary
pack-priv final int transparency

The transparency of this paint object.

Constructor Detail

MultipleGradientPaintback to summary
pack-priv MultipleGradientPaint(float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, AffineTransform gradientTransform)

Package-private constructor.

Parameters
fractions:float[]

numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient

colors:Color[]

array of colors corresponding to each fractional value

cycleMethod:MultipleGradientPaint.CycleMethod

either NO_CYCLE, REFLECT, or REPEAT

colorSpace:MultipleGradientPaint.ColorSpaceType

which color space to use for interpolation, either SRGB or LINEAR_RGB

gradientTransform:AffineTransform

transform to apply to the gradient

Exceptions
NullPointerException:
if fractions array is null, or colors array is null, or gradientTransform is null, or cycleMethod is null, or colorSpace is null
IllegalArgumentException:
if fractions.length != colors.length, or colors is less than 2 in size, or a fractions value is less than 0.0 or greater than 1.0, or the fractions are not provided in strictly increasing order

Method Detail

getColorsback to summary
public final Color[] getColors()

Returns a copy of the array of colors used by this gradient. The first color maps to the first value in the fractions array, and the last color maps to the last value in the fractions array.

Returns:Color[]

a copy of the array of colors used by this gradient

getColorSpaceback to summary
public final MultipleGradientPaint.ColorSpaceType getColorSpace()

Returns the enumerated type which specifies color space for interpolation.

Returns:MultipleGradientPaint.ColorSpaceType

the enumerated type which specifies color space for interpolation

getCycleMethodback to summary
public final MultipleGradientPaint.CycleMethod getCycleMethod()

Returns the enumerated type which specifies cycling behavior.

Returns:MultipleGradientPaint.CycleMethod

the enumerated type which specifies cycling behavior

getFractionsback to summary
public final float[] getFractions()

Returns a copy of the array of floats used by this gradient to calculate color distribution. The returned array always has 0 as its first value and 1 as its last value, with increasing values in between.

Returns:float[]

a copy of the array of floats used by this gradient to calculate color distribution

getTransformback to summary
public final AffineTransform getTransform()

Returns a copy of the transform applied to the gradient.

Note that if no transform is applied to the gradient when it is created, the identity transform is used.

Returns:AffineTransform

a copy of the transform applied to the gradient

getTransparencyback to summary
public final int getTransparency()

Implements java.awt.Transparency.getTransparency.

Returns the transparency mode for this Paint object.

Returns:int

OPAQUE if all colors used by this Paint object are opaque, TRANSLUCENT if at least one of the colors used by this Paint object is not opaque.

See Also
java.awt.Transparency
java.awt back to summary

public final Enum MultipleGradientPaint.ColorSpaceType

extends Enum<MultipleGradientPaint.ColorSpaceType>
Class Inheritance

The color space in which to perform the gradient interpolation.
Since
1.6

Field Summary

Modifier and TypeField and Description
public static final MultipleGradientPaint.ColorSpaceType
LINEAR_RGB

Indicates that the color interpolation should occur in linearized RGB space.

public static final MultipleGradientPaint.ColorSpaceType
SRGB

Indicates that the color interpolation should occur in sRGB space.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static MultipleGradientPaint.ColorSpaceType
public static MultipleGradientPaint.ColorSpaceType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

LINEAR_RGBback to summary
public static final MultipleGradientPaint.ColorSpaceType LINEAR_RGB

Indicates that the color interpolation should occur in linearized RGB space.

SRGBback to summary
public static final MultipleGradientPaint.ColorSpaceType SRGB

Indicates that the color interpolation should occur in sRGB space.

Constructor Detail

ColorSpaceTypeback to summary
private ColorSpaceType()

Method Detail

valueOfback to summary
public static MultipleGradientPaint.ColorSpaceType valueOf(String name)
valuesback to summary
public static MultipleGradientPaint.ColorSpaceType[] values()
java.awt back to summary

public final Enum MultipleGradientPaint.CycleMethod

extends Enum<MultipleGradientPaint.CycleMethod>
Class Inheritance

The method to use when painting outside the gradient bounds.
Since
1.6

Field Summary

Modifier and TypeField and Description
public static final MultipleGradientPaint.CycleMethod
NO_CYCLE

Use the terminal colors to fill the remaining area.

public static final MultipleGradientPaint.CycleMethod
REFLECT

Cycle the gradient colors start-to-end, end-to-start to fill the remaining area.

public static final MultipleGradientPaint.CycleMethod
REPEAT

Cycle the gradient colors start-to-end, start-to-end to fill the remaining area.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static MultipleGradientPaint.CycleMethod
public static MultipleGradientPaint.CycleMethod[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NO_CYCLEback to summary
public static final MultipleGradientPaint.CycleMethod NO_CYCLE

Use the terminal colors to fill the remaining area.

REFLECTback to summary
public static final MultipleGradientPaint.CycleMethod REFLECT

Cycle the gradient colors start-to-end, end-to-start to fill the remaining area.

REPEATback to summary
public static final MultipleGradientPaint.CycleMethod REPEAT

Cycle the gradient colors start-to-end, start-to-end to fill the remaining area.

Constructor Detail

CycleMethodback to summary
private CycleMethod()

Method Detail

valueOfback to summary
public static MultipleGradientPaint.CycleMethod valueOf(String name)
valuesback to summary
public static MultipleGradientPaint.CycleMethod[] values()