/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* 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
* {@code LinearGradientPaint} and {@code RadialGradientPaint}.
*
* @author Nicholas Talian, Vincent Hardy, Jim Graham, Jerry Evans
* @since 1.6
*/
/** The method to use when painting outside the gradient bounds.
* @since 1.6
*/
public static enum CycleMethod {
/**
* Use the terminal colors to fill the remaining area.
*/
/**
* Cycle the gradient colors start-to-end, end-to-start
* to fill the remaining area.
*/
/**
* Cycle the gradient colors start-to-end, start-to-end
* to fill the remaining area.
*/
}
/** The color space in which to perform the gradient interpolation.
* @since 1.6
*/
public static enum ColorSpaceType {
/**
* Indicates that the color interpolation should occur in sRGB space.
*/
SRGB,
/**
* Indicates that the color interpolation should occur in linearized
* RGB space.
*/
}
/** The transparency of this paint object. */
final int transparency;
/** Gradient keyframe values in the range 0 to 1. */
final float[] fractions;
/** Gradient colors. */
/** Transform to apply to gradient. */
/** The method to use when painting outside the gradient bounds. */
/** The color space in which to perform the gradient interpolation. */
/**
* 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.
*/
float[] normalizedIntervals;
boolean isSimpleLookup;
/**
* Package-private constructor.
*
* @param fractions numbers ranging from 0.0 to 1.0 specifying the
* distribution of colors along the gradient
* @param colors array of colors corresponding to each fractional value
* @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
* or {@code REPEAT}
* @param colorSpace which color space to use for interpolation,
* either {@code SRGB} or {@code LINEAR_RGB}
* @param gradientTransform transform to apply to the gradient
*
* @throws NullPointerException
* if {@code fractions} array is null,
* or {@code colors} array is null,
* or {@code gradientTransform} is null,
* or {@code cycleMethod} is null,
* or {@code colorSpace} is null
* @throws IllegalArgumentException
* if {@code fractions.length != colors.length},
* or {@code colors} is less than 2 in size,
* or a {@code fractions} value is less than 0.0 or greater than 1.0,
* or the {@code fractions} are not provided in strictly increasing order
*/
{
throw new NullPointerException("Fractions array cannot be null");
}
throw new NullPointerException("Colors array cannot be null");
}
if (cycleMethod == null) {
throw new NullPointerException("Cycle method cannot be null");
}
if (colorSpace == null) {
throw new NullPointerException("Color space cannot be null");
}
if (gradientTransform == null) {
throw new NullPointerException("Gradient transform cannot be "+
"null");
}
throw new IllegalArgumentException("Colors and fractions must " +
"have equal size");
}
throw new IllegalArgumentException("User must specify at least " +
"2 colors");
}
// check that values are in the proper range and progress
// in increasing order from 0 to 1
float previousFraction = -1.0f;
for (float currentFraction : fractions) {
throw new IllegalArgumentException("Fraction values must " +
"be in the range 0 to 1: " +
}
if (currentFraction <= previousFraction) {
throw new IllegalArgumentException("Keyframe fractions " +
"must be increasing: " +
}
}
// We have to deal with the cases where the first gradient stop is not
// In both cases, create a new point and replicate the previous
// extreme point's color.
boolean fixFirst = false;
boolean fixLast = false;
int off = 0;
// first stop is not equal to zero, fix this condition
fixFirst = true;
len++;
off++;
}
// last stop is not equal to one, fix this condition
fixLast = true;
len++;
}
if (fixFirst) {
}
if (fixLast) {
}
// copy some flags
this.colorSpace = colorSpace;
this.cycleMethod = cycleMethod;
// copy the gradient transform
// determine transparency
boolean opaque = true;
}
}
/**
* 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.
*
* @return a copy of the array of floats used by this gradient to
* calculate color distribution
*/
public final float[] getFractions() {
}
/**
* 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.
*
* @return a copy of the array of colors used by this gradient
*/
}
/**
* Returns the enumerated type which specifies cycling behavior.
*
* @return the enumerated type which specifies cycling behavior
*/
return cycleMethod;
}
/**
* Returns the enumerated type which specifies color space for
* interpolation.
*
* @return the enumerated type which specifies color space for
* interpolation
*/
return colorSpace;
}
/**
* Returns a copy of the transform applied to the gradient.
*
* <p>
* Note that if no transform is applied to the gradient
* when it is created, the identity transform is used.
*
* @return a copy of the transform applied to the gradient
*/
return new AffineTransform(gradientTransform);
}
/**
* Returns the transparency mode for this {@code Paint} object.
*
* @return {@code OPAQUE} if all colors used by this
* {@code Paint} object are opaque,
* {@code TRANSLUCENT} if at least one of the
* colors used by this {@code Paint} object is not opaque.
* @see java.awt.Transparency
*/
public final int getTransparency() {
return transparency;
}
}