Groovy Documentation

eu.hansolo.gradients
[Java] Class ContourGradientPaint

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

public final class ContourGradientPaint
extends Object

A paint class that creates a gradient that is a combination of four linear gradient paints. Each of the gradients start at one of the four sides of the given bounds rectangle and fill stop in the center of the boundary rectangle. You could use it like the other gradient paints in the jdk (LinearGradientPaint and RadialGradientPaint). You simply have to pass the boundary box of your element, a array of floats for the fractions and a array of colors to the ContourGradientPaint. If you would like to create a diamond like gradient you have to pass a boundary rectangle that is square (width == height). Even if the name implies that it uses the contour of a shape it will always use the rectangular boundary box of your shape!

Authors:
hansolo
Version:
1.0


Nested Class Summary
private class ContourGradientPaint.DiamondGradientPaintContext

 
Field Summary
private Rectangle2D BOUNDS

private Color[] COLORS

private List COLOR_LOOKUP

private Float[] FRACTIONS

private static float INT_TO_FLOAT_CONST

 
Constructor Summary
ContourGradientPaint(Rectangle2D GIVEN_BOUNDS, float[] GIVEN_FRACTIONS, Color[] GIVEN_COLORS)

Enhanced constructor which takes the FRACTIONS in degress from 0.0f to 360.0f and also an GIVEN_OFFSET in degrees around the rotation CENTER

 
Method Summary
PaintContext createContext(ColorModel COLOR_MODEL, Rectangle DEVICE_BOUNDS, Rectangle2D USER_BOUNDS, AffineTransform TRANSFORM, RenderingHints HINTS)

private Color getColorFromFraction(Color SOURCE_COLOR, Color DESTINATION_COLOR, int RANGE, int CURRENT_FRACTION)

Returns the color that equals the value from CURRENT_FRACTION in a RANGE of values where the start of the RANGE equals the SOURCE_COLOR and the end of the RANGE equals the DESTINATION_COLOR.

int getTransparency()

private List prepareColorLookup()

String toString()

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

Field Detail

BOUNDS

private final Rectangle2D BOUNDS


COLORS

private final Color[] COLORS


COLOR_LOOKUP

private final List COLOR_LOOKUP


FRACTIONS

private final Float[] FRACTIONS


INT_TO_FLOAT_CONST

private static final float INT_TO_FLOAT_CONST


 
Constructor Detail

ContourGradientPaint

public ContourGradientPaint(Rectangle2D GIVEN_BOUNDS, float[] GIVEN_FRACTIONS, Color[] GIVEN_COLORS)
Enhanced constructor which takes the FRACTIONS in degress from 0.0f to 360.0f and also an GIVEN_OFFSET in degrees around the rotation CENTER
throws:
IllegalArgumentException
Parameters:
GIVEN_BOUNDS
GIVEN_FRACTIONS
GIVEN_COLORS


 
Method Detail

createContext

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


getColorFromFraction

private Color getColorFromFraction(Color SOURCE_COLOR, Color DESTINATION_COLOR, int RANGE, int CURRENT_FRACTION)
Returns the color that equals the value from CURRENT_FRACTION in a RANGE of values where the start of the RANGE equals the SOURCE_COLOR and the end of the RANGE equals the DESTINATION_COLOR. In other words you could get any color in a gradient between to colors by a given value.
Parameters:
SOURCE_COLOR
DESTINATION_COLOR
RANGE
CURRENT_FRACTION
Returns:
Color that was calculated by a fraction from a range of values.


getTransparency

@Override
public int getTransparency()


prepareColorLookup

private List prepareColorLookup()


toString

@Override
public String toString()


 

Groovy Documentation