LibreOffice Module xmerge (master) 1
|
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... | |
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.
|
inline |
Default constructor used in the case where a lookup table is not required.
Definition at line 96 of file ColourConverter.java.
|
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).
lookup | a 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.
|
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().
|
inline |
This method approximates an RGB value (as used by Writer) to one of the 16 available colours.
Most of the supported colours have their components set to either 0, 128 or 255. The exception is 'Grey' which is 0xC0C0C0.
colour | Color object representing the RGB value of the colour. |
Definition at line 243 of file ColourConverter.java.
References org.openoffice.xmerge.util.ColourConverter.AQUA, org.openoffice.xmerge.util.ColourConverter.BLACK, org.openoffice.xmerge.util.ColourConverter.BLUE, org.openoffice.xmerge.util.ColourConverter.colourLookup(), org.openoffice.xmerge.util.ColourConverter.FUCHSIA, org.openoffice.xmerge.util.ColourConverter.getClosest(), org.openoffice.xmerge.util.ColourConverter.GREEN, org.openoffice.xmerge.util.ColourConverter.GREY, org.openoffice.xmerge.util.ColourConverter.isGrey(), org.openoffice.xmerge.util.ColourConverter.LIME, org.openoffice.xmerge.util.ColourConverter.MAROON, org.openoffice.xmerge.util.ColourConverter.NAVY, org.openoffice.xmerge.util.ColourConverter.OLIVE, org.openoffice.xmerge.util.ColourConverter.PURPLE, org.openoffice.xmerge.util.ColourConverter.RED, org.openoffice.xmerge.util.ColourConverter.SILVER, org.openoffice.xmerge.util.ColourConverter.TEAL, org.openoffice.xmerge.util.ColourConverter.WHITE, and org.openoffice.xmerge.util.ColourConverter.YELLOW.
|
inline |
This method maps a Pocket Word colour index value to an RGB value as used by OpenOffice.
colour | The index into Pocket Word's colour table. |
Color
object representing the RGB value of the Pocket Word colour. Definition at line 152 of file ColourConverter.java.
References org.openoffice.xmerge.util.ColourConverter.AQUA, org.openoffice.xmerge.util.ColourConverter.BLACK, org.openoffice.xmerge.util.ColourConverter.BLUE, Color, org.openoffice.xmerge.util.ColourConverter.FUCHSIA, org.openoffice.xmerge.util.ColourConverter.GREEN, org.openoffice.xmerge.util.ColourConverter.GREY, index, org.openoffice.xmerge.util.ColourConverter.indexLookup(), org.openoffice.xmerge.util.ColourConverter.LIME, org.openoffice.xmerge.util.ColourConverter.MAROON, org.openoffice.xmerge.util.ColourConverter.NAVY, org.openoffice.xmerge.util.ColourConverter.OLIVE, org.openoffice.xmerge.util.ColourConverter.PURPLE, org.openoffice.xmerge.util.ColourConverter.RED, org.openoffice.xmerge.util.ColourConverter.SILVER, org.openoffice.xmerge.util.ColourConverter.TEAL, org.openoffice.xmerge.util.ColourConverter.WHITE, and org.openoffice.xmerge.util.ColourConverter.YELLOW.
Default implementation, checks for the closest of value to 0, 128 or 255.
Definition at line 382 of file ColourConverter.java.
References org.openoffice.xmerge.util.ColourConverter.getClosest(), and value.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), org.openoffice.xmerge.util.ColourConverter.getClosest(), and org.openoffice.xmerge.util.ColourConverter.isGrey().
Utility method that returns the closest of the three points to the value supplied.
Definition at line 392 of file ColourConverter.java.
|
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().
|
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().
|
staticprivate |
Colour table index for Aqua.
Definition at line 65 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Black.
Definition at line 44 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Blue.
Definition at line 62 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Fuchsia.
Definition at line 68 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Green.
Definition at line 77 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Grey.
Definition at line 50 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Lime.
Definition at line 59 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Maroon.
Definition at line 74 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Navy.
Definition at line 80 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
static |
Colour table index for Olive.
Definition at line 89 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Purple.
Definition at line 86 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Red.
Definition at line 56 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Silver.
Definition at line 47 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
private |
Definition at line 91 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.ColourConverter(), org.openoffice.xmerge.util.ColourConverter.colourLookup(), and org.openoffice.xmerge.util.ColourConverter.indexLookup().
|
staticprivate |
Colour table index for Teal.
Definition at line 83 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for White.
Definition at line 53 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().
|
staticprivate |
Colour table index for Yellow.
Definition at line 71 of file ColourConverter.java.
Referenced by org.openoffice.xmerge.util.ColourConverter.convertFromRGB(), and org.openoffice.xmerge.util.ColourConverter.convertToRGB().