0N/A/*
3909N/A * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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 *
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 *
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.
0N/A *
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
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.awt;
0N/A
0N/Aimport java.awt.geom.AffineTransform;
0N/Aimport java.awt.geom.Point2D;
0N/Aimport java.awt.geom.Rectangle2D;
0N/Aimport java.awt.image.ColorModel;
2965N/Aimport java.beans.ConstructorProperties;
0N/A
0N/A/**
0N/A * The {@code RadialGradientPaint} class provides a way to fill a shape with
0N/A * a circular radial color gradient pattern. The user may specify 2 or more
0N/A * gradient colors, and this paint will provide an interpolation between
0N/A * each color.
0N/A * <p>
0N/A * The user must specify the circle controlling the gradient pattern,
0N/A * which is described by a center point and a radius. The user can also
0N/A * specify a separate focus point within that circle, which controls the
0N/A * location of the first color of the gradient. By default the focus is
0N/A * set to be the center of the circle.
0N/A * <p>
0N/A * This paint will map the first color of the gradient to the focus point,
0N/A * and the last color to the perimeter of the circle, interpolating
0N/A * smoothly for any in-between colors specified by the user. Any line drawn
0N/A * from the focus point to the circumference will thus span all the gradient
0N/A * colors.
0N/A * <p>
4067N/A * Specifying a focus point outside of the radius of the circle will cause
4067N/A * the rings of the gradient pattern to be centered on the point just inside
4067N/A * the edge of the circle in the direction of the focus point.
4067N/A * The rendering will internally use this modified location as if it were
4067N/A * the specified focus point.
0N/A * <p>
0N/A * The user must provide an array of floats specifying how to distribute the
0N/A * colors along the gradient. These values should range from 0.0 to 1.0 and
0N/A * act like keyframes along the gradient (they mark where the gradient should
0N/A * be exactly a particular color).
0N/A * <p>
0N/A * In the event that the user does not set the first keyframe value equal
0N/A * to 0 and/or the last keyframe value equal to 1, keyframes will be created
0N/A * at these positions and the first and last colors will be replicated there.
0N/A * So, if a user specifies the following arrays to construct a gradient:<br>
0N/A * <pre>
0N/A * {Color.BLUE, Color.RED}, {.3f, .7f}
0N/A * </pre>
0N/A * this will be converted to a gradient with the following keyframes:<br>
0N/A * <pre>
0N/A * {Color.BLUE, Color.BLUE, Color.RED, Color.RED}, {0f, .3f, .7f, 1f}
0N/A * </pre>
0N/A *
0N/A * <p>
3724N/A * The user may also select what action the {@code RadialGradientPaint} object
3724N/A * takes when it is filling the space outside the circle's radius by
3724N/A * setting {@code CycleMethod} to either {@code REFLECTION} or {@code REPEAT}.
3724N/A * The gradient color proportions are equal for any particular line drawn
3724N/A * from the focus point. The following figure shows that the distance AB
3724N/A * is equal to the distance BC, and the distance AD is equal to the distance DE.
3724N/A * <center>
3724N/A * <img src = "doc-files/RadialGradientPaint-3.png">
3724N/A * </center>
3724N/A * If the gradient and graphics rendering transforms are uniformly scaled and
3724N/A * the user sets the focus so that it coincides with the center of the circle,
3724N/A * the gradient color proportions are equal for any line drawn from the center.
3724N/A * The following figure shows the distances AB, BC, AD, and DE. They are all equal.
3724N/A * <center>
3724N/A * <img src = "doc-files/RadialGradientPaint-4.png">
3724N/A * </center>
3724N/A * Note that some minor variations in distances may occur due to sampling at
3724N/A * the granularity of a pixel.
0N/A * If no cycle method is specified, {@code NO_CYCLE} will be chosen by
0N/A * default, which means the the last keyframe color will be used to fill the
0N/A * remaining area.
0N/A * <p>
0N/A * The colorSpace parameter allows the user to specify in which colorspace
0N/A * the interpolation should be performed, default sRGB or linearized RGB.
0N/A *
0N/A * <p>
0N/A * The following code demonstrates typical usage of
0N/A * {@code RadialGradientPaint}, where the center and focus points are
0N/A * the same:
0N/A * <p>
0N/A * <pre>
0N/A * Point2D center = new Point2D.Float(50, 50);
0N/A * float radius = 25;
0N/A * float[] dist = {0.0f, 0.2f, 1.0f};
0N/A * Color[] colors = {Color.RED, Color.WHITE, Color.BLUE};
0N/A * RadialGradientPaint p =
0N/A * new RadialGradientPaint(center, radius, dist, colors);
0N/A * </pre>
0N/A *
0N/A * <p>
0N/A * This image demonstrates the example code above, with default
0N/A * (centered) focus for each of the three cycle methods:
0N/A * <p>
0N/A * <center>
0N/A * <img src = "doc-files/RadialGradientPaint-1.png">
0N/A * </center>
0N/A *
0N/A * <p>
0N/A * It is also possible to specify a non-centered focus point, as
0N/A * in the following code:
0N/A * <p>
0N/A * <pre>
0N/A * Point2D center = new Point2D.Float(50, 50);
0N/A * float radius = 25;
0N/A * Point2D focus = new Point2D.Float(40, 40);
0N/A * float[] dist = {0.0f, 0.2f, 1.0f};
0N/A * Color[] colors = {Color.RED, Color.WHITE, Color.BLUE};
0N/A * RadialGradientPaint p =
0N/A * new RadialGradientPaint(center, radius, focus,
0N/A * dist, colors,
0N/A * CycleMethod.NO_CYCLE);
0N/A * </pre>
0N/A *
0N/A * <p>
0N/A * This image demonstrates the previous example code, with non-centered
0N/A * focus for each of the three cycle methods:
0N/A * <p>
0N/A * <center>
0N/A * <img src = "doc-files/RadialGradientPaint-2.png">
0N/A * </center>
0N/A *
0N/A * @see java.awt.Paint
0N/A * @see java.awt.Graphics2D#setPaint
0N/A * @author Nicholas Talian, Vincent Hardy, Jim Graham, Jerry Evans
0N/A * @since 1.6
0N/A */
0N/Apublic final class RadialGradientPaint extends MultipleGradientPaint {
0N/A
0N/A /** Focus point which defines the 0% gradient stop X coordinate. */
0N/A private final Point2D focus;
0N/A
0N/A /** Center of the circle defining the 100% gradient stop X coordinate. */
0N/A private final Point2D center;
0N/A
0N/A /** Radius of the outermost circle defining the 100% gradient stop. */
0N/A private final float radius;
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code NO_CYCLE} repeating method and {@code SRGB} color space,
0N/A * using the center as the focus point.
0N/A *
0N/A * @param cx the X coordinate in user space of the center point of the
0N/A * circle defining the gradient. The last color of the
0N/A * gradient is mapped to the perimeter of this circle.
0N/A * @param cy the Y coordinate in user space of the center point of the
0N/A * circle defining the gradient. The last color of the
0N/A * gradient is mapped to the perimeter of this circle.
0N/A * @param radius the radius of the circle defining the extents of the
0N/A * color gradient
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A *
0N/A * @throws NullPointerException
0N/A * if {@code fractions} array is null,
0N/A * or {@code colors} array is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
0N/A public RadialGradientPaint(float cx, float cy, float radius,
0N/A float[] fractions, Color[] colors)
0N/A {
0N/A this(cx, cy,
0N/A radius,
0N/A cx, cy,
0N/A fractions,
0N/A colors,
0N/A CycleMethod.NO_CYCLE);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code NO_CYCLE} repeating method and {@code SRGB} color space,
0N/A * using the center as the focus point.
0N/A *
0N/A * @param center the center point, in user space, of the circle defining
0N/A * the gradient
0N/A * @param radius the radius of the circle defining the extents of the
0N/A * color gradient
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A *
0N/A * @throws NullPointerException
0N/A * if {@code center} point is null,
0N/A * or {@code fractions} array is null,
0N/A * or {@code colors} array is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
0N/A public RadialGradientPaint(Point2D center, float radius,
0N/A float[] fractions, Color[] colors)
0N/A {
0N/A this(center,
0N/A radius,
0N/A center,
0N/A fractions,
0N/A colors,
0N/A CycleMethod.NO_CYCLE);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code SRGB} color space, using the center as the focus point.
0N/A *
0N/A * @param cx the X coordinate in user space of the center point of the
0N/A * circle defining the gradient. The last color of the
0N/A * gradient is mapped to the perimeter of this circle.
0N/A * @param cy the Y coordinate in user space of the center point of the
0N/A * circle defining the gradient. The last color of the
0N/A * gradient is mapped to the perimeter of this circle.
0N/A * @param radius the radius of the circle defining the extents of the
0N/A * color gradient
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
0N/A * or {@code REPEAT}
0N/A *
0N/A * @throws NullPointerException
0N/A * if {@code fractions} array is null,
0N/A * or {@code colors} array is null,
0N/A * or {@code cycleMethod} is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
0N/A public RadialGradientPaint(float cx, float cy, float radius,
0N/A float[] fractions, Color[] colors,
0N/A CycleMethod cycleMethod)
0N/A {
0N/A this(cx, cy,
0N/A radius,
0N/A cx, cy,
0N/A fractions,
0N/A colors,
0N/A cycleMethod);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code SRGB} color space, using the center as the focus point.
0N/A *
0N/A * @param center the center point, in user space, of the circle defining
0N/A * the gradient
0N/A * @param radius the radius of the circle defining the extents of the
0N/A * color gradient
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
0N/A * or {@code REPEAT}
0N/A *
0N/A * @throws NullPointerException
0N/A * if {@code center} point is null,
0N/A * or {@code fractions} array is null,
0N/A * or {@code colors} array is null,
0N/A * or {@code cycleMethod} is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
0N/A public RadialGradientPaint(Point2D center, float radius,
0N/A float[] fractions, Color[] colors,
0N/A CycleMethod cycleMethod)
0N/A {
0N/A this(center,
0N/A radius,
0N/A center,
0N/A fractions,
0N/A colors,
0N/A cycleMethod);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code SRGB} color space.
0N/A *
0N/A * @param cx the X coordinate in user space of the center point of the
0N/A * circle defining the gradient. The last color of the
0N/A * gradient is mapped to the perimeter of this circle.
0N/A * @param cy the Y coordinate in user space of the center point of the
0N/A * circle defining the gradient. The last color of the
0N/A * gradient is mapped to the perimeter of this circle.
0N/A * @param radius the radius of the circle defining the extents of the
0N/A * color gradient
0N/A * @param fx the X coordinate of the point in user space to which the
0N/A * first color is mapped
0N/A * @param fy the Y coordinate of the point in user space to which the
0N/A * first color is mapped
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
0N/A * or {@code REPEAT}
0N/A *
0N/A * @throws NullPointerException
0N/A * if {@code fractions} array is null,
0N/A * or {@code colors} array is null,
0N/A * or {@code cycleMethod} is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
0N/A public RadialGradientPaint(float cx, float cy, float radius,
0N/A float fx, float fy,
0N/A float[] fractions, Color[] colors,
0N/A CycleMethod cycleMethod)
0N/A {
0N/A this(new Point2D.Float(cx, cy),
0N/A radius,
0N/A new Point2D.Float(fx, fy),
0N/A fractions,
0N/A colors,
0N/A cycleMethod);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code SRGB} color space.
0N/A *
0N/A * @param center the center point, in user space, of the circle defining
0N/A * the gradient. The last color of the gradient is mapped
0N/A * to the perimeter of this circle.
0N/A * @param radius the radius of the circle defining the extents of the color
0N/A * gradient
0N/A * @param focus the point in user space to which the first color is mapped
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
0N/A * or {@code REPEAT}
0N/A *
0N/A * @throws NullPointerException
0N/A * if one of the points is null,
0N/A * or {@code fractions} array is null,
0N/A * or {@code colors} array is null,
0N/A * or {@code cycleMethod} is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
0N/A public RadialGradientPaint(Point2D center, float radius,
0N/A Point2D focus,
0N/A float[] fractions, Color[] colors,
0N/A CycleMethod cycleMethod)
0N/A {
0N/A this(center,
0N/A radius,
0N/A focus,
0N/A fractions,
0N/A colors,
0N/A cycleMethod,
0N/A ColorSpaceType.SRGB,
0N/A new AffineTransform());
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint}.
0N/A *
0N/A * @param center the center point in user space of the circle defining the
0N/A * gradient. The last color of the gradient is mapped to
0N/A * the perimeter of this circle.
0N/A * @param radius the radius of the circle defining the extents of the
0N/A * color gradient
0N/A * @param focus the point in user space to which the first color is mapped
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
0N/A * or {@code REPEAT}
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 *
0N/A * @throws NullPointerException
0N/A * if one of the points is null,
0N/A * or {@code fractions} array is null,
0N/A * or {@code colors} array is null,
0N/A * or {@code cycleMethod} is null,
0N/A * or {@code colorSpace} is null,
0N/A * or {@code gradientTransform} is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code radius} is non-positive,
0N/A * or {@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 */
2965N/A @ConstructorProperties({ "centerPoint", "radius", "focusPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" })
0N/A public RadialGradientPaint(Point2D center,
0N/A float radius,
0N/A Point2D focus,
0N/A float[] fractions, Color[] colors,
0N/A CycleMethod cycleMethod,
0N/A ColorSpaceType colorSpace,
0N/A AffineTransform gradientTransform)
0N/A {
0N/A super(fractions, colors, cycleMethod, colorSpace, gradientTransform);
0N/A
0N/A // check input arguments
0N/A if (center == null) {
0N/A throw new NullPointerException("Center point must be non-null");
0N/A }
0N/A
0N/A if (focus == null) {
0N/A throw new NullPointerException("Focus point must be non-null");
0N/A }
0N/A
0N/A if (radius <= 0) {
0N/A throw new IllegalArgumentException("Radius must be greater " +
0N/A "than zero");
0N/A }
0N/A
0N/A // copy parameters
0N/A this.center = new Point2D.Double(center.getX(), center.getY());
0N/A this.focus = new Point2D.Double(focus.getX(), focus.getY());
0N/A this.radius = radius;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a {@code RadialGradientPaint} with a default
0N/A * {@code SRGB} color space.
0N/A * The gradient circle of the {@code RadialGradientPaint} is defined
0N/A * by the given bounding box.
0N/A * <p>
0N/A * This constructor is a more convenient way to express the
0N/A * following (equivalent) code:<br>
0N/A *
0N/A * <pre>
0N/A * double gw = gradientBounds.getWidth();
0N/A * double gh = gradientBounds.getHeight();
0N/A * double cx = gradientBounds.getCenterX();
0N/A * double cy = gradientBounds.getCenterY();
0N/A * Point2D center = new Point2D.Double(cx, cy);
0N/A *
0N/A * AffineTransform gradientTransform = new AffineTransform();
0N/A * gradientTransform.translate(cx, cy);
0N/A * gradientTransform.scale(gw / 2, gh / 2);
0N/A * gradientTransform.translate(-cx, -cy);
0N/A *
0N/A * RadialGradientPaint gp =
0N/A * new RadialGradientPaint(center, 1.0f, center,
0N/A * fractions, colors,
0N/A * cycleMethod,
0N/A * ColorSpaceType.SRGB,
0N/A * gradientTransform);
0N/A * </pre>
0N/A *
0N/A * @param gradientBounds the bounding box, in user space, of the circle
0N/A * defining the outermost extent of the gradient
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 to use in the gradient. The first color
0N/A * is used at the focus point, the last color around the
0N/A * perimeter of the circle.
0N/A * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
0N/A * or {@code REPEAT}
0N/A *
0N/A * @throws NullPointerException
0N/A * if {@code gradientBounds} is null,
0N/A * or {@code fractions} array is null,
0N/A * or {@code colors} array is null,
0N/A * or {@code cycleMethod} is null
0N/A * @throws IllegalArgumentException
0N/A * if {@code gradientBounds} is empty,
0N/A * or {@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 */
0N/A public RadialGradientPaint(Rectangle2D gradientBounds,
0N/A float[] fractions, Color[] colors,
0N/A CycleMethod cycleMethod)
0N/A {
0N/A // gradient center/focal point is the center of the bounding box,
0N/A // radius is set to 1.0, and then we set a scale transform
0N/A // to achieve an elliptical gradient defined by the bounding box
0N/A this(new Point2D.Double(gradientBounds.getCenterX(),
0N/A gradientBounds.getCenterY()),
0N/A 1.0f,
0N/A new Point2D.Double(gradientBounds.getCenterX(),
0N/A gradientBounds.getCenterY()),
0N/A fractions,
0N/A colors,
0N/A cycleMethod,
0N/A ColorSpaceType.SRGB,
0N/A createGradientTransform(gradientBounds));
0N/A
0N/A if (gradientBounds.isEmpty()) {
0N/A throw new IllegalArgumentException("Gradient bounds must be " +
0N/A "non-empty");
0N/A }
0N/A }
0N/A
0N/A private static AffineTransform createGradientTransform(Rectangle2D r) {
0N/A double cx = r.getCenterX();
0N/A double cy = r.getCenterY();
0N/A AffineTransform xform = AffineTransform.getTranslateInstance(cx, cy);
0N/A xform.scale(r.getWidth()/2, r.getHeight()/2);
0N/A xform.translate(-cx, -cy);
0N/A return xform;
0N/A }
0N/A
0N/A /**
213N/A * Creates and returns a {@link PaintContext} used to
213N/A * generate a circular radial color gradient pattern.
213N/A * See the description of the {@link Paint#createContext createContext} method
213N/A * for information on null parameter handling.
213N/A *
213N/A * @param cm the preferred {@link ColorModel} which represents the most convenient
213N/A * format for the caller to receive the pixel data, or {@code null}
213N/A * if there is no preference.
213N/A * @param deviceBounds the device space bounding box
213N/A * of the graphics primitive being rendered.
213N/A * @param userBounds the user space bounding box
213N/A * of the graphics primitive being rendered.
213N/A * @param transform the {@link AffineTransform} from user
213N/A * space into device space.
213N/A * @param hints the set of hints that the context object can use to
213N/A * choose between rendering alternatives.
213N/A * @return the {@code PaintContext} for
213N/A * generating color patterns.
213N/A * @see Paint
213N/A * @see PaintContext
213N/A * @see ColorModel
213N/A * @see Rectangle
213N/A * @see Rectangle2D
213N/A * @see AffineTransform
213N/A * @see RenderingHints
0N/A */
0N/A public PaintContext createContext(ColorModel cm,
0N/A Rectangle deviceBounds,
0N/A Rectangle2D userBounds,
0N/A AffineTransform transform,
0N/A RenderingHints hints)
0N/A {
0N/A // avoid modifying the user's transform...
0N/A transform = new AffineTransform(transform);
0N/A // incorporate the gradient transform
0N/A transform.concatenate(gradientTransform);
0N/A
0N/A return new RadialGradientPaintContext(this, cm,
0N/A deviceBounds, userBounds,
0N/A transform, hints,
0N/A (float)center.getX(),
0N/A (float)center.getY(),
0N/A radius,
0N/A (float)focus.getX(),
0N/A (float)focus.getY(),
0N/A fractions, colors,
0N/A cycleMethod, colorSpace);
0N/A }
0N/A
0N/A /**
0N/A * Returns a copy of the center point of the radial gradient.
0N/A *
0N/A * @return a {@code Point2D} object that is a copy of the center point
0N/A */
0N/A public Point2D getCenterPoint() {
0N/A return new Point2D.Double(center.getX(), center.getY());
0N/A }
0N/A
0N/A /**
3724N/A * Returns a copy of the focus point of the radial gradient.
4067N/A * Note that if the focus point specified when the radial gradient
4067N/A * was constructed lies outside of the radius of the circle, this
4067N/A * method will still return the original focus point even though
4067N/A * the rendering may center the rings of color on a different
4067N/A * point that lies inside the radius.
0N/A *
0N/A * @return a {@code Point2D} object that is a copy of the focus point
0N/A */
0N/A public Point2D getFocusPoint() {
0N/A return new Point2D.Double(focus.getX(), focus.getY());
0N/A }
0N/A
0N/A /**
0N/A * Returns the radius of the circle defining the radial gradient.
0N/A *
0N/A * @return the radius of the circle defining the radial gradient
0N/A */
0N/A public float getRadius() {
0N/A return radius;
0N/A }
0N/A}