MultipleGradientPaint.java revision 3724
2362N/A * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This is the superclass for Paints which use a multiple color 0N/A * gradient to fill in their raster. It provides storage for variables and 0N/A * enumerated values common to 0N/A * {@code LinearGradientPaint} and {@code RadialGradientPaint}. 0N/A * @author Nicholas Talian, Vincent Hardy, Jim Graham, Jerry Evans 0N/A /** The method to use when painting outside the gradient bounds. 0N/A * Use the terminal colors to fill the remaining area. 0N/A * Cycle the gradient colors start-to-end, end-to-start 0N/A * to fill the remaining area. 0N/A * Cycle the gradient colors start-to-end, start-to-end 0N/A * to fill the remaining area. 0N/A /** The color space in which to perform the gradient interpolation. 0N/A * Indicates that the color interpolation should occur in sRGB space. 0N/A * Indicates that the color interpolation should occur in linearized 0N/A /** The transparency of this paint object. */ 0N/A /** Gradient keyframe values in the range 0 to 1. */ 0N/A /** Gradient colors. */ 0N/A /** Transform to apply to gradient. */ 0N/A /** The method to use when painting outside the gradient bounds. */ 0N/A /** The color space in which to perform the gradient interpolation. */ 0N/A * The following fields are used only by MultipleGradientPaintContext 0N/A * to cache certain values that remain constant and do not need to be 0N/A * recalculated for each context created from this paint instance. 0N/A * Package-private constructor. 0N/A * @param fractions numbers ranging from 0.0 to 1.0 specifying the 0N/A * distribution of colors along the gradient 0N/A * @param colors array of colors corresponding to each fractional value 0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT}, 0N/A * @param colorSpace which color space to use for interpolation, 0N/A * either {@code SRGB} or {@code LINEAR_RGB} 0N/A * @param gradientTransform transform to apply to the gradient 0N/A * @throws NullPointerException 0N/A * if {@code fractions} array is null, 0N/A * or {@code colors} array is null, 0N/A * or {@code gradientTransform} is null, 0N/A * or {@code cycleMethod} is null, 0N/A * or {@code colorSpace} is null 0N/A * @throws IllegalArgumentException 0N/A * if {@code fractions.length != colors.length}, 0N/A * or {@code colors} is less than 2 in size, 0N/A * or a {@code fractions} value is less than 0.0 or greater than 1.0, 0N/A * or the {@code fractions} are not provided in strictly increasing order 0N/A // check that values are in the proper range and progress 0N/A // in increasing order from 0 to 1 0N/A "be in the range 0 to 1: " +
0N/A "must be increasing: " +
0N/A // We have to deal with the cases where the first gradient stop is not 0N/A // equal to 0 and/or the last gradient stop is not equal to 1. 0N/A // In both cases, create a new point and replicate the previous 0N/A // extreme point's color. 0N/A // first stop is not equal to zero, fix this condition 0N/A // last stop is not equal to one, fix this condition 0N/A // copy the gradient transform 0N/A // determine transparency 0N/A * Returns a copy of the array of floats used by this gradient 0N/A * to calculate color distribution. 0N/A * The returned array always has 0 as its first value and 1 as its 0N/A * last value, with increasing values in between. 0N/A * @return a copy of the array of floats used by this gradient to 0N/A * calculate color distribution 0N/A * Returns a copy of the array of colors used by this gradient. 0N/A * The first color maps to the first value in the fractions array, 0N/A * and the last color maps to the last value in the fractions array. 0N/A * @return a copy of the array of colors used by this gradient 0N/A * Returns the enumerated type which specifies cycling behavior. 0N/A * @return the enumerated type which specifies cycling behavior 0N/A * Returns the enumerated type which specifies color space for 0N/A * @return the enumerated type which specifies color space for 0N/A * Returns a copy of the transform applied to the gradient. 3724N/A * Note that if no transform is applied to the gradient 3724N/A * when it is created, the identity transform is used. 0N/A * @return a copy of the transform applied to the gradient 3724N/A * Returns the transparency mode for this {@code Paint} object. 3724N/A * @return {@code OPAQUE} if all colors used by this 3724N/A * {@code Paint} object are opaque, 3724N/A * {@code TRANSLUCENT} if at least one of the 3724N/A * colors used by this {@code Paint} object is not opaque. 0N/A * @see java.awt.Transparency