Class ColorGenerator


  • public class ColorGenerator
    extends Object
    Class to generate a given number of color steps to cross fade from color A to color C (and optionally pass color B)
    Version:
    $Revision: 1.19 $
    Author:
    Ole Rahn, Stefan Ostermann

    FH Osnabrück - University of Applied Sciences Osnabrück,
    Project: PIROL (2005),
    Subproject: Daten- und Wissensmanagement
    • Field Detail

      • inputColors

        protected List inputColors
      • colorArray

        protected Color[] colorArray
      • steps

        protected int steps
    • Constructor Detail

      • ColorGenerator

        public ColorGenerator()
        For java2xml which needs an empty constructor.
      • ColorGenerator

        public ColorGenerator​(int steps,
                              List colors)
        this constructor is untested, yet (but there is no predictable reason, why it should not work...)
        Parameters:
        steps - number of colors wanted
        colors - List containing java.awt.Color objects
      • ColorGenerator

        public ColorGenerator​(int steps,
                              Color[] colors)
        this constructor is untested, yet (but there is no predictable reason, why it should not work...)
        Parameters:
        steps - number of colors wanted
        colors - array containing java.awt.Color objects
      • ColorGenerator

        public ColorGenerator​(int steps,
                              Color A,
                              Color C)
      • ColorGenerator

        public ColorGenerator​(int steps,
                              Color A,
                              Color B,
                              Color C)
    • Method Detail

      • getTrafficLightColors

        public static ColorGenerator getTrafficLightColors​(int steps)
      • getGreenToRedColors

        public static ColorGenerator getGreenToRedColors​(int steps)
      • getRedToGreenColors

        public static ColorGenerator getRedToGreenColors​(int steps)
      • getReverseTrafficLightColors

        public static ColorGenerator getReverseTrafficLightColors​(int steps)
      • getBlueToRedColors

        public static ColorGenerator getBlueToRedColors​(int steps)
      • getColorArray

        public Color[] getColorArray()
        Returns:
        All generated colors in an object-array
      • getSteps

        public int getSteps()
        Returns:
        the given number of color steps
      • setSteps

        public void setSteps​(int steps)
        Parameters:
        steps - the number of color steps
      • getColor

        public Color getColor​(int nr)
        Returns the nr-th color, generated by this class
        Parameters:
        nr - zero-based index of the color wanted
        Returns:
        Color or null if the given index is out-of-bounds
      • setColor

        protected void setColor​(int nr,
                                Color color)
        Sets the nr-th color, originally generated by this class
        Parameters:
        nr - zero-based index of the color wanted
      • fillColorArray

        protected void fillColorArray()
        method to actually generate the colors
      • getInputColorsAsArray

        public Color[] getInputColorsAsArray()
      • getXMLInputColors

        public Collection getXMLInputColors()
        For java2xml
        Returns:
        Returns the inputColors.
      • addXMLInputColor

        public void addXMLInputColor​(Color color)
        For java2xml
        Parameters:
        color - the color to add
      • getStepsXML

        public int getStepsXML()
        For java2xml
        Returns:
        the number of steps to cross fade from color A to color C
      • setStepsXML

        public void setStepsXML​(int steps)
        For java2xml
        Parameters:
        steps - number of steps