chemaxon.marvin.util
Class ColorGenerator

java.lang.Object
  extended by chemaxon.marvin.util.ColorGenerator

public final class ColorGenerator
extends java.lang.Object

A final class which provides a static access to a color distant color creator class. The result will be a List of Colors which are distinguishable from each other and some specified other colors (typically from background colors). The order of the generated Colors is the same on the same collection of forbidden colors, regardless of the number of the required colors. This class also provides a few collections of colors, for gathering the most used forbidden colors.

Usage example:

If you need a n Colors without the most often used molecule label colors and without the base (red, green, blue, cyan magenta, yellow, black, white) colors, and you intend to use them on a light background:

List<Color> colors =
     ColorGenerator.generateColors(n, gatherBaseColorsAndBaseMoleculeColors(true));


If you need n colors without any constraints:

List<Color> colors = ColorGenerator.generateColors(n);

Since:
07.24.2011.
Version:
5.7
Author:
Janos Papdeak
See Also:
Color, Collection, List, gatherBlackAndWhite(), gatherBaseColors(), gatherBaseMoleculeColors(boolean), gatherBaseColorsAndBaseMoleculeColors(boolean)

Constructor Summary
ColorGenerator()
           
 
Method Summary
static java.util.Collection<java.awt.Color> gatherBaseColors()
          Creates a Collection of the base colors.
static java.util.Collection<java.awt.Color> gatherBaseColorsAndBaseMoleculeColors(boolean onLightBackground)
          Creates a Collection of the base Molecule RGB colors and base colors.
static java.util.Collection<java.awt.Color> gatherBaseMoleculeColors(boolean onLightBackground)
          Creates a Collection of the base Molecule RGB colors.
static java.util.Collection<java.awt.Color> gatherBlackAndWhite()
          Creates a Collection of black and white color
static java.util.List<java.awt.Color> generateColors(int count)
          Generates the specified number of different Colors, with no forbidden colors.
static java.util.List<java.awt.Color> generateColors(int count, java.util.Collection<java.awt.Color> forbiddenColors)
          Generates the specified number of different Colors, which are different enough from the specified forbidden colors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorGenerator

public ColorGenerator()
Method Detail

generateColors

public static final java.util.List<java.awt.Color> generateColors(int count,
                                                                  java.util.Collection<java.awt.Color> forbiddenColors)
Generates the specified number of different Colors, which are different enough from the specified forbidden colors. If there are too many forbidden and required colors (greater than 224), this function throws IllegalArgumentException.

Parameters:
count - the number of the required colors between 1 and 224
forbiddenColors - the forbidden colors or null
Returns:
the List of the generated Colors
See Also:
gatherBlackAndWhite(), gatherBaseColors(), gatherBaseMoleculeColors(boolean), gatherBaseColorsAndBaseMoleculeColors(boolean), Color

generateColors

public static final java.util.List<java.awt.Color> generateColors(int count)
Generates the specified number of different Colors, with no forbidden colors. If there are too many required colors (greater than 224), this function throws IllegalArgumentException.

Parameters:
count - the number of the required colors between 1 and 224
Returns:
the List of the generated Colors

gatherBaseColors

public static final java.util.Collection<java.awt.Color> gatherBaseColors()
Creates a Collection of the base colors.
These colors are:

- black
- white
- red
- green
- blue
- cyan
- magenta
- yellow.

Returns:
the base colors
See Also:
gatherBlackAndWhite(), gatherBaseMoleculeColors(boolean), gatherBaseColorsAndBaseMoleculeColors(boolean), Color

gatherBaseMoleculeColors

public static final java.util.Collection<java.awt.Color> gatherBaseMoleculeColors(boolean onLightBackground)
Creates a Collection of the base Molecule RGB colors.
These colors are the atom label RGB colors of:

- H
- C
- N
- O
- S
- F
- P
- Cl
- Br
- I.


and

- black
- white

Parameters:
onLightBackground - true if the colors will be displayed on a light background, false if not.
Returns:
the base Molecule colors
See Also:
gatherBlackAndWhite(), gatherBaseColors(), gatherBaseColorsAndBaseMoleculeColors(boolean), Color

gatherBaseColorsAndBaseMoleculeColors

public static final java.util.Collection<java.awt.Color> gatherBaseColorsAndBaseMoleculeColors(boolean onLightBackground)
Creates a Collection of the base Molecule RGB colors and base colors.
These colors are the atom label RGB colors of:
- H
- C
- N
- O
- S
- F
- P
- Cl
- Br
- I.

and the following basic colors:

- black
- white
- red
- green
- blue
- cyan
- magenta
- yellow.

Parameters:
onLightBackground - true if the colors will be displayed on a light background, false if not.
Returns:
the collection of the base colors and base molecule colors
See Also:
gatherBlackAndWhite(), gatherBaseColors(), gatherBaseMoleculeColors(boolean), Color

gatherBlackAndWhite

public static final java.util.Collection<java.awt.Color> gatherBlackAndWhite()
Creates a Collection of black and white color

Returns:
the collection of the base colors and base molecule colors
See Also:
gatherBaseColors(), gatherBaseMoleculeColors(boolean), gatherBaseColorsAndBaseMoleculeColors(boolean), Color