Class LinearGradient.LinearGradientBuilder
java.lang.Object
com.github.tadukoo.view.paint.gradient.GradientBuilder<LinearGradient>
com.github.tadukoo.view.paint.gradient.LinearGradient.LinearGradientBuilder
- Enclosing class:
- LinearGradient
Linear Gradient Builder is a builder for
LinearGradient
.
The only required parameters to specify are the color points
. You must specify
at least two, so that it's an actual gradient.
The following parameters are optional:
cycleMethod
- defaults toMultipleGradientPaint.CycleMethod.NO_CYCLE
colorSpace
- defaults toMultipleGradientPaint.ColorSpaceType.SRGB
gradientTransform
- defaults to new AffineTransform()direction
- defaults toLinearGradient.GradientDirection.HORIZONTAL
startAndEndPointsFunc
- defaults to calculating based on the direction given
- Since:
- Alpha v.0.2
- Version:
- Alpha v.0.2.1
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Modifier and TypeFieldDescriptionprivate LinearGradient.GradientDirection
The direction for theLinearGradient
to go.private BiFunction<Dimension,
LinearGradient.GradientDirection, com.github.tadukoo.util.tuple.Pair<Point2D, Point2D>> A function taking in the dimensions of the space and the chosenLinearGradient.GradientDirection
to return the start and end points in space for theLinearGradient
Fields inherited from class com.github.tadukoo.view.paint.gradient.GradientBuilder
colors, colorSpace, cycleMethod, fractions, gradientTransform
-
Constructor Summary
ModifierConstructorDescriptionprivate
Not allowed to create outside of LinearGradient -
Method Summary
Modifier and TypeMethodDescriptionprotected LinearGradient
Builds the actualGradient
.Checks thatstartAndEndPointsFunc
is not nullcolorPoint
(float fraction, Color color) colorSpace
(MultipleGradientPaint.ColorSpaceType colorSpace) cycleMethod
(MultipleGradientPaint.CycleMethod cycleMethod) direction
(LinearGradient.GradientDirection direction) gradientTransform
(AffineTransform gradientTransform) startAndEndPointsFunc
(BiFunction<Dimension, LinearGradient.GradientDirection, com.github.tadukoo.util.tuple.Pair<Point2D, Point2D>> startAndEndPointsFunc) Methods inherited from class com.github.tadukoo.view.paint.gradient.GradientBuilder
build, checkForErrors
-
Field Details
-
direction
The direction for theLinearGradient
to go. This may be ignored by thestartAndEndPointsFunc
-
startAndEndPointsFunc
private BiFunction<Dimension,LinearGradient.GradientDirection, startAndEndPointsFunccom.github.tadukoo.util.tuple.Pair<Point2D, Point2D>> A function taking in the dimensions of the space and the chosenLinearGradient.GradientDirection
to return the start and end points in space for theLinearGradient
-
-
Constructor Details
-
LinearGradientBuilder
private LinearGradientBuilder()Not allowed to create outside of LinearGradient
-
-
Method Details
-
direction
- Parameters:
direction
- The direction for theLinearGradient
to go. This may be ignored by thestartAndEndPointsFunc
- Returns:
- this, to continue building
-
startAndEndPointsFunc
public LinearGradient.LinearGradientBuilder startAndEndPointsFunc(BiFunction<Dimension, LinearGradient.GradientDirection, com.github.tadukoo.util.tuple.Pair<Point2D, Point2D>> startAndEndPointsFunc) - Parameters:
startAndEndPointsFunc
- A function taking in the dimensions of the space and the chosenLinearGradient.GradientDirection
to return the start and end points in space for theLinearGradient
- Returns:
- this, to continue building
-
colorPoint
- Overrides:
colorPoint
in classGradientBuilder<LinearGradient>
- Parameters:
fraction
- The fraction to use for this color pointcolor
- TheColor
to use for this color point- Returns:
- this, to continue building
-
cycleMethod
public LinearGradient.LinearGradientBuilder cycleMethod(MultipleGradientPaint.CycleMethod cycleMethod) - Overrides:
cycleMethod
in classGradientBuilder<LinearGradient>
- Parameters:
cycleMethod
- Thecycle method
involved in the Gradient- Returns:
- this, to continue building
-
colorSpace
public LinearGradient.LinearGradientBuilder colorSpace(MultipleGradientPaint.ColorSpaceType colorSpace) - Overrides:
colorSpace
in classGradientBuilder<LinearGradient>
- Parameters:
colorSpace
- Thecolor space
involved in the Gradient- Returns:
- this, to continue building
-
gradientTransform
- Overrides:
gradientTransform
in classGradientBuilder<LinearGradient>
- Parameters:
gradientTransform
- TheAffineTransform
involved in the Gradient- Returns:
- this, to continue building
-
checkForSubclassErrors
Checks thatstartAndEndPointsFunc
is not null- Specified by:
checkForSubclassErrors
in classGradientBuilder<LinearGradient>
- Returns:
- An ArrayList of any errors found
-
buildGradient
Builds the actualGradient
. This is implemented by the specific subclass.- Specified by:
buildGradient
in classGradientBuilder<LinearGradient>
- Returns:
- The newly built
Gradient
-