Class RtfColorTable
- java.lang.Object
-
- org.apache.fop.render.rtf.rtflib.rtfdoc.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 colorsprivate java.util.Vector
colorTable
Used colors to this vectorprivate static int
GREEN
private static RtfColorTable
instance
Singelton instanceprivate java.util.Hashtable
namedColors
Map of color names to color numbersprivate 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 tablejava.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.
-
-
-
Field Detail
-
RED
private static final int RED
- See Also:
- Constant Field Values
-
GREEN
private static final int GREEN
- See Also:
- Constant Field Values
-
BLUE
private static final int BLUE
- See Also:
- Constant Field Values
-
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
-
-
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 redgreen
- Color level greenblue
- 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 redgreen
- Color level greenblue
- 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 identifiercolor
- One of the bit moving constants- Returns:
- Color level in byte size
-
-