com.lizardtech.djvu.anno
Class DjVuAnno

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

public class DjVuAnno
extends DjVuObject
implements Codec

DjVuAnno implement the mechanism for annotating DjVuImages. Annotations are additional instructions for the plugin about how the image should be displayed. The exact format of annotations is not strictly defined. The only requirement is that they have to be stored as a sequence of chunks inside a FORM:ANNO.

This file implements annotations understood by the DjVu plugins and encoders.

using: contents of ANT chunks.

>

Contents of the FORM:ANNO should be passed to DjVuAnno.decode() for parsing, which initializes DjVuAnno.ANT and fills them with decoded data.

This is a top-level class containing annotations of a DjVu document (or just a page). It has only two functions: encode() and decode(). Both of them work with a sequence of annotation chunks from FORM:ANNO form. Basing on the name of the chunks they call encode() and decode() functions of the proper annotation structure (like ANT). The real work of encoding and decoding is done by lower-level classes.


Field Summary
static java.lang.String[] ALIGN_STRING_ARRAY
          The array of align specifications.
static int BACKGROUND
          Background mode.
static int BITONAL
          Bitonal mode.
static int BOTTOM
          Align bottom.
static int CENTER
          Align center.
static int COLOR
          Color mode.
static long DEFAULT_BG_COLOR
          The default background color.
static int FIT_PAGE
          Display fit page.
static int FIT_WIDTH
          Display fit width.
static int FOREGROUND
          Foreground mode.
static int LEFT
          Align left.
static java.lang.String[] MODE_STRING_ARRAY
          The array of legal mode specifications.
static int ONE2ONE
          Display 1 to 1.
static int RIGHT
          Align right.
static int STRETCH
          Display stretched.
static int TOP
          Align top.
static int UNSPEC
          Used for unspecifed.
static java.lang.String[] ZOOM_STRING_ARRAY
          The array of legal zoom specifications.
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
DjVuAnno()
          Creates a new DjVuAnno object.
 
Method Summary
static DjVuAnno createDjVuAnno(DjVuInterface ref)
          Creates an instance of DjVuAnno with the options interherited from the specified reference.
static int cvt_color(java.lang.String color, int retval)
          Converts color from string in #RRGGBB notation to a long.
 void decode(DataPool pool)
          Same as init() but adds the new data to what has been decoded before.
 long get_bg_color()
          Get background color in #0x00RRBBGG# format unless DEFAULT_BG_COLOR is used because there was no background color records in the annotation chunk.
 int getHorAlign()
          Get the horizontal alignment.
 java.util.Vector getMapArea()
          Get the vector of Rect, Oval, and Poly objects.
 int getMode()
          Get the display mode value.
 java.lang.String getRaw()
          Query the raw annotation string.
 int getVerAlign()
          Get the vertical alignment.
 int getZoom()
          Get the zoom value.
 DjVuAnno init(DataPool pool)
          Decodes contents of annotation chunk ANTa.
 boolean is_empty()
          Returns TRUE if no features are specified or specified features are not different from default ones
 boolean isImageData()
          Query if this is image data.
 void set_bg_color(long bg_color)
          Set background color in #0x00RRBBGG# format unless DEFAULT_BG_COLOR is used because there was no background color records in the annotation chunk.
 void setHorAlign(int hor_align)
          Set the horizontal alignment.
 void setMapArea(java.util.Vector map_area)
          Set the vector of Rect, Oval, and Poly objects.
 void setMode(int mode)
          Set the display mode value.
 void setRaw(java.lang.String raw)
          Set the raw annotation string.
 void setRaw(java.lang.StringBuffer raw)
          Set the raw annotation string.
 void setVerAlign(int ver_align)
          Set the vertical alignment.
 void setZoom(int zoom)
          Set the zoom value.
 
Methods inherited from class com.lizardtech.djvu.DjVuObject
checkLockTime, create, create, createSoftReference, createWeakReference, getDjVuOptions, getFromReference, invoke, setDjVuOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.lizardtech.djvu.DjVuInterface
getDjVuOptions, setDjVuOptions
 

Field Detail

DEFAULT_BG_COLOR

public static final long DEFAULT_BG_COLOR
The default background color.

See Also:
Constant Field Values

ZOOM_STRING_ARRAY

public static final java.lang.String[] ZOOM_STRING_ARRAY
The array of legal zoom specifications.


MODE_STRING_ARRAY

public static final java.lang.String[] MODE_STRING_ARRAY
The array of legal mode specifications.


ALIGN_STRING_ARRAY

public static final java.lang.String[] ALIGN_STRING_ARRAY
The array of align specifications.


UNSPEC

public static final int UNSPEC
Used for unspecifed.

See Also:
Constant Field Values

COLOR

public static final int COLOR
Color mode.

See Also:
Constant Field Values

FOREGROUND

public static final int FOREGROUND
Foreground mode.

See Also:
Constant Field Values

BACKGROUND

public static final int BACKGROUND
Background mode.

See Also:
Constant Field Values

BITONAL

public static final int BITONAL
Bitonal mode.

See Also:
Constant Field Values

STRETCH

public static final int STRETCH
Display stretched.

See Also:
Constant Field Values

ONE2ONE

public static final int ONE2ONE
Display 1 to 1.

See Also:
Constant Field Values

FIT_WIDTH

public static final int FIT_WIDTH
Display fit width.

See Also:
Constant Field Values

FIT_PAGE

public static final int FIT_PAGE
Display fit page.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Align left.

See Also:
Constant Field Values

CENTER

public static final int CENTER
Align center.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Align right.

See Also:
Constant Field Values

TOP

public static final int TOP
Align top.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Align bottom.

See Also:
Constant Field Values
Constructor Detail

DjVuAnno

public DjVuAnno()
Creates a new DjVuAnno object.

Method Detail

isImageData

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

Specified by:
isImageData in interface Codec
Returns:
false

createDjVuAnno

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

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

setHorAlign

public void setHorAlign(int hor_align)
Set the horizontal alignment. Allowed values are LEFT, CENTER, RIGHT and UNSPEC.

Parameters:
hor_align - desired horizontal alignment

getHorAlign

public int getHorAlign()
Get the horizontal alignment. Possible values are LEFT, CENTER, RIGHT and UNSPEC.

Returns:
horizontal alignment.

setMapArea

public void setMapArea(java.util.Vector map_area)
Set the vector of Rect, Oval, and Poly objects.

Parameters:
map_area - Vector of area maps.

getMapArea

public java.util.Vector getMapArea()
Get the vector of Rect, Oval, and Poly objects.

Returns:
the vector of area maps.

setMode

public void setMode(int mode)
Set the display mode value. Allowed values are UNSPEC, COLOR, FOREGROUND, BACKGROUND, BITONAL, and UNSPEC.

Parameters:
mode - the desired display mode

getMode

public int getMode()
Get the display mode value. Possible values are UNSPEC, COLOR, FOREGROUND, BACKGROUND, BITONAL, and UNSPEC.

Returns:
the desired display mode

setRaw

public void setRaw(java.lang.StringBuffer raw)
Set the raw annotation string.

Parameters:
raw - a buffer with the raw annotations

setRaw

public void setRaw(java.lang.String raw)
Set the raw annotation string.

Parameters:
raw - The raw annotation.

getRaw

public java.lang.String getRaw()
Query the raw annotation string.

Returns:
the raw annotation string.

setVerAlign

public void setVerAlign(int ver_align)
Set the vertical alignment. Allowed values are TOP, CENTER, BOTTOM and UNSPEC.

Parameters:
ver_align - the desired vertical alignment

getVerAlign

public int getVerAlign()
Get the vertical alignment. Possible values are TOP, CENTER, BOTTOM and UNSPEC.

Returns:
the desired vertical alignment

setZoom

public void setZoom(int zoom)
Set the zoom value. Allowed values are STRETCH, ONE2ONE, FIT_WIDTH, FIT_PAGE, UNSPEC, and any posative number.

Parameters:
zoom - the desired zoom mode

getZoom

public int getZoom()
Get the zoom value. Possible values are STRETCH, ONE2ONE, FIT_WIDTH, FIT_PAGE, UNSPEC, and any posative number.

Returns:
the desired zoom mode

cvt_color

public static int cvt_color(java.lang.String color,
                            int retval)
Converts color from string in #RRGGBB notation to a long.

Parameters:
color - the string with the formatted color.
retval - the default value to use if the string can not be converted
Returns:
The color value.

decode

public void decode(DataPool pool)
            throws java.io.IOException
Same as init() but adds the new data to what has been decoded before.

Specified by:
decode in interface Codec
Parameters:
pool - the annotation chunk.
Throws:
java.io.IOException - if an error occures

get_bg_color

public long get_bg_color()
Get background color in #0x00RRBBGG# format unless DEFAULT_BG_COLOR is used because there was no background color records in the annotation chunk.

Returns:
the desired background color.

init

public DjVuAnno init(DataPool pool)
              throws java.io.IOException
Decodes contents of annotation chunk ANTa. The chunk data is read from InputStream bs until reaching an end-of-stream marker. This function is normally called after a call to IFFInputStream.get_chunk().

Parameters:
pool - Stream to read data from.
Returns:
The decoded annotations.
Throws:
java.io.IOException - if an error occurs reading the stream.

is_empty

public boolean is_empty()
Returns TRUE if no features are specified or specified features are not different from default ones

Returns:
true if no features have bees specified.

set_bg_color

public void set_bg_color(long bg_color)
Set background color in #0x00RRBBGG# format unless DEFAULT_BG_COLOR is used because there was no background color records in the annotation chunk.

Parameters:
bg_color - the desired background color