19package org.openoffice.xmerge.util;
44 private static final short BLACK = 0;
47 private static final short SILVER = 1;
50 private static final short GREY = 2;
53 private static final short WHITE = 3;
56 private static final short RED = 4;
59 private static final short LIME = 5;
62 private static final short BLUE = 6;
65 private static final short AQUA = 7;
71 private static final short YELLOW = 9;
74 private static final short MAROON = 10;
77 private static final short GREEN = 11;
80 private static final short NAVY = 12;
83 private static final short TEAL = 13;
86 private static final short PURPLE = 14;
89 public static final short OLIVE = 15;
227 return new Color(r, g, b);
245 short indexColour = 0;
246 int reducedMap[] =
new int[] { 0, 0, 128 };
248 int red = colour.getRed();
249 int green = colour.getGreen();
250 int blue = colour.getBlue();
254 if(red>0xC0 && green>0xC0 && blue>0xC0) {
275 if ((matchedRGB & 0xFF0000) == 0xFF0000 || (matchedRGB & 0xFF00) == 0xFF00
276 || (matchedRGB & 0xFF) == 0xFF) {
277 if ((matchedRGB & 0xFF0000) == 0x800000) {
278 matchedRGB ^= 0x800000;
280 if ((matchedRGB & 0xFF00) == 0x8000) {
281 matchedRGB ^= 0x8000;
283 if ((matchedRGB & 0xFF) == 0x80) {
300 switch (matchedRGB) {
383 int points[] =
new int[] { 0, 128, 255 };
398 if (
value < points[1]) {
399 int x =
value - points[0];
400 return (
Math.round((
float)
x / (points[1] - points[0])) == 1 ? points[1] : points[0]);
403 int x =
value - points[1];
404 return (
Math.round((
float)
x / (points[2] - points[1])) >= 1 ? points[2] : points[1]);
413 int points[] =
new int[] { 128, 192, 255 };
415 matchedRGB +=
getClosest(c.getRed(), points) << 16;
416 matchedRGB +=
getClosest(c.getGreen(), points) << 8;
417 matchedRGB +=
getClosest(c.getBlue(), points);
419 return matchedRGB == 0xC0C0C0;
Utility class mapping RGB colour specifications to the colour indices used in the Pocket PC.
static final short WHITE
Colour table index for White.
ColourConverter()
Default constructor used in the case where a lookup table is not required.
static final short BLACK
Colour table index for Black.
int getClosest(int value, int[] points)
Utility method that returns the closest of the three points to the value supplied.
static final short GREEN
Colour table index for Green.
short convertFromRGB(Color colour)
This method approximates an RGB value (as used by Writer) to one of the 16 available colours.
static final short MAROON
Colour table index for Maroon.
static final short FUCHSIA
Colour table index for Fuchsia.
static final short SILVER
Colour table index for Silver.
Color convertToRGB(short colour)
This method maps a Pocket Word colour index value to an RGB value as used by OpenOffice.
static final short PURPLE
Colour table index for Purple.
static final short AQUA
Colour table index for Aqua.
static final short LIME
Colour table index for Lime.
ColourConverter(short lookup[])
Constructor that passes in the colour lookup table.
int getClosest(int value)
Default implementation, checks for the closest of value to 0, 128 or 255.
static final short BLUE
Colour table index for Blue.
static final short RED
Colour table index for Red.
static final short OLIVE
Colour table index for Olive.
static final short YELLOW
Colour table index for Yellow.
static final short GREY
Colour table index for Grey.
static final short NAVY
Colour table index for Navy.
short indexLookup(short index)
Uses the colour table if it exists to translate default values to values in the colorTable.
boolean isGrey(Color c)
Checks to see if the supplied colour can be considered to be grey.
static final short TEAL
Colour table index for Teal.
short colourLookup(short colour)
Uses the colour table if it exists to translate default values to values in the colorTable.