JIDE 3.5.15

com.jidesoft.chart.util
Class ColorFactory

java.lang.Object
  extended by com.jidesoft.chart.util.ColorFactory

public class ColorFactory
extends Object

The idea of this class is to produce any number of colors, but the colors should be different to one another so that they can be picked out visually in a chart.

Author:
Simon White (swhite@catalysoft.com)

Constructor Summary
ColorFactory()
           
ColorFactory(Color... initialColors)
          Sets up a predetermined sequence of colors to use initially
ColorFactory(int transparency, Color... initialColors)
          This constructor allows you to set the transparency of the generated colors as well as provide a sequence of colors to use initially
 
Method Summary
 void clear()
           
 double closest(Color color)
          Returns the distance of the closest color generated
 Color create()
           
static double distance(Color color1, Color color2)
          The distance measure between the two supplied colors in red, green, blue space.
 int getTransparency()
           
static Color intensify(Color c, int offset)
          Intensify a colour by applying the supplied offset
static Color intensify2(Color c, int offset)
          This method of intensifying a colour distributes intensity wherever it can.
 void setTransparency(int transparency)
          Sets the transparency value
static Color transitionColor(Color fromColor, Color toColor, double position)
          Create a color that lies on the 'color line' between the supplied fromColor and toColor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorFactory

public ColorFactory()

ColorFactory

public ColorFactory(int transparency,
                    Color... initialColors)
This constructor allows you to set the transparency of the generated colors as well as provide a sequence of colors to use initially

Parameters:
transparency - a value between 0 (transparent) and 255 (opaque)
initialColors - the first colours to use in the generated sequence

ColorFactory

public ColorFactory(Color... initialColors)
Sets up a predetermined sequence of colors to use initially

Parameters:
initialColors - the colors to start with
Method Detail

clear

public void clear()

getTransparency

public int getTransparency()
Returns:
the transparency value

setTransparency

public void setTransparency(int transparency)
Sets the transparency value

Parameters:
transparency - the new transparency value

distance

public static double distance(Color color1,
                              Color color2)
The distance measure between the two supplied colors in red, green, blue space.

Parameters:
color1 - a color
color2 - another color
Returns:
the distance between the two colors

closest

public double closest(Color color)
Returns the distance of the closest color generated

Parameters:
color - the color of interest
Returns:
the distance of the closest color generated, according to the distance(color, color) method.

create

public Color create()

intensify

public static Color intensify(Color c,
                              int offset)
Intensify a colour by applying the supplied offset

Parameters:
c - the original colour
offset - a value between -255 and 255 to add to each of the rgb components
Returns:
a new colour with the offset applied. If the new colour would be negative it is set to 0 and if greater than 255 it is set to 255.

intensify2

public static Color intensify2(Color c,
                               int offset)
This method of intensifying a colour distributes intensity wherever it can. If one of the primary colours gets to 255, then the colour points that the colour would have received are given to the other colours.

Parameters:
c - the original color
offset - the amount by which to change the color, in the range 0 to 255
Returns:
the new intensified Color object

transitionColor

public static Color transitionColor(Color fromColor,
                                    Color toColor,
                                    double position)
Create a color that lies on the 'color line' between the supplied fromColor and toColor. The position parameter dictates where along the color line the new color will be. This parameter should be in the range [0, 1]. If the value is 0, the returned color is the same as the fromColor; if it is 1, it the same as the toColor.

Parameters:
fromColor - one point at the end of the color line
toColor - another point at the end of the color line
position - the position along the color line
Returns:
a new Color

JIDE 3.5.15