Groovy Documentation

eu.hansolo.gradients
[Java] Class GradientWrapper

java.lang.Object
  eu.hansolo.gradients.GradientWrapper
All Implemented Interfaces:
Paint

public class GradientWrapper
extends Object

Authors:
Gerrit Grunwald


Field Summary
private LinearGradientPaint GRADIENT

private Color[] colors

private float[] fractions

 
Constructor Summary
GradientWrapper(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors)

GradientWrapper(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)

GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors)

GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)

GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, AffineTransform gradientTransform)

 
Method Summary
private void copyArrays(float[] FRACTIONS, Color[] colors)

Just create a local copy of the fractions and colors array

PaintContext createContext(ColorModel COLOR_MODEL, Rectangle DEVICE_BOUNDS, Rectangle2D USER_BOUNDS, AffineTransform X_FORM, RenderingHints HINTS)

Color getColorAt(float FRACTION)

Returns the color that is defined by the given fraction in the linear gradient paint

Point2D getEndPoint()

Returns the point where the wrapped LinearGradientPaint will stop

LinearGradientPaint getGradient()

Returns the wrapped LinearGradientPaint

Point2D getStartPoint()

Returns the point where the wrapped LinearGradientPaint will start

int getTransparency()

private Color interpolateColor(Color COLOR1, Color COLOR2, float FRACTION)

Returns the interpolated color that you get if you multiply the delta between color2 and color1 with the given fraction (for each channel) and interpolation.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

GRADIENT

private final LinearGradientPaint GRADIENT


colors

private Color[] colors


fractions

private float[] fractions


 
Constructor Detail

GradientWrapper

public GradientWrapper(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors)


GradientWrapper

public GradientWrapper(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)


GradientWrapper

public GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors)


GradientWrapper

public GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)


GradientWrapper

public GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, AffineTransform gradientTransform)


 
Method Detail

copyArrays

private void copyArrays(float[] FRACTIONS, Color[] colors)
Just create a local copy of the fractions and colors array
Parameters:
FRACTIONS
colors


createContext

@Override
public PaintContext createContext(ColorModel COLOR_MODEL, Rectangle DEVICE_BOUNDS, Rectangle2D USER_BOUNDS, AffineTransform X_FORM, RenderingHints HINTS)


getColorAt

public Color getColorAt(float FRACTION)
Returns the color that is defined by the given fraction in the linear gradient paint
Parameters:
FRACTION
Returns:
the color that is defined by the given fraction in the linear gradient paint


getEndPoint

public Point2D getEndPoint()
Returns the point where the wrapped LinearGradientPaint will stop
Returns:
the point where the wrapped LinearGradientPaint will stop


getGradient

public LinearGradientPaint getGradient()
Returns the wrapped LinearGradientPaint
Returns:
the wrapped LinearGradientPaint


getStartPoint

public Point2D getStartPoint()
Returns the point where the wrapped LinearGradientPaint will start
Returns:
the point where the wrapped LinearGradientPaint will start


getTransparency

@Override
public int getTransparency()


interpolateColor

private Color interpolateColor(Color COLOR1, Color COLOR2, float FRACTION)
Returns the interpolated color that you get if you multiply the delta between color2 and color1 with the given fraction (for each channel) and interpolation. The fraction should be a value between 0 and 1.
Parameters:
COLOR1 - The first color as integer in the hex format 0xALPHA RED GREEN BLUE, e.g. 0xFF00FF00 for a pure green
COLOR2 - The second color as integer in the hex format 0xALPHA RED GREEN BLUE e.g. 0xFFFF0000 for a pure red
FRACTION - The fraction between those two colors that we would like to get e.g. 0.5f will result in the color 0xFF808000
Returns:
the interpolated color between color1 and color2 calculated by the given fraction and interpolation


 

Groovy Documentation