|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lizardtech.djvu.DjVuObject
com.lizardtech.djvu.DjVuPage
public class DjVuPage
DjVuPage decodes single page DjVu files. This class is appropriate for decoding a single page. If an INCL chunk is contained in the page, then either decoding must be done from a URL or createDataPool must be overloaded as in the case of the Document class. The general usage of this class is to create an instance, set any desired values, and then call decode with the relevant data. Decoding may be done either asynchronously or synchronously. By default decoding is synchronous, but this may be changed by calling setAsync(true) before calling decode. If you will be accessing this class from another thread while decoding is in progress then you should use asynchronous mode.
In synchronous mode, the decode method will not return until decoding is complete. In asynchronous mode decode returns right away as decoding continues in a separate thread. One method to track asynchronous decode progress is to register a PropertyChangeListener. Each codec will generate a signal when created. If you need to wait for a particular codec, rather than polling, use the waitForCodec method.
The updateMap method should be used for progressive rendering. The following example shows how to progressively update an image map in a separate thread.
class Progressive extends Thread { GMap map = null; GRect segment; int subsample; final DjVuPage page; ... define constructors and other methods here ... public void run() { boolean repeat; do { repeat=page.isDecoding(); map=page.updateMap(map,segment,subsample); // get the map // We limit our wait to 200 ms, to query updates for new // segment or subsample values. This also limits our wait // wait time when the page is updated before waitForCodec // obtains a lock. page.waitForCodec(progressLock,200L); } while(repeat); } }
Field Summary | |
---|---|
java.lang.Object |
annoLock
Lock used for accessing the annotation codec. |
java.lang.Object |
bgIWPixmapLock
Lock used for accessing the background IWPixmap codec. |
static int |
DJVUVERSION
This is the version of DjVu this code was written for. |
static int |
DJVUVERSION_TOO_NEW
This is the newest version of DjVu we should attempt to decode. |
static int |
DJVUVERSION_TOO_OLD
This is the oldest version of DjVu we can hope to decode. |
java.lang.Object |
doneLock
Lock to signal decoding is done. |
java.lang.Object |
fgIWPixmapLock
Lock used for accessing the foreground IWPixmap codec. |
java.lang.Object |
fgJb2DictLock
Lock used for accessing the foreground JB2Dict codec. |
java.lang.Object |
fgJb2Lock
Lock used for accessing the foreground JB2 codec. |
java.lang.Object |
fgPaletteLock
Lock used for accessing the foreground Palette codec. |
java.lang.Object |
infoLock
Lock used for accessing the info codec. |
static int |
MAX_PRIORITY
|
java.lang.String |
mimetype
The mimetype of this document. |
static int |
MIN_PRIORITY
|
protected java.lang.Number |
progressiveCount
Number incremented each time the image pixels are updated. |
java.lang.Object |
progressiveLock
Lock to signal any image update, for progressive rendering. |
protected static int |
queueCount
|
protected static java.lang.Thread |
queueThread
The thread used for asynchronious decoding. |
protected static java.util.Vector[] |
queueVector
An array of vectors listing pages which need decoding. |
protected DataPool |
sjbzChunk
The shared dictionary data. |
java.lang.Object |
textLock
Lock used for accessing the text codec. |
protected java.net.URL |
url
The URL for this page. |
Fields inherited from class com.lizardtech.djvu.DjVuObject |
---|
hasReferences |
Constructor Summary | |
---|---|
DjVuPage()
Creates a new DjVuPage object. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a listener for property change events. |
protected void |
clean(java.lang.String chkid)
Called after processing each chunk to log progress and optionally run the garbage collector. |
static int |
compute_red(int w,
int h,
int rw,
int rh)
Compute the subsample rate used. |
static DjVuPage |
createDjVuPage(DjVuInterface ref)
Creates an instance of DjVuPage with the options interherited from the specified reference. |
com.lizardtech.djvu.GPixmapScaler |
createGPixmapScaler(int inw,
int inh,
int outw,
int outh)
Called to create an instance of GPixmapScaler |
void |
decode(DataPool pool)
Decode the specified DataPool. |
void |
decode(java.net.URL url)
Decode the specified URL. |
protected void |
decodeChunk(IFFInputStream iff,
java.lang.String chkid,
boolean isInclude)
Called to decode a chunk. |
protected void |
decodeChunks(IFFInputStream iff,
boolean isInclude)
Called to decode chunks. |
protected void |
decodeInclude(DataPool pool)
Called to decode an include chunk. |
GBitmap |
get_bitmap(GRect rect,
int subsample,
int align,
java.util.Vector components)
Get a bitmap for the specifed region |
Codec |
getAnno()
Query the Anno Codec for this page. |
IWPixmap |
getBgIWPixmap()
Query the background IWPixmap codec for this page. |
GPixmap |
getBgPixmap(GRect rect,
int subsample,
double gamma,
GPixmap retval)
Get the background pixmap. |
GBitmap |
getBitmap(GRect rect,
int subsample,
int align,
GBitmap retval)
Get the foreground bitmap. |
Codec |
getCodec(java.lang.Object nameLock)
Query the named Codec for this page. |
IWPixmap |
getFgIWPixmap()
Query the foreground IWPixmap for this page. |
JB2Image |
getFgJb2()
Query the foreground Jb2 codec for this page. |
JB2Dict |
getFgJb2Dict()
Query the foreground Jb2 Dict codec for this page. |
Palette |
getFgPalette()
Query the foreground palette codec for this page. |
GPixmap |
getFgPixmap()
Query the foreground pixmap for this page. |
DjVuInfo |
getInfo()
Query the DjVuInfo for this page. |
DjVuInfo |
getInfoWait()
Query the DjVuInfo for this page. |
GMap |
getMap(GRect segment,
int subsample,
GMap retval)
Create a new map. |
GPixmap |
getPixmap(GRect rect,
int subsample,
double gamma,
GPixmap retval)
Get the pixmap for the desired region. |
int |
getPriority()
Query if the asynchronous flag is set. |
int |
getProgressiveCount()
Query the progressive count. |
java.lang.String |
getStatus()
Query the status string. |
Codec |
getText()
Query the hidden text Codec for this page. |
boolean |
hasCodec(java.lang.Object nameLock)
Query if the specified codec is available. |
boolean |
is_legal_bilevel()
Query if this is a bitonal image. |
boolean |
is_legal_compound()
Query if this is a compound image. |
boolean |
is_legal_photo()
Test if this is a photo image. |
boolean |
isAsync()
Query if the asynchronous flag is set. |
boolean |
isColor()
Query if this is a compound or photo DjVu page. |
boolean |
isDecoding()
Query if the thread is alive and processing. |
protected void |
parseSjbz(java.io.InputStream input)
Called to parse jb2 data. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a listener for PropertyChangeEvent. |
void |
run()
This thread processes the asynchronous queue. |
void |
setAsync(boolean value)
Set the flag to allow or disallow asynchronous operations. |
void |
setPriority(int value)
Set the decode priority. |
void |
setStatus(java.lang.String status)
Set the status string and fire a property change event "status". |
boolean |
stencil(GPixmap pm,
GRect rect,
int subsample,
double gamma)
Create an image by stenciling the foreground onto the background. |
GMap |
updateMap(GMap map,
GRect segment,
int subsample)
Update an image map based on an existing one. |
Codec |
waitForCodec(java.lang.Object nameLock,
long maxTime)
Query the named Codec for this page. |
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 |
Field Detail |
---|
public static final int DJVUVERSION
public static final int DJVUVERSION_TOO_OLD
public static final int DJVUVERSION_TOO_NEW
protected static java.lang.Thread queueThread
protected static java.util.Vector[] queueVector
protected static int queueCount
public static int MAX_PRIORITY
public static int MIN_PRIORITY
public final java.lang.Object annoLock
public final java.lang.Object bgIWPixmapLock
public final java.lang.Object doneLock
public final java.lang.Object fgIWPixmapLock
public final java.lang.Object fgJb2DictLock
public final java.lang.Object fgJb2Lock
public final java.lang.Object fgPaletteLock
public final java.lang.Object infoLock
public final java.lang.Object progressiveLock
public final java.lang.Object textLock
public java.lang.String mimetype
protected DataPool sjbzChunk
protected java.lang.Number progressiveCount
protected java.net.URL url
Constructor Detail |
---|
public DjVuPage()
Method Detail |
---|
public final void setAsync(boolean value)
value
- true if asynchronous operations should be used.public final boolean isAsync()
public final void setPriority(int value)
value
- the decode prioritypublic final int getPriority()
public GPixmap getBgPixmap(GRect rect, int subsample, double gamma, GPixmap retval)
rect
- area to rendersubsample
- rate to subsamplegamma
- color correction factorretval
- an old pixmap to reuse rather than allocating more memory
public final GBitmap getBitmap(GRect rect, int subsample, int align, GBitmap retval)
rect
- area of interestsubsample
- rate to subsamplealign
- number of alignment pixelsretval
- an old image to fill rather than creating a new image
public boolean isColor()
public final boolean isDecoding()
public Codec getAnno()
public IWPixmap getBgIWPixmap()
public Codec getCodec(java.lang.Object nameLock)
nameLock
- DOCUMENT ME!
public final GMap getMap(GRect segment, int subsample, GMap retval)
segment
- The bounding rectangle of the subsampled segment.subsample
- The subsample rate.retval
- an old image to fill rather than creating a new image
public IWPixmap getFgIWPixmap()
public JB2Image getFgJb2()
public JB2Dict getFgJb2Dict()
public Palette getFgPalette()
public GPixmap getFgPixmap()
public DjVuInfo getInfo()
public DjVuInfo getInfoWait()
public int getProgressiveCount()
public Codec getText()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- to addpublic static int compute_red(int w, int h, int rw, int rh)
w
- full size widthh
- fill size heightrw
- reduced widthrh
- reduced height
public static DjVuPage createDjVuPage(DjVuInterface ref)
ref
- Object to interherit DjVuOptions from.
public com.lizardtech.djvu.GPixmapScaler createGPixmapScaler(int inw, int inh, int outw, int outh)
inw
- Source image width.inh
- Source image height.outw
- Destination image width.outh
- Destination image height.
public void decode(java.net.URL url) throws java.io.IOException
url
- URL to decode.
java.io.IOException
- if an error occures.public void decode(DataPool pool) throws java.io.IOException
pool
- DataPool to decode.
java.io.IOException
- if an error occures.
java.lang.IllegalStateException
- DOCUMENT ME!public boolean hasCodec(java.lang.Object nameLock)
nameLock
- DOCUMENT ME!
public boolean is_legal_photo()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- to removepublic final GMap updateMap(GMap map, GRect segment, int subsample)
map
- The existing map.segment
- The bounding rectangle of the subsampled segment.subsample
- The subsample rate.
public GPixmap getPixmap(GRect rect, int subsample, double gamma, GPixmap retval)
rect
- area of interestsubsample
- rate to subsamplegamma
- color correction factorretval
- an old image to use instead of creating a new one
public GBitmap get_bitmap(GRect rect, int subsample, int align, java.util.Vector components)
rect
- area of interestsubsample
- subsample ratealign
- border alignmentcomponents
- a list of components
public boolean is_legal_bilevel()
public boolean is_legal_compound()
public void run()
run
in interface java.lang.Runnable
public void setStatus(java.lang.String status)
status
- new status stringpublic java.lang.String getStatus()
public boolean stencil(GPixmap pm, GRect rect, int subsample, double gamma)
pm
- the background image to stencilrect
- the area of the page being stenciledsubsample
- the subsample rate of the area being stenciledgamma
- the color correction factor
public Codec waitForCodec(java.lang.Object nameLock, long maxTime)
nameLock
- the name lock of the codec to wait formaxTime
- the maximum amount of time to wait for the specified
codec
protected void clean(java.lang.String chkid)
chkid
- name of chunk processedprotected void decodeChunk(IFFInputStream iff, java.lang.String chkid, boolean isInclude) throws java.io.IOException
iff
- stream being processedchkid
- name of the current chunkisInclude
- true if this is an include file stream
java.io.IOException
- if an error occurs
java.lang.IllegalStateException
- if an error occursprotected void decodeChunks(IFFInputStream iff, boolean isInclude) throws java.io.IOException
iff
- stream being processedisInclude
- true if this is an include file stream
java.io.IOException
- if an error occursprotected void decodeInclude(DataPool pool) throws java.io.IOException
pool
- chunk to be read
java.io.IOException
- if an error occurs
java.lang.IllegalStateException
- if an error occursprotected void parseSjbz(java.io.InputStream input) throws java.io.IOException
input
- stream to parse
java.io.IOException
- if an error occurs
java.lang.IllegalStateException
- if an error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |