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

◆ ColourConverter() [1/2]

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.

◆ ColourConverter() [2/2]

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.

References org.openoffice.xmerge.util.ColourConverter.tableLookup.

Member Function Documentation

◆ colourLookup()

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.

References org.openoffice.xmerge.util.ColourConverter.tableLookup.

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

◆ convertFromRGB()

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

◆ convertToRGB()

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

◆ getClosest() [1/2]

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

◆ getClosest() [2/2]

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, value, and x.

◆ indexLookup()

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, index, result, and org.openoffice.xmerge.util.ColourConverter.tableLookup.

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

◆ isGrey()

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

◆ AQUA

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

◆ BLACK

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

◆ BLUE

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

◆ FUCHSIA

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

◆ GREEN

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

◆ GREY

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

◆ LIME

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

◆ MAROON

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

◆ NAVY

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

◆ OLIVE

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

◆ PURPLE

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

◆ RED

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

◆ SILVER

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

◆ tableLookup

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

◆ TEAL

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

◆ WHITE

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

◆ YELLOW

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

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