Class GradientUIResource
java.lang.Object
com.github.tadukoo.view.paint.gradient.GradientUIResource
- All Implemented Interfaces:
Gradient,PaintUIResource,SizablePaint,UIResource
GradientUIResource is simply a
LinearGradient wrapped as a PaintUIResource so that it can be
used in Tadukoo Look & Feel (or other custom Look & Feels if desired).- Since:
- Alpha v.0.2
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGradientUIResource(Gradient gradient) Constructs a Gradient UI Resource using the givenGradient. -
Method Summary
Modifier and TypeMethodDescriptionColor[]Makes a ColorUIResource out of the first Color in this Gradient.float[]Metal Look and Feel has a trash way of handling gradients.Creates a Paint to be used based on the size of the object to be painted.
-
Field Details
-
gradient
TheGradientcontained in this Gradient UI resource
-
-
Constructor Details
-
Method Details
-
getColors
-
getFractions
public float[] getFractions()- Specified by:
getFractionsin interfaceGradient- Returns:
- The fractions involved in this Gradient
-
getCycleMethod
- Specified by:
getCycleMethodin interfaceGradient- Returns:
- The
cycle methodinvolved in the Gradient
-
getColorSpace
- Specified by:
getColorSpacein interfaceGradient- Returns:
- The
color spaceinvolved in the Gradient
-
getGradientTransform
- Specified by:
getGradientTransformin interfaceGradient- Returns:
- The
AffineTransforminvolved in the Gradient
-
getPaint
Creates a Paint to be used based on the size of the object to be painted. The size is given because in the case of Gradients, it determines where the points are placed.- Specified by:
getPaintin interfaceSizablePaint- Parameters:
size- The Dimensions of the object to be painted- Returns:
- A Paint
-
getColorUIResource
Makes a ColorUIResource out of the first Color in this Gradient. There are some UI situations where we can't avoid using a Color instead of a general Paint if we want to support everything, so we need to return a plain Color in some cases.- Specified by:
getColorUIResourcein interfacePaintUIResource- Returns:
- The first Color in the Gradient as a ColorUIResource
-
getMetalGradientList
Metal Look and Feel has a trash way of handling gradients. Basically it takes 3 colors and 2 fractions, but with the 3 colors, it repeats color 1 and does 1, 2, 1, 3. The fractions represent the 2 middle points, but the 2nd point is calculated as mid1 * 2 + mid2.
If there are 4 colors or more, we send colors 1, 2, and either 3 or 4. Color 3 is sent if it's different than color 1 (because if it's the same, Metal already handles it with its 1, 2, 1, 3 garbage).
3 colors get sent in their given order, and we can't help that 1 is repeated.
If there are 3 fractions or more, we send fraction 2 as midpoint1, and fraction 3 as midpoint2, after subtracting midpoint1 * 2 from it.
If there are only 2 colors, we send color 1, 2, and 2 again. For the fractions, we send fraction 2 as midpoint 1 and put in 0 for midpoint 2.- Specified by:
getMetalGradientListin interfacePaintUIResource- Returns:
- The garbage List that Metal Look and Feel expects for gradients that matches best to the one defined here
-