com.lizardtech.djvu
Class Palette

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.Palette
All Implemented Interfaces:
Codec, DjVuInterface, java.lang.Cloneable

public class Palette
extends DjVuObject
implements java.lang.Cloneable, Codec

DOCUMENT ME!

Version:
$Revision: 1.5 $
Author:
$author$

Field Summary
 int[] colordata
          Contains an optional sequence of color indices.
static int DJVUPALETTEVERSION
          DOCUMENT ME!
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
Palette()
          Creates a new Palette object.
 
Method Summary
 java.lang.Object clone()
          DOCUMENT ME!
 int color_to_index(GPixel p)
          Returns the best palette index for representing color #bgr#.
static Palette createPalette(DjVuInterface ref)
          Creates an instance of Palette with the options interherited from the specified reference.
 void decode_rgb_entries(java.io.InputStream input, int palettesize)
          Reads palette colors.
 void decode(DataPool pool)
          Initializes the object by reading data from bytestream #bs#.
 void get_color(int nth, GPixel out)
          Returns colors from the color index sequence.
 GPixel[] getPalette()
          DOCUMENT ME!
 void index_to_color(int index, GPixel p)
          Overwrites #p# with the color located at position #index# in the palette.
 boolean isImageData()
          Query if this is image data.
 void setPalette(GPixel[] palette)
          DOCUMENT ME!
 int size()
          Returns the number of colors in the palette.
 
Methods inherited from class com.lizardtech.djvu.DjVuObject
checkLockTime, create, create, createSoftReference, createWeakReference, getDjVuOptions, getFromReference, invoke, setDjVuOptions
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.lizardtech.djvu.DjVuInterface
getDjVuOptions, setDjVuOptions
 

Field Detail

DJVUPALETTEVERSION

public static final int DJVUPALETTEVERSION
DOCUMENT ME!

See Also:
Constant Field Values

colordata

public int[] colordata
Contains an optional sequence of color indices. Function \Ref{encode} and \Ref{decode} also encode and decode this sequence when such a sequence is provided.

Constructor Detail

Palette

public Palette()
Creates a new Palette object.

Method Detail

isImageData

public boolean isImageData()
Query if this is image data.

Specified by:
isImageData in interface Codec
Returns:
true

setPalette

public void setPalette(GPixel[] palette)
DOCUMENT ME!

Parameters:
palette - DOCUMENT ME!

getPalette

public GPixel[] getPalette()
DOCUMENT ME!

Returns:
DOCUMENT ME!

createPalette

public static Palette createPalette(DjVuInterface ref)
Creates an instance of Palette with the options interherited from the specified reference.

Parameters:
ref - Object to interherit DjVuOptions from.
Returns:
a new instance of Palette.

clone

public java.lang.Object clone()
DOCUMENT ME!

Overrides:
clone in class java.lang.Object
Returns:
DOCUMENT ME!

get_color

public final void get_color(int nth,
                            GPixel out)
Returns colors from the color index sequence. Pixel #out# is overwritten with the color corresponding to the #nth# element of the color sequence \Ref{colordata}.

Parameters:
nth - DOCUMENT ME!
out - DOCUMENT ME!

size

public final int size()
Returns the number of colors in the palette.

Returns:
DOCUMENT ME!

color_to_index

public int color_to_index(GPixel p)
Returns the best palette index for representing color #bgr#.

Parameters:
p - DOCUMENT ME!
Returns:
DOCUMENT ME!

index_to_color

public final void index_to_color(int index,
                                 GPixel p)
Overwrites #p# with the color located at position #index# in the palette.

Parameters:
index - DOCUMENT ME!
p - DOCUMENT ME!

decode

public void decode(DataPool pool)
            throws java.io.IOException
Initializes the object by reading data from bytestream #bs#. This function reads a version byte, the palette size, the palette and the color index sequence from bytestream #bs#.

Specified by:
decode in interface Codec
Parameters:
pool - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

decode_rgb_entries

public void decode_rgb_entries(java.io.InputStream input,
                               int palettesize)
                        throws java.io.IOException
Reads palette colors. This function initializes the palette colors by reading #palettesize# RGB triples from bytestream #bs#.

Parameters:
input - DOCUMENT ME!
palettesize - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!