Spec-Zone .ru
спецификации, руководства, описания, API
|
public final class LinearGradient extends Paint
The LinearGradient
class fills a shape
with a linear color gradient pattern. The user may specify two or
more gradient colors, and this Paint will provide an interpolation
between each color.
The application provides an array of Stop
s specifying how to distribute
the colors along the gradient. The Stop#offset
variable must be
the range 0.0 to 1.0 and act like keyframes along the gradient.
They mark where the gradient should be exactly a particular color.
If the proportional variable is set to true (the default) then the start and end points of the gradient should be specified relative to the unit square (0.0->1.0) and will be stretched across the shape. If proportional variable is set to false, then the start and end points should be specified as absolute pixel values and the gradient will not be stretched at all.
The two filled rectangles in the example below will render the same. The one on the left uses proportional coordinates (the default) to specify the gradient's end points. The one on the right uses absolute coordinates. Both of them fill the specified rectangle with a horizontal gradient that varies from black to red
// object bounding box relative (proportional:true) Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.BLACK)}; LinearGradient lg = new LinearGradient(0, 0, 1, 0, true, CycleMethod.No_CYCLE, stops); Rectangle r = new Rectangle(); r.setFill(lg); // user space relative (proportional:false) LinearGradient lg = new LinearGradient(125, 0, 225, 0, false, CycleMethod.No_CYCLE, stops); Rectangle r = new Rectangle(); r.setX(125.0); r.setY(0.0); r.setWidth(100); r.setHeight(100); r.setFill(lg);
Constructor and Description |
---|
LinearGradient(double startX,
double startY,
double endX,
double endY,
boolean proportional,
CycleMethod cycleMethod,
java.util.List<Stop> stops)
Creates a new instance of LinearGradient.
|
LinearGradient(double startX,
double startY,
double endX,
double endY,
boolean proportional,
CycleMethod cycleMethod,
Stop... stops)
Creates a new instance of LinearGradient.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.
|
CycleMethod |
getCycleMethod()
Defines which of the following cycle method is applied
to the
LinearGradient : CycleMethod.NO_CYCLE ,
CycleMethod.REFLECT , or CycleMethod.REPEAT . |
double |
getEndX()
Defines the X coordinate of the gradient axis end point.
|
double |
getEndY()
Defines the Y coordinate of the gradient axis end point.
|
double |
getStartX()
Defines the X coordinate of the gradient axis start point.
|
double |
getStartY()
Defines the Y coordinate of the gradient axis start point.
|
java.util.List<Stop> |
getStops()
A sequence of 2 or more
Stop values specifying how to distribute
the colors along the gradient. |
int |
hashCode()
Returns a hash code for this
LinearGradient object. |
boolean |
isProportional()
Indicates whether start and end locations are proportional or absolute.
|
java.lang.String |
toString()
Returns a string representation of this
LinearGradient object. |
public LinearGradient(double startX, double startY, double endX, double endY, boolean proportional, CycleMethod cycleMethod, Stop... stops)
startX
- the X coordinate of the gradient axis start pointstartY
- the Y coordinate of the gradient axis start pointendX
- the X coordinate of the gradient axis end pointendY
- the Y coordinate of the gradient axis end pointproportional
- whether the coordinates are proportional
to the shape which this gradient fillscycleMethod
- cycle method applied to the gradientstops
- the gradient's color specificationpublic LinearGradient(double startX, double startY, double endX, double endY, boolean proportional, CycleMethod cycleMethod, java.util.List<Stop> stops)
startX
- the X coordinate of the gradient axis start pointstartY
- the Y coordinate of the gradient axis start pointendX
- the X coordinate of the gradient axis end pointendY
- the Y coordinate of the gradient axis end pointproportional
- whether the coordinates are proportional
to the shape which this gradient fillscycleMethod
- cycle method applied to the gradientstops
- the gradient's color specificationpublic final double getStartX()
public final double getStartY()
public final double getEndX()
public final double getEndY()
public final boolean isProportional()
[0..1]
are scaled to map
onto the bounds of the shape that the gradient fills.
If this flag is false, then the coordinates are specified in the local
coordinate system of the node.public final CycleMethod getCycleMethod()
LinearGradient
: CycleMethod.NO_CYCLE
,
CycleMethod.REFLECT
, or CycleMethod.REPEAT
.public final java.util.List<Stop> getStops()
Stop
values specifying how to distribute
the colors along the gradient. These values must be in the range
0.0 to 1.0. They act like key frames along the gradient: they mark where
the gradient should be exactly a particular color.
Each stop in the sequence must have an offset that is greater than the previous stop in the sequence.
The list is unmodifiable and will throw
UnsupportedOperationException
on each modification attempt.
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare.true
if this object is equal to the obj
argument; false
otherwise.public int hashCode()
LinearGradient
object.hashCode
in class java.lang.Object
LinearGradient
object.public java.lang.String toString()
LinearGradient
object.toString
in class java.lang.Object
LinearGradient
object.Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to