ilog.views.java2d
Class IlvRadialGradientPaint

java.lang.Object
  extended by ilog.views.java2d.IlvMultipleGradientPaint
      extended by ilog.views.java2d.IlvRadialGradientPaint
All Implemented Interfaces:
IlvPersistentObject, Paint, Transparency

public class IlvRadialGradientPaint
extends IlvMultipleGradientPaint
implements IlvPersistentObject

This class defines a multiple radial color gradient paint that will be used to fill Java 2 Shape objects.

You can, for example, set it on an IlvGeneralPath to fill it.

The user must provide an array of floats in an increasing order specifying how to distribute the colors along the gradient. These values should range from 0.0 to 1.0 and act like keyframes along the gradient (they mark where the gradient should be exactly a particular color).

In the event that the user does not set the first keyframe value equal to 0 and the last keyframe value equal to 1, keyframes will be created at these positions, and the first and last colors will be replicated there.

This paint will map the first color of the gradient to a focal point within the circle and the last color to the perimeter of the circle, interpolating smoothly for any in-between colors specified by the user. Any line drawn from the focal point to the circumference will span all the gradient colors. By default, the focus is set to be the center of the circle.

Specifying a focal point outside of the circle's radius will result in the focus being set to the intersection point of the focus-center line and the perimeter of the circle.

The user may also select what action the IlvRadialGradientPaint should take when filling color outside the start and end points. If no spread method is specified, SPREAD_PAD will be chosen by default, so the endpoint colors will be used to fill the remaining area.

Here is a sample drawing produced by a radial gradient:

See Also:
Paint, IlvMultipleGradientPaint

Field Summary
 
Fields inherited from class ilog.views.java2d.IlvMultipleGradientPaint
LINEAR_RGB, SPREAD_PAD, SPREAD_REFLECT, SPREAD_REPEAT, SRGB
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
IlvRadialGradientPaint(float cx, float cy, float radius, float[] stops, Color[] colors, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(float cx, float cy, float radius, float[] stops, Color[] colors, float fx, float fy, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(float cx, float cy, float radius, float[] stops, Color[] colors, float fx, float fy, short spreadMethod, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(float cx, float cy, float radius, float[] stops, Color[] colors, short spreadMethod, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(IlvInputStream stream)
          Builds an IlvRadialGradientPaint from an IlvInputStream.
IlvRadialGradientPaint(Point2D center, float radius, float[] stops, Color[] colors, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(Point2D center, float radius, float[] stops, Color[] colors, Point2D focal, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(Point2D center, float radius, float[] stops, Color[] colors, Point2D focal, short spreadMethod, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(Point2D center, float radius, float[] stops, Color[] colors, Point2D focal, short spreadMethod, short colorSpace, AffineTransform transform, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
IlvRadialGradientPaint(Point2D center, float radius, float[] stops, Color[] colors, short spreadMethod, boolean adapt)
          Builds a circular IlvRadialGradientPaint instance.
 
Method Summary
 PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints)
          Creates and returns a context used to generate the gradient.
 Point2D getCenter()
          Returns the gradient center.
 Point2D getFocal()
          Returns the gradient focus.
 float getRadius()
          Returns the gradient radius.
 void write(IlvOutputStream stream)
          Writes the IlvRadialGradientPaint to an IlvOutputStream.
 
Methods inherited from class ilog.views.java2d.IlvMultipleGradientPaint
getColors, getColorSpace, getSpreadMethod, getStops, getTransform, getTransparency, isAdapting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvRadialGradientPaint

public IlvRadialGradientPaint(Point2D center,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
center - The center of the circle.
radius - The radius of the circle.
stops - Array of stops of the gradient.
colors - Array of colors of the gradient.
adapt - true if the gradient should be adapted to the shape on which it is drawn.

IlvRadialGradientPaint

public IlvRadialGradientPaint(Point2D center,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              short spreadMethod,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
center - The center of the circle.
radius - The radius of the circle.
stops - Array of stops of the gradient.
colors - Array of colors of the gradient.
spreadMethod - How to fill the remainder region.
adapt - true if the gradient should be adapted to the shape on which it is drawn.
Since:
JViews 5.0
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT

IlvRadialGradientPaint

public IlvRadialGradientPaint(float cx,
                              float cy,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
cx - The x coordinate of the circle center.
cy - The y coordinate of the circle center.
radius - The radius of the circle.
stops - Array of stops of the gradient.
colors - Array of colors of the gradient.
adapt - true if the gradient should be adapted to the shape on which it is drawn.

IlvRadialGradientPaint

public IlvRadialGradientPaint(float cx,
                              float cy,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              short spreadMethod,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
cx - The x coordinate of the circle center.
cy - The y coordinate of the circle center.
radius - The radius of the circle.
stops - Array of stops of the gradient.
colors - Array of colors of the gradient.
spreadMethod - How to fill the remainder region.
adapt - true if the gradient should be adapted to the shape on which it is drawn.
Since:
JViews 5.0
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT

IlvRadialGradientPaint

public IlvRadialGradientPaint(float cx,
                              float cy,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              float fx,
                              float fy,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
cx - The x coordinate of the circle center.
cy - The y coordinate of the circle center.
radius - The radius of the circle.
stops - Array of stops of the gradient.
colors - Array of colors of the gradient.
fx - The x coordinate of the focal point.
fy - The y coordinate of the focal point.
adapt - true if the gradient should be adapted to the shape on which it is drawn.

IlvRadialGradientPaint

public IlvRadialGradientPaint(float cx,
                              float cy,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              float fx,
                              float fy,
                              short spreadMethod,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
cx - The x coordinate of the circle center.
cy - The y coordinate of the circle center.
radius - The radius of the circle.
stops - Array of stops of the gradient.
colors - Array of colors of the gradient.
fx - The x coordinate of the focal point.
fy - The y coordinate of the focal point.
spreadMethod - How to fill the remainder region.
adapt - true if the gradient should be adapted to the shape on which it is drawn.
Since:
JViews 5.0
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT

IlvRadialGradientPaint

public IlvRadialGradientPaint(Point2D center,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              Point2D focal,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
center - The center of the circle.
radius - The radius of the circle.
colors - Array of colors of the gradient.
stops - Array of stops of the gradient.
focal - The focal point.
adapt - true if the gradient should be adapted to the shape on which it is drawn.

IlvRadialGradientPaint

public IlvRadialGradientPaint(Point2D center,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              Point2D focal,
                              short spreadMethod,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
center - The center of the circle.
radius - The radius of the circle.
colors - Array of colors of the gradient.
stops - Array of stops of the gradient.
focal - The focal point.
spreadMethod - How to fill the remainder region.
adapt - true if the gradient should be adapted to the shape on which it is drawn.
Since:
JViews 5.0
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT

IlvRadialGradientPaint

public IlvRadialGradientPaint(Point2D center,
                              float radius,
                              float[] stops,
                              Color[] colors,
                              Point2D focal,
                              short spreadMethod,
                              short colorSpace,
                              AffineTransform transform,
                              boolean adapt)
Builds a circular IlvRadialGradientPaint instance.

Parameters:
center - The center of the circle.
radius - The radius of the circle.
colors - Array of colors of the gradient.
stops - Array of stops of the gradient.
focal - The focal point.
spreadMethod - How to fill the remainder region.
colorSpace - The color space where the color interpolation should take place.
transform - An additional transformer to apply when drawing the gradient.
adapt - true if the gradient should be adapted to the shape on which it is drawn.
Since:
JViews 5.0
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT, IlvMultipleGradientPaint.SRGB, IlvMultipleGradientPaint.LINEAR_RGB

IlvRadialGradientPaint

public IlvRadialGradientPaint(IlvInputStream stream)
                       throws IOException,
                              IlvReadFileException
Builds an IlvRadialGradientPaint from an IlvInputStream.

Parameters:
stream - The input stream.
Throws:
IOException
IlvReadFileException
Method Detail

createContext

public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds,
                                  Rectangle2D userBounds,
                                  AffineTransform transform,
                                  RenderingHints hints)
Creates and returns a context used to generate the gradient.

Specified by:
createContext in interface Paint

getCenter

public Point2D getCenter()
Returns the gradient center.

Returns:
The gradient center.

getRadius

public float getRadius()
Returns the gradient radius.

Returns:
The gradient radius.

getFocal

public Point2D getFocal()
Returns the gradient focus.

Returns:
The gradient focus.

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the IlvRadialGradientPaint to an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvMultipleGradientPaint
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.