Class RtfColorTable


  • public final class RtfColorTable
    extends java.lang.Object
    Singelton of the RTF color table. This class was created for fo:basic-link tag processing. This work was originally authored by Andreas Putz
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BLUE  
      private java.util.Hashtable colorIndex
      Index table for the colors
      private java.util.Vector colorTable
      Used colors to this vector
      private static int GREEN  
      private static RtfColorTable instance
      Singelton instance
      private java.util.Hashtable namedColors
      Map of color names to color numbers
      private static int RED  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private RtfColorTable()
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addColor​(java.lang.Integer i)
      Adds a color to the table.
      private void addNamedColor​(java.lang.String name, int colorNumber)
      define a named color for getColorNumber(String)
      private int determineColorLevel​(int identifier, int color)
      Determines the color level from the identifier.
      private int determineIdentifier​(int red, int green, int blue)
      Determines a identifier for the color.
      java.lang.Integer getColorNumber​(int red, int green, int blue)
      Gets the number of color in the color table
      java.lang.Integer getColorNumber​(java.lang.String name)  
      static RtfColorTable getInstance()
      Singelton.
      private void init()
      Initialize the color table.
      void writeColors​(RtfHeader header)
      Writes the color table in the header.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • instance

        private static RtfColorTable instance
        Singelton instance
      • colorIndex

        private java.util.Hashtable colorIndex
        Index table for the colors
      • colorTable

        private java.util.Vector colorTable
        Used colors to this vector
      • namedColors

        private java.util.Hashtable namedColors
        Map of color names to color numbers
    • Constructor Detail

      • RtfColorTable

        private RtfColorTable()
        Constructor.
    • Method Detail

      • getInstance

        public static RtfColorTable getInstance()
        Singelton.
        Returns:
        The instance of RTFColorTable
      • init

        private void init()
        Initialize the color table.
      • addNamedColor

        private void addNamedColor​(java.lang.String name,
                                   int colorNumber)
        define a named color for getColorNumber(String)
      • getColorNumber

        public java.lang.Integer getColorNumber​(java.lang.String name)
        Parameters:
        name - a named color
        Returns:
        the RTF number of a named color, or null if name not found
      • getColorNumber

        public java.lang.Integer getColorNumber​(int red,
                                                int green,
                                                int blue)
        Gets the number of color in the color table
        Parameters:
        red - Color level red
        green - Color level green
        blue - Color level blue
        Returns:
        The number of the color in the table
      • writeColors

        public void writeColors​(RtfHeader header)
                         throws java.io.IOException
        Writes the color table in the header.
        Parameters:
        header - The header container to write in
        Throws:
        java.io.IOException - On error
      • addColor

        private void addColor​(java.lang.Integer i)
        Adds a color to the table.
        Parameters:
        i - Identifier of color
      • determineIdentifier

        private int determineIdentifier​(int red,
                                        int green,
                                        int blue)
        Determines a identifier for the color.
        Parameters:
        red - Color level red
        green - Color level green
        blue - Color level blue
        Returns:
        Unique identifier of color
      • determineColorLevel

        private int determineColorLevel​(int identifier,
                                        int color)
        Determines the color level from the identifier.
        Parameters:
        identifier - Unique color identifier
        color - One of the bit moving constants
        Returns:
        Color level in byte size