Class StiGradient2Painter
java.lang.Object
com.stimulsoft.base.drawing.painter.StiGradient2Painter
- All Implemented Interfaces:
Paint,Transparency
The
GradientPaint class provides a way to fill a Shape with a linear color
gradient pattern. If Point P1 with Color C1 and Point P2 with
Color C2 are specified in user space, the Color on the P1, P2
connecting line is proportionally changed from C1 to C2. Any point P not on the extended P1, P2
connecting line has the color of the point P' that is the perpendicular projection of P on the
extended P1, P2 connecting line. Points on the extended line outside of the P1, P2 segment can be
colored in one of two ways.
- If the gradient is cyclic then the points on the extended P1, P2 connecting line cycle back and forth between the colors C1 and C2.
-
If the gradient is acyclic then points on the P1 side of the segment have the constant
ColorC1 while points on the P2 side have the constantColorC2.
- Version:
- 10 Feb 1997
- See Also:
-
Field Summary
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT -
Constructor Summary
ConstructorsConstructorDescriptionStiGradient2Painter(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic, float distance) Constructs either a cyclic or acyclicGradientPaintobject depending on thebooleanparameter.StiGradient2Painter(float x1, float y1, Color color1, float x2, float y2, Color color2, float distance) Constructs a simple acyclicGradientPaintobject.StiGradient2Painter(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic, float distance) Constructs either a cyclic or acyclicGradientPaintobject depending on thebooleanparameter.StiGradient2Painter(Point2D pt1, Color color1, Point2D pt2, Color color2, float distance) Constructs a simple acyclicGradientPaintobject. -
Method Summary
Modifier and TypeMethodDescriptioncreateContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) Creates and returns a context used to generate the color pattern.Returns the color C1 anchored by the point P1.Returns the color C2 anchored by the point P2.Returns a copy of the point P1 that anchors the first color.Returns a copy of the point P2 which anchors the second color.intReturns the transparency mode for thisGradientPaint.booleanisCyclic()Returnstrueif the gradient cycles repeatedly between the two colors C1 and C2.
-
Constructor Details
-
StiGradient2Painter
public StiGradient2Painter(float x1, float y1, Color color1, float x2, float y2, Color color2, float distance) Constructs a simple acyclicGradientPaintobject.- Parameters:
x1- x coordinate of the first specifiedPointin user spacey1- y coordinate of the first specifiedPointin user spacecolor1-Colorat the first specifiedPointx2- x coordinate of the second specifiedPointin user spacey2- y coordinate of the second specifiedPointin user spacecolor2-Colorat the second specifiedPoint- Throws:
NullPointerException- if either one of colors is null
-
StiGradient2Painter
Constructs a simple acyclicGradientPaintobject.- Parameters:
pt1- the first specifiedPointin user spacecolor1-Colorat the first specifiedPointpt2- the second specifiedPointin user spacecolor2-Colorat the second specifiedPoint- Throws:
NullPointerException- if either one of colors or points is null
-
StiGradient2Painter
public StiGradient2Painter(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic, float distance) Constructs either a cyclic or acyclicGradientPaintobject depending on thebooleanparameter.- Parameters:
x1- x coordinate of the first specifiedPointin user spacey1- y coordinate of the first specifiedPointin user spacecolor1-Colorat the first specifiedPointx2- x coordinate of the second specifiedPointin user spacey2- y coordinate of the second specifiedPointin user spacecolor2-Colorat the second specifiedPointcyclic-trueif the gradient pattern should cycle repeatedly between the two colors;falseotherwise
-
StiGradient2Painter
public StiGradient2Painter(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic, float distance) Constructs either a cyclic or acyclicGradientPaintobject depending on thebooleanparameter.- Parameters:
pt1- the first specifiedPointin user spacecolor1-Colorat the first specifiedPointpt2- the second specifiedPointin user spacecolor2-Colorat the second specifiedPointcyclic-trueif the gradient pattern should cycle repeatedly between the two colors;falseotherwise- Throws:
NullPointerException- if either one of colors or points is null
-
-
Method Details
-
getPoint1
Returns a copy of the point P1 that anchors the first color.- Returns:
- a
Point2Dobject that is a copy of the point that anchors the first color of thisGradientPaint.
-
getColor1
Returns the color C1 anchored by the point P1.- Returns:
- a
Colorobject that is the color anchored by P1.
-
getPoint2
Returns a copy of the point P2 which anchors the second color.- Returns:
- a
Point2Dobject that is a copy of the point that anchors the second color of thisGradientPaint.
-
getColor2
Returns the color C2 anchored by the point P2.- Returns:
- a
Colorobject that is the color anchored by P2.
-
isCyclic
public boolean isCyclic()Returnstrueif the gradient cycles repeatedly between the two colors C1 and C2.- Returns:
trueif the gradient cycles repeatedly between the two colors;falseotherwise.
-
createContext
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) Creates and returns a context used to generate the color pattern.- Specified by:
createContextin interfacePaint- Parameters:
cm-ColorModelthat receives thePaintdata. This is used only as a hint.deviceBounds- the device space bounding box of the graphics primitive being rendereduserBounds- the user space bounding box of the graphics primitive being renderedxform- theAffineTransformfrom user space into device spacehints- the hints that the context object uses to choose between rendering alternatives- Returns:
- the
PaintContextthat generates color patterns. - See Also:
-
getTransparency
public int getTransparency()Returns the transparency mode for thisGradientPaint.- Specified by:
getTransparencyin interfaceTransparency- Returns:
- an integer value representing this
GradientPaintobject's transparency mode. - See Also:
-