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_CYCLEcolorSpace- defaults toMultipleGradientPaint.ColorSpaceType.SRGBgradientTransform- defaults to new AffineTransform()direction- defaults toLinearGradient.GradientDirection.HORIZONTALstartAndEndPointsFunc- 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
FieldsModifier and TypeFieldDescriptionprivate LinearGradient.GradientDirectionThe direction for theLinearGradientto 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.GradientDirectionto return the start and end points in space for theLinearGradientFields inherited from class com.github.tadukoo.view.paint.gradient.GradientBuilder
colors, colorSpace, cycleMethod, fractions, gradientTransform -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNot allowed to create outside of LinearGradient -
Method Summary
Modifier and TypeMethodDescriptionprotected LinearGradientBuilds the actualGradient.Checks thatstartAndEndPointsFuncis 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 theLinearGradientto 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.GradientDirectionto 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 theLinearGradientto 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.GradientDirectionto return the start and end points in space for theLinearGradient- Returns:
- this, to continue building
-
colorPoint
- Overrides:
colorPointin classGradientBuilder<LinearGradient>- Parameters:
fraction- The fraction to use for this color pointcolor- TheColorto use for this color point- Returns:
- this, to continue building
-
cycleMethod
public LinearGradient.LinearGradientBuilder cycleMethod(MultipleGradientPaint.CycleMethod cycleMethod) - Overrides:
cycleMethodin classGradientBuilder<LinearGradient>- Parameters:
cycleMethod- Thecycle methodinvolved in the Gradient- Returns:
- this, to continue building
-
colorSpace
public LinearGradient.LinearGradientBuilder colorSpace(MultipleGradientPaint.ColorSpaceType colorSpace) - Overrides:
colorSpacein classGradientBuilder<LinearGradient>- Parameters:
colorSpace- Thecolor spaceinvolved in the Gradient- Returns:
- this, to continue building
-
gradientTransform
- Overrides:
gradientTransformin classGradientBuilder<LinearGradient>- Parameters:
gradientTransform- TheAffineTransforminvolved in the Gradient- Returns:
- this, to continue building
-
checkForSubclassErrors
Checks thatstartAndEndPointsFuncis not null- Specified by:
checkForSubclassErrorsin classGradientBuilder<LinearGradient>- Returns:
- An ArrayList of any errors found
-
buildGradient
Builds the actualGradient. This is implemented by the specific subclass.- Specified by:
buildGradientin classGradientBuilder<LinearGradient>- Returns:
- The newly built
Gradient
-