## org.apache.poi.hssf.record
Class PaletteRecord

    java.lang.Object
      org.apache.poi.hssf.record.Record
          org.apache.poi.hssf.record.PaletteRecord

public class PaletteRecord
extends Record

PaletteRecord - Supports custom palettes.

Version:
  2.0-pre
Author:
  Andrew C. Oliver (acoliver at apache dot org), Brian Sanders (bsanders at risklabs dot com) - custom palette editing

Field Summary
`static short` `FIRST_COLOR_INDEX` The byte index of the first color
`static short` `sid`
`static byte` `STANDARD_PALETTE_SIZE` The standard size of an XLS palette

Constructor Summary
`PaletteRecord()`
`PaletteRecord(short id)` Constructs a custom palette with the default set of colors
`PaletteRecord(short id, short size, byte[] data)` Constructs a PaletteRecord record and sets its fields appropriately.
`PaletteRecord(short id, short size, byte[] data, int offset)` Constructs a PaletteRecord record and sets its fields appropriately.

Method Summary
`protected void` `fillFields(byte[] data, short size, int offset)` called by the constructor, should set class level fields.
`byte[]` `getColor(short byteIndex)` Returns the color value at a given index
`static byte[]` `getDefaultData()` Returns the default palette as PaletteRecord binary data
`int` `getRecordSize()` gives the current serialized size of the record.
`short` `getSid()` return the non static version of the id for this record.
`int` `serialize(int offset, byte[] data)` called by the class that is responsible for writing this sucker.
`void` `setColor(short byteIndex, byte red, byte green, byte blue)` Sets the color value at a given index If the given index is greater than the current last color index, then black is inserted at every index required to make the palette continuous.
`java.lang.String` `toString()` get a string representation of the record (for biffview/debugging)
`protected void` `validateSid(short id)` called by constructor, should throw runtime exception in the event of a record passed with a differing ID.

Methods inherited from class org.apache.poi.hssf.record.Record
`clone, fillFields, isInValueSection, isValue, processContinueRecord, serialize`

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

Field Detail

### sid

    public static final short sid

See Also:
  Constant Field Values

### STANDARD_PALETTE_SIZE

    public static final byte STANDARD_PALETTE_SIZE

  The standard size of an XLS palette

  See Also:
    Constant Field Values

### FIRST_COLOR_INDEX

    public static final short FIRST_COLOR_INDEX

  The byte index of the first color

  See Also:
    Constant Field Values

Constructor Detail

### PaletteRecord

    public PaletteRecord()

### PaletteRecord

    public PaletteRecord(short id)

  Constructs a custom palette with the default set of colors

### PaletteRecord

    public PaletteRecord(short id,
                         short size,
                         byte[] data)

  Constructs a PaletteRecord record and sets its fields appropriately.

Parameters:
  `id` - id must be 0x92 or an exception will be throw upon validation
  `size` - the size of the data area of the record
  `data` - data of the record (should not contain sid/len)

### PaletteRecord

    public PaletteRecord(short id,
                         short size,
                         byte[] data,
                         int offset)

  Constructs a PaletteRecord record and sets its fields appropriately.

Parameters:
  `id` - id must be 0x0A or an exception will be throw upon validation
  `size` - the size of the data area of the record
  `data` - data of the record (should not contain sid/len)
  `offset` - of the record's data

Method Detail

### validateSid

    protected void validateSid(short id)

  Description copied from class: `Record`
  called by constructor, should throw runtime exception in the event of a record passed with a differing ID.

  Specified by:
    `validateSid` in class `Record`
  Parameters:
    `id` - alleged id for this record

### fillFields

    protected void fillFields(byte[] data,
                              short size,
                              int offset)

  Description copied from class: `Record`
  called by the constructor, should set class level fields. Should throw runtime exception for bad/icomplete data.

  Specified by:
    `fillFields` in class `Record`
  Parameters:
    `data` - raw data
    `size` - size of data
    `offset` - of the record's data (provided a big array of the file)

### toString

    public java.lang.String toString()

  Description copied from class: `Record`
  get a string representation of the record (for biffview/debugging)

  Overrides:
    `toString` in class `Record`

### serialize

    public int serialize(int offset,
                         byte[] data)

  Description copied from class: `Record`
  called by the class that is responsible for writing this sucker. Subclasses should implement this so that their data is passed back in a byte array.

  Specified by:
    `serialize` in class `Record`
  Parameters:
    `offset` - to begin writing at
    `data` - byte array containing instance data
  Returns:
    number of bytes written

### getRecordSize

    public int getRecordSize()

  Description copied from class: `Record`
  gives the current serialized size of the record. Should include the sid and reclength (4 bytes).

  Overrides:
    `getRecordSize` in class `Record`

### getSid

    public short getSid()

  Description copied from class: `Record`
  return the non static version of the id for this record.

  Specified by:
    `getSid` in class `Record`

### getColor

    public byte[] getColor(short byteIndex)

  Returns the color value at a given index

  Returns:
    the RGB triplet for the color, or null if the specified index does not exist

### setColor

    public void setColor(short byteIndex,
                         byte red,
                         byte green,
                         byte blue)

  Sets the color value at a given index If the given index is greater than the current last color index, then black is inserted at every index required to make the palette continuous.

### getDefaultData

    public static byte[] getDefaultData()

  Returns the default palette as PaletteRecord binary data

  See Also:
    `Workbook.createPalette()`

Copyright © 2003 Apache Software Foundation.