Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## waba.fx
Class Palette

    java.lang.Object
      |
      +--waba.fx.Palette

public final class Palette
extends Object

Palette represents a ordered group of colors. Palette only supports up to 256 colors, since memory is critical, supporting 16k would fill all waba memory heap. To make this Palette active, use Graphics.applyPalette. In PalmOS, the System palette is as follows:

In Color devices:

00 - FFFFFF | 01 - FFCCFF | 02 - FF99FF | 03 - FF66FF | 04 - FF33FF | 05 - FF00FF
06 - FFFFCC | 07 - FFCCCC | 08 - FF99CC | 09 - FF66CC | 0A - FF33CC | 0B - FF00CC
0C - FFFF99 | 0D - FFCC99 | 0E - FF9999 | 0F - FF6699 | 10 - FF3399 | 11 - FF0099
12 - CCFFFF | 13 - CCCCFF | 14 - CC99FF | 15 - CC66FF | 16 - CC33FF | 17 - CC00FF
18 - CCFFCC | 19 - CCCCCC | 1A - CC99CC | 1B - CC66CC | 1C - CC33CC | 1D - CC00CC
1E - CCFF99 | 1F - CCCC99 | 20 - CC9999 | 21 - CC6699 | 22 - CC3399 | 23 - CC0099
24 - 99FFFF | 25 - 99CCFF | 26 - 9999FF | 27 - 9966FF | 28 - 9933FF | 29 - 9900FF
2A - 99FFCC | 2B - 99CCCC | 2C - 9999CC | 2D - 9966CC | 2E - 9933CC | 2F - 9900CC
30 - 99FF99 | 31 - 99CC99 | 32 - 999999 | 33 - 996699 | 34 - 993399 | 35 - 990099
36 - 66FFFF | 37 - 66CCFF | 38 - 6699FF | 39 - 6666FF | 3A - 6633FF | 3B - 6600FF
3C - 66FFCC | 3D - 66CCCC | 3E - 6699CC | 3F - 6666CC | 40 - 6633CC | 41 - 6600CC
42 - 66FF99 | 43 - 66CC99 | 44 - 669999 | 45 - 666699 | 46 - 663399 | 47 - 660099
48 - 33FFFF | 49 - 33CCFF | 4A - 3399FF | 4B - 3366FF | 4C - 3333FF | 4D - 3300FF
4E - 33FFCC | 4F - 33CCCC | 50 - 3399CC | 51 - 3366CC | 52 - 3333CC | 53 - 3300CC
54 - 33FF99 | 55 - 33CC99 | 56 - 339999 | 57 - 336699 | 58 - 333399 | 59 - 330099
5A - 00FFFF | 5B - 00CCFF | 5C - 0099FF | 5D - 0066FF | 5E - 0033FF | 5F - 0000FF
60 - 00FFCC | 61 - 00CCCC | 62 - 0099CC | 63 - 0066CC | 64 - 0033CC | 65 - 0000CC
66 - 00FF99 | 67 - 00CC99 | 68 - 009999 | 69 - 006699 | 6A - 003399 | 6B - 000099
6C - FFFF66 | 6D - FFCC66 | 6E - FF9966 | 6F - FF6666 | 70 - FF3366 | 71 - FF0066
72 - FFFF33 | 73 - FFCC33 | 74 - FF9933 | 75 - FF6633 | 76 - FF3333 | 77 - FF0033
78 - FFFF00 | 79 - FFCC00 | 7A - FF9900 | 7B - FF6600 | 7C - FF3300 | 7D - FF0000
7E - CCFF66 | 7F - CCCC66 | 80 - CC9966 | 81 - CC6666 | 82 - CC3366 | 83 - CC0066
84 - CCFF33 | 85 - CCCC33 | 86 - CC9933 | 87 - CC6633 | 88 - CC3333 | 89 - CC0033
8A - CCFF00 | 8B - CCCC00 | 8C - CC9900 | 8D - CC6600 | 8E - CC3300 | 8F - CC0000
90 - 99FF66 | 91 - 99CC66 | 92 - 999966 | 93 - 996666 | 94 - 993366 | 95 - 990066
96 - 99FF33 | 97 - 99CC33 | 98 - 999933 | 99 - 996633 | 9A - 993333 | 9B - 990033
9C - 99FF00 | 9D - 99CC00 | 9E - 999900 | 9F - 996600 | A0 - 993300 | A1 - 990000
A2 - 66FF66 | A3 - 66CC66 | A4 - 669966 | A5 - 666666 | A6 - 663366 | A7 - 660066
A8 - 66FF33 | A9 - 66CC33 | AA - 669933 | AB - 666633 | AC - 663333 | AD - 660033
AE - 66FF00 | AF - 66CC00 | B0 - 669900 | B1 - 666600 | B2 - 663300 | B3 - 660000
B4 - 33FF66 | B5 - 33CC66 | B6 - 339966 | B7 - 336666 | B8 - 333366 | B9 - 330066
BA - 33FF33 | BB - 33CC33 | BC - 339933 | BD - 336633 | BE - 333333 | BF - 330033
C0 - 33FF00 | C1 - 33CC00 | C2 - 339900 | C3 - 336600 | C4 - 333300 | C5 - 330000
C6 - 00FF66 | C7 - 00CC66 | C8 - 009966 | C9 - 006666 | CA - 003366 | CB - 000066
CC - 00FF33 | CD - 00CC33 | CE - 009933 | CF - 006633 | D0 - 003333 | D1 - 000033
D2 - 00FF00 | D3 - 00CC00 | D4 - 009900 | D5 - 006600 | D6 - 003300 | D7 - 111111
D8 - 222222 | D9 - 444444 | DA - 555555 | DB - 777777 | DC - 888888 | DD - AAAAAA
DE - BBBBBB | DF - DDDDDD | E0 - EEEEEE | E1 - C0C0C0 | E2 - 800000 | E3 - 800080
E4 - 008000 | E5 - 008080 | E6 - 000000 | E7 - 000000 | E8 - 000000 | E9 - 000000
EA - 000000 | EB - 000000 | EC - 000000 | ED - 000000 | EE - 000000 | EF - 000000
F0 - 000000 | F1 - 000000 | F2 - 000000 | F3 - 000000 | F4 - 000000 | F5 - 000000
F6 - 000000 | F7 - 000000 | F8 - 000000 | F9 - 000000 | FA - 000000 | FB - 000000
FC - 000000 | FD - 000000 | FE - 000000 | FF - 060003

In GrayScale devices with PalmOS version greater or equal to 3.5 that supports 16 colors:

00 - FFFFFF | 01 - EEEEEE | 02 - DDDDDD | 03 - CCCCCC | 04 - BBBBBB | 05 - AAAAAA
06 - 999999 | 07 - 888888 | 08 - 777777 | 09 - 666666 | 0A - 555555 | 0B - 444444
0C - 333333 | 0D - 222222 | 0E - 111111 | 0F - 000000

In GrayScale devices with PalmOS version prior to 3.5 that supports 4 colors:

00 - FFFFFF | 01 - BFBFBF | 02 - 7F7F7F | 03 - 000000

The following code generate a new palette with the 216 web safe colors:

     int[] samples = {0x00, 0x33, 0x66, 0x99, 0xcc, 0xff};
     int index = 0;
     for (int r = 0; r < 6; r++)
        for (int g = 0; g < 6; g++)
           for (int b = 0; b < 6; b++)
           {
              Color c = new Color(samples[r], samples[g], samples[b]);
           }

Field Summary
`static int[]` | `default16PaletteDev2Scr`
`static int[]` | `default16PaletteScr2Dev`
`static int[]` | `default4PaletteDev2Scr`
`static int[]` | `default4PaletteScr2Dev`
`static Palette` | `SystemPalette` System palette.

Constructor Summary
`Palette()` Create a palette containing the current applied palette.
`Palette(Color[] colors)` Create a Palette with the given colors array. if the array length is > 256 or the array is null, the system palette is assigned.
`Palette(int[] colorRGBs)` construct the palette getting the rgb values from the int array

Method Summary
`int` | `find(Color color)` does a linear search for the given color in this palette and returns its index. if not found, return -1.
`int` | `findNearest(Color color)` search for the nearest color of the given color in this palette and return its index.
`Color` | `getColor(int index)` gets the color from the given index. it puts index in the range, if necessary.
`int` | `getColorIndex(Color color)` Gets the color index of the given color in this Palette.
`Color[]` | `getColors()` returns a copy of the color array assigned with this Palette
`static int[]` | `getDeviceRGBs()`
`void` | `setColor(int index, Color color)` sets the color in the given index
`void` | `setColors(Color[] aColor, int toIndex)` sets a range of colors in this palette, replacing all colors from toIndex to toIndex+aColor.length-1.
`int` | `size()` returns the number of colors in this palette
`int[]` | `toRGBArray(int startIndex, int endIndex)` return an int array containing the rgb values of this palette, from startIndex to endIndex (including it).

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, toString, wait, wait`

Field Detail

### default16PaletteScr2Dev

    public static final int[] default16PaletteScr2Dev

### default16PaletteDev2Scr

    public static final int[] default16PaletteDev2Scr

### default4PaletteScr2Dev

    public static final int[] default4PaletteScr2Dev

### default4PaletteDev2Scr

    public static final int[] default4PaletteDev2Scr

### SystemPalette

    public static final Palette SystemPalette

  System palette. In Palm OS, if color, this is the WebSafe palette; if gray scale, this is a gray palette with 4 or 16 colors

Constructor Detail

### Palette

    public Palette()

  Create a palette containing the current applied palette. In PalmOS it is the WebSafe palette if in color or a gray palette if not color. You can also use the SystemPalette to get the default system palette.

### Palette

    public Palette(Color[] colors)

  Create a Palette with the given colors array. if the array length is > 256 or the array is null, the system palette is assigned.

### Palette

    public Palette(int[] colorRGBs)

  construct the palette getting the rgb values from the int array

Method Detail

### toRGBArray

    public int[] toRGBArray(int startIndex,
                            int endIndex)

  return an int array containing the rgb values of this palette, from startIndex to endIndex (including it). You can pass -1,-1 to include all palette; or 100,-1 to get from 100 up to the last element. This method is useful to save this palette into a stream.
  Returns:
    a sub-array containing only the colors whoose indexes you asked for.

### getColors

    public Color[] getColors()

  returns a copy of the color array assigned with this Palette

### setColor

    public void setColor(int index,
                         Color color)

  sets the color in the given index

### setColors

    public void setColors(Color[] aColor,
                          int toIndex)

  sets a range of colors in this palette, replacing all colors from toIndex to toIndex+aColor.length-1.

### getColor

    public Color getColor(int index)

  gets the color from the given index. it puts index in the range, if necessary.

### size

    public int size()

  returns the number of colors in this palette

### find

    public int find(Color color)

  does a linear search for the given color in this palette and returns its index. if not found, return -1.

### findNearest

    public int findNearest(Color color)

  search for the nearest color of the given color in this palette and return its index.

### getColorIndex

    public int getColorIndex(Color color)

  Gets the color index of the given color in this Palette. If the color isnt in this palette, returns the nearest color index. The searched colors are stored in a hash table to improve performance

### getDeviceRGBs

    public static int[] getDeviceRGBs()

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD