Package snap.gfx
Class GradientPaint
java.lang.Object
snap.gfx.GradientPaint
- All Implemented Interfaces:
Cloneable
,Paint
,XMLArchiver.Archivable
A Paint subclass to represent a gradient.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A Builder class for GradientPaint.static class
A class to describe gradient paint stops.static enum
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new GradientPaint.GradientPaint
(double aSX, double aSY, double aEX, double aEY, GradientPaint.Stop[] theStops) Creates a new linear GradientPaint with given type, start/end points, stops.GradientPaint
(double anAngle, GradientPaint.Stop[] theStops) Creates a new linear GradientPaint with given stops and roll.GradientPaint
(Color aC1, Color aC2, double anAngle) Creates a new linear GradientPaint with given stops and roll.GradientPaint
(GradientPaint.Type aType, double aSX, double aSY, double aEX, double aEY, GradientPaint.Stop[] theStops) Creates a new GradientPaint with given type, start/end points, stops.GradientPaint
(GradientPaint.Type aType, double aSX, double aSY, double aEX, double aEY, GradientPaint.Stop[] theStops, boolean isAbs) Creates a new GradientPaint with given type, start/end points, stops and absolute flag. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a copy of this gradient paint.copyForColor
(Color aColor) Derives an instance of this class from given color.copyForPoints
(double aSX, double aSY, double aEX, double aEY) Returns a copy of this paint for new start/end points.copyForRect
(Rect aRect) Returns an absolute paint for given bounds of primitive to be filled.Reverse the order of the color stopscopyForRoll
(double aRoll) Returns a new gradient which is a copy of this gradient but with a different roll value.copyForStops
(GradientPaint.Stop[] theStops) Returns a copy of this paint with stops from given array.copyForType
(GradientPaint.Type aType) Returns a new gradient which is a copy of this gradient but of a different type.boolean
Standard equals implementation.fromXML
(XMLArchiver anArchiver, XMLElement anElement) XML unarchival.getColor()
Returns the closest color approximation of this paint.double
getEndX()
Returns the end x.double
getEndY()
Returns the end y.double
getRoll()
Returns the roll.double
Returns the start x.double
Returns the start y.getStop
(int anIndex) Returns the stop at given index.getStopColor
(int anIndex) Returns the stop color at given index.int
Returns the number of stops.double
getStopOffset
(int anIndex) Returns the stop offset at given index.getStops()
Returns the stops.static GradientPaint.Stop[]
Adds stops to a stops array.static GradientPaint.Stop[]
Creates an array of stops.static GradientPaint.Stop[]
Creates an array of stops.static GradientPaint.Stop[]
Creates an array of stops.static boolean
getStopsHaveAlpha
(GradientPaint.Stop[] theStops) Returns true if any of the colors in the gradient have alphagetType()
Returns the type.boolean
Returns whether paint is defined in terms independent of primitive to be filled.boolean
isLinear()
Returns whether gradient is linear.boolean
isOpaque()
Returns whether paint is opaque.boolean
isRadial()
Returns whether gradient is radial.protected void
Sets the roll.toString()
Standard to string implementation.toXML
(XMLArchiver anArchiver) XML archival.
-
Field Details
-
DEFAULT_STOPS
-
-
Constructor Details
-
GradientPaint
public GradientPaint()Creates a new GradientPaint. -
GradientPaint
Creates a new linear GradientPaint with given stops and roll. -
GradientPaint
Creates a new linear GradientPaint with given stops and roll. -
GradientPaint
Creates a new linear GradientPaint with given type, start/end points, stops. -
GradientPaint
public GradientPaint(GradientPaint.Type aType, double aSX, double aSY, double aEX, double aEY, GradientPaint.Stop[] theStops) Creates a new GradientPaint with given type, start/end points, stops. -
GradientPaint
public GradientPaint(GradientPaint.Type aType, double aSX, double aSY, double aEX, double aEY, GradientPaint.Stop[] theStops, boolean isAbs) Creates a new GradientPaint with given type, start/end points, stops and absolute flag.
-
-
Method Details
-
getType
Returns the type. -
isLinear
public boolean isLinear()Returns whether gradient is linear. -
isRadial
public boolean isRadial()Returns whether gradient is radial. -
getStartX
public double getStartX()Returns the start x. -
getStartY
public double getStartY()Returns the start y. -
getEndX
public double getEndX()Returns the end x. -
getEndY
public double getEndY()Returns the end y. -
getStops
Returns the stops. -
getRoll
public double getRoll()Returns the roll. -
setRoll
Sets the roll. -
getStopCount
public int getStopCount()Returns the number of stops. -
getStop
Returns the stop at given index. -
getStopColor
Returns the stop color at given index. -
getStopOffset
public double getStopOffset(int anIndex) Returns the stop offset at given index. -
isAbsolute
public boolean isAbsolute()Returns whether paint is defined in terms independent of primitive to be filled.- Specified by:
isAbsolute
in interfacePaint
-
isOpaque
public boolean isOpaque()Returns whether paint is opaque. -
getColor
Returns the closest color approximation of this paint. -
copyForColor
Derives an instance of this class from given color.- Specified by:
copyForColor
in interfacePaint
-
copyForRect
Returns an absolute paint for given bounds of primitive to be filled.- Specified by:
copyForRect
in interfacePaint
-
copyForPoints
Returns a copy of this paint for new start/end points. -
copyForStops
Returns a copy of this paint with stops from given array. -
copyForType
Returns a new gradient which is a copy of this gradient but of a different type. -
copyForRoll
Returns a new gradient which is a copy of this gradient but with a different roll value. -
copyForReverseStops
Reverse the order of the color stops -
clone
Returns a copy of this gradient paint. -
equals
Standard equals implementation. -
toXML
XML archival.- Specified by:
toXML
in interfaceXMLArchiver.Archivable
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceXMLArchiver.Archivable
-
toString
Standard to string implementation. -
getStopsHaveAlpha
Returns true if any of the colors in the gradient have alpha -
getStops
Creates an array of stops. -
getStops
public static GradientPaint.Stop[] getStops(double off1, Color col1, double off2, Color col2, double off3, Color col3) Creates an array of stops. -
getStops
public static GradientPaint.Stop[] getStops(double o1, Color c1, double o2, Color c2, double o3, Color c3, double o4, Color c4) Creates an array of stops. -
getStops
Adds stops to a stops array.
-