ilog.views.java2d
Class IlvLinearGradientPaint

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

public class IlvLinearGradientPaint
extends IlvMultipleGradientPaint
implements IlvPersistentObject

This class defines a multiple linear 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.

The user may also select what action the IlvLinearGradientPaint 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.

Sample drawing produced by a linear 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
IlvLinearGradientPaint(float x1, float y1, float x2, float y2, float[] stops, Color[] colors, boolean adapt)
          Builds an IlvLinearGradientPaint.
IlvLinearGradientPaint(float x1, float y1, float x2, float y2, float[] stops, Color[] colors, short spreadMethod, boolean adapt)
          Builds an IlvLinearGradientPaint.
IlvLinearGradientPaint(IlvInputStream stream)
          Builds an IlvLinearGradientPaint from an IlvInputStream.
IlvLinearGradientPaint(Point2D start, Point2D end, float[] stops, Color[] colors, boolean adapt)
          Builds an IlvLinearGradientPaint.
IlvLinearGradientPaint(Point2D start, Point2D end, float[] stops, Color[] colors, short spreadMethod, boolean adapt)
          Builds an IlvLinearGradientPaint.
IlvLinearGradientPaint(Point2D start, Point2D end, float[] stops, Color[] colors, short spreadMethod, short colorSpace, AffineTransform transform, boolean adapt)
          Builds an IlvLinearGradientPaint.
 
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 getEnd()
          Returns the end point for the gradient.
 Point2D getStart()
          Returns the start point for the gradient.
 void write(IlvOutputStream stream)
          Writes the IlvLinearGradientPaint 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

IlvLinearGradientPaint

public IlvLinearGradientPaint(float x1,
                              float y1,
                              float x2,
                              float y2,
                              float[] stops,
                              Color[] colors,
                              boolean adapt)
Builds an IlvLinearGradientPaint.

Parameters:
x1 - x coordinate of the gradient axis start point.
y1 - y coordinate of the gradient axis start point.
x2 - x coordinate of the gradient axis end point.
y2 - y coordinate of the gradient axis end point.
stops - Array of stops on the gradient axis.
colors - Array of colors on the gradient axis.
adapt - true if the gradient should be adapted to its displaying area.

IlvLinearGradientPaint

public IlvLinearGradientPaint(float x1,
                              float y1,
                              float x2,
                              float y2,
                              float[] stops,
                              Color[] colors,
                              short spreadMethod,
                              boolean adapt)
Builds an IlvLinearGradientPaint.

Parameters:
x1 - x coordinate of the gradient axis start point.
y1 - y coordinate of the gradient axis start point.
x2 - x coordinate of the gradient axis end point.
y2 - y coordinate of the gradient axis end point.
stops - Array of stops on the gradient axis.
colors - Array of colors on the gradient axis.
spreadMethod - How to fill the remainder region.
adapt - true if the gradient should be adapted to its displaying area.
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT

IlvLinearGradientPaint

public IlvLinearGradientPaint(Point2D start,
                              Point2D end,
                              float[] stops,
                              Color[] colors,
                              boolean adapt)
Builds an IlvLinearGradientPaint.

Parameters:
start - Coordinates of the gradient axis start point.
end - Coordinates of the gradient axis end point.
stops - Array of stops on the gradient axis.
colors - Array of colors on the gradient axis.
adapt - true if the gradient should be adapted to its displaying area.

IlvLinearGradientPaint

public IlvLinearGradientPaint(Point2D start,
                              Point2D end,
                              float[] stops,
                              Color[] colors,
                              short spreadMethod,
                              boolean adapt)
Builds an IlvLinearGradientPaint.

Parameters:
start - Coordinates of the gradient axis start point.
end - Coordinates of the gradient axis end point.
stops - Array of stops on the gradient axis.
colors - Array of colors on the gradient axis.
spreadMethod - How to fill the remainder region.
adapt - true if the gradient should be adapted to its displaying area.
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT

IlvLinearGradientPaint

public IlvLinearGradientPaint(Point2D start,
                              Point2D end,
                              float[] stops,
                              Color[] colors,
                              short spreadMethod,
                              short colorSpace,
                              AffineTransform transform,
                              boolean adapt)
Builds an IlvLinearGradientPaint.

Parameters:
start - Coordinates of the gradient axis start point.
end - Coordinates of the gradient axis end point.
stops - Array of stops on the gradient axis.
colors - Array of colors on the gradient axis.
spreadMethod - How to fill the remainder region.
colorSpace - The color space into 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 its displaying area.
Since:
JViews 5.0
See Also:
IlvMultipleGradientPaint.SPREAD_PAD, IlvMultipleGradientPaint.SPREAD_REPEAT, IlvMultipleGradientPaint.SPREAD_REFLECT, IlvMultipleGradientPaint.SRGB, IlvMultipleGradientPaint.LINEAR_RGB

IlvLinearGradientPaint

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

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

getStart

public Point2D getStart()
Returns the start point for the gradient.

Returns:
The start point for the gradient.

getEnd

public Point2D getEnd()
Returns the end point for the gradient.

Returns:
The end point for the gradient.

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the IlvLinearGradientPaint 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.