LibreOffice Module xmerge (master)  1
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.openoffice.xmerge.util.ColourConverter Class Reference

Utility class mapping RGB colour specifications to the colour indices used in the Pocket PC. More...

Public Member Functions

 ColourConverter ()
 Default constructor used in the case where a lookup table is not required. More...
 
 ColourConverter (short lookup[])
 Constructor that passes in the colour lookup table. More...
 
Color convertToRGB (short colour)
 This method maps a Pocket Word colour index value to an RGB value as used by OpenOffice. More...
 
short convertFromRGB (Color colour)
 This method approximates an RGB value (as used by Writer) to one of the 16 available colours. More...
 

Static Public Attributes

static final short OLIVE = 15
 Colour table index for Olive. More...
 

Private Member Functions

short colourLookup (short colour)
 Uses the colour table if it exists to translate default values to values in the colorTable. More...
 
short indexLookup (short index)
 Uses the colour table if it exists to translate default values to values in the colorTable. More...
 
int getClosest (int value)
 Default implementation, checks for the closest of value to 0, 128 or 255. More...
 
int getClosest (int value, int[] points)
 Utility method that returns the closest of the three points to the value supplied. More...
 
boolean isGrey (Color c)
 Checks to see if the supplied colour can be considered to be grey. More...
 

Private Attributes

short tableLookup [] = null
 

Static Private Attributes

static final short BLACK = 0
 Colour table index for Black. More...
 
static final short SILVER = 1
 Colour table index for Silver. More...
 
static final short GREY = 2
 Colour table index for Grey. More...
 
static final short WHITE = 3
 Colour table index for White. More...
 
static final short RED = 4
 Colour table index for Red. More...
 
static final short LIME = 5
 Colour table index for Lime. More...
 
static final short BLUE = 6
 Colour table index for Blue. More...
 
static final short AQUA = 7
 Colour table index for Aqua. More...
 
static final short FUCHSIA = 8
 Colour table index for Fuchsia. More...
 
static final short YELLOW = 9
 Colour table index for Yellow. More...
 
static final short MAROON = 10
 Colour table index for Maroon. More...
 
static final short GREEN = 11
 Colour table index for Green. More...
 
static final short NAVY = 12
 Colour table index for Navy. More...
 
static final short TEAL = 13
 Colour table index for Teal. More...
 
static final short PURPLE = 14
 Colour table index for Purple. More...
 

Detailed Description

Utility class mapping RGB colour specifications to the colour indices used in the Pocket PC.

The original converter was written for use with Pocket Word it was later put into the utils so Pocket excel could use this code also. For this reason the default values are those used by Pocket Word but a colour table can be passed in through the constructor to map the 16 values to a colour table.

These colour indices are based on the Windows VGA 16 colour palette, which later was used as the basis for the named colours in the HTML 3.2 specification.

In Pocket Word's case, the match to the VGA 16 palette is not exact as it swaps Grey and Silver, with Silver being the darker colour (i.e. having the lower RGB value).

Definition at line 41 of file ColourConverter.java.

Constructor & Destructor Documentation

org.openoffice.xmerge.util.ColourConverter.ColourConverter ( )
inline

Default constructor used in the case where a lookup table is not required.

Definition at line 96 of file ColourConverter.java.

org.openoffice.xmerge.util.ColourConverter.ColourConverter ( short  lookup[])
inline

Constructor that passes in the colour lookup table.

This is required in cases where the 16 colour values are something other than there default values (e.g. in the case of pocket Excel).

Parameters
lookupa 16 bit array mapping the 16 colours to their values.

Definition at line 108 of file ColourConverter.java.

Member Function Documentation

short org.openoffice.xmerge.util.ColourConverter.colourLookup ( short  colour)
inlineprivate

Uses the colour table if it exists to translate default values to values in the colorTable.

Definition at line 116 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

short org.openoffice.xmerge.util.ColourConverter.convertFromRGB ( Color  colour)
inline
Color org.openoffice.xmerge.util.ColourConverter.convertToRGB ( short  colour)
inline

This method maps a Pocket Word colour index value to an RGB value as used by OpenOffice.

Parameters
colourThe index into Pocket Word's colour table.
Returns
A object representing the RGB value of the Pocket Word colour.

Definition at line 152 of file ColourConverter.java.

References Color, index, and org.openoffice.xmerge.util.ColourConverter.indexLookup().

int org.openoffice.xmerge.util.ColourConverter.getClosest ( int  value)
inlineprivate

Default implementation, checks for the closest of value to 0, 128 or 255.

Definition at line 382 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.isGrey().

int org.openoffice.xmerge.util.ColourConverter.getClosest ( int  value,
int[]  points 
)
inlineprivate

Utility method that returns the closest of the three points to the value supplied.

Definition at line 392 of file ColourConverter.java.

References Math, and x.

short org.openoffice.xmerge.util.ColourConverter.indexLookup ( short  index)
inlineprivate

Uses the colour table if it exists to translate default values to values in the colorTable.

Definition at line 128 of file ColourConverter.java.

References i, and result.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertToRGB().

boolean org.openoffice.xmerge.util.ColourConverter.isGrey ( Color  c)
inlineprivate

Checks to see if the supplied colour can be considered to be grey.

Definition at line 411 of file ColourConverter.java.

References org.openoffice.xmerge.util.ColourConverter.getClosest().

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

Member Data Documentation

final short org.openoffice.xmerge.util.ColourConverter.AQUA = 7
staticprivate

Colour table index for Aqua.

Definition at line 65 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.BLACK = 0
staticprivate

Colour table index for Black.

Definition at line 44 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.BLUE = 6
staticprivate

Colour table index for Blue.

Definition at line 62 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.FUCHSIA = 8
staticprivate

Colour table index for Fuchsia.

Definition at line 68 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.GREEN = 11
staticprivate

Colour table index for Green.

Definition at line 77 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.GREY = 2
staticprivate

Colour table index for Grey.

Definition at line 50 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.LIME = 5
staticprivate

Colour table index for Lime.

Definition at line 59 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.MAROON = 10
staticprivate

Colour table index for Maroon.

Definition at line 74 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.NAVY = 12
staticprivate

Colour table index for Navy.

Definition at line 80 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.OLIVE = 15
static

Colour table index for Olive.

Definition at line 89 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.PURPLE = 14
staticprivate

Colour table index for Purple.

Definition at line 86 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.RED = 4
staticprivate

Colour table index for Red.

Definition at line 56 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.SILVER = 1
staticprivate

Colour table index for Silver.

Definition at line 47 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

short org.openoffice.xmerge.util.ColourConverter.tableLookup[] = null
private

Definition at line 91 of file ColourConverter.java.

final short org.openoffice.xmerge.util.ColourConverter.TEAL = 13
staticprivate

Colour table index for Teal.

Definition at line 83 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.WHITE = 3
staticprivate

Colour table index for White.

Definition at line 53 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().

final short org.openoffice.xmerge.util.ColourConverter.YELLOW = 9
staticprivate

Colour table index for Yellow.

Definition at line 71 of file ColourConverter.java.

Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB().


The documentation for this class was generated from the following file: