com.lizardtech.djvubean
Class DjVuImage

java.lang.Object
  extended by com.lizardtech.djvubean.DjVuImage

public class DjVuImage
extends java.lang.Object

This class is used to represent a DjVuPage object as a Vector of buffered images, for displaying in a viewport.


Field Summary
static java.awt.Color BLACK
          A constant indicating the color blue.
static java.awt.Color BLUE
          A constant indicating the color blue.
static boolean BROKEN_XOR
           
static java.lang.reflect.Constructor colorConstructor
          Test to determine java version.
static int FIT_PAGE
          Magic scale value used to zoom to fit page.
static int FIT_WIDTH
          Magic scale value used to zoom to fit width.
static java.awt.Color WHITE
          A constant indicating the color white.
static int XOR_HILITE
          Special value for XOR HIGHLIGHTING
 
Constructor Summary
DjVuImage(DjVuPage djvuPage, boolean favorFast)
          Creates a new DjVuImage object.
DjVuImage(DjVuPage djvuPage, int zoom, java.awt.Dimension size, boolean favorFast)
          Creates a new DjVuImage object.
DjVuImage(DjVuPage djvuPage, int width, int height, boolean favorFast)
          Creates a new DjVuImage object.
 
Method Summary
 java.awt.Rectangle computeScaledBounds(int zoom, java.awt.Dimension size)
          Compute the page size scaled at the appropriate zoom.
static java.awt.Color createColor(int rgb, int alpha)
          Equivalent to new Color(rgb,hasAlpha).
 void draw(java.awt.Component parent, java.awt.Graphics g, java.awt.image.ImageObserver observer)
          Called to create one or more images to draw to.
 void drawHighlight(java.awt.Graphics g, boolean useXOR)
          Called to paint the highlight areas onto the image.
 void fillRect(java.awt.Graphics g, int color, int opacity, int xmin, int ymin, int xmax, int ymax)
          Set the color as specified and then call g.fillRect.
 java.awt.Dimension getBorderNW()
          Query the north and west border width and height respectively.
 java.awt.Dimension getBorderSE()
          Query the south and east border width and height respectively.
 java.awt.Rectangle getBounds()
          Query the scaled size of this image, with an origin at (0,0).
 DjVuInfo getDjVuInfo()
          Query the size and other page information as indicated in the INFO chunk.
 DjVuPage getDjVuPage()
          Query the DjVuPage being rendered.
 DjVuFilter getFilter(java.awt.Component parent, java.awt.Rectangle bounds)
          Get a segmented Image.
 java.awt.Rectangle getHighlightBounds()
          Query the bounding rectangle of the area to highlight.
 java.awt.Image[] getImage(java.awt.Component parent, java.awt.Rectangle bounds)
          Get a segmented Image.
 DjVuImage getScaledInstance(int scale)
          Create a new instance of this class, scaled to the specified size.
 DjVuImage getScaledInstance(int width, int height)
          Create a new instance of this class, scaled to the specified size.
 java.awt.Dimension getSize()
          Query the scaled size of the DjVuPage.
 Codec getTextCodec(long maxWait)
          Query the DjVuText codec for this page.
 boolean isDecoding()
          Query if decoding is still in progress.
static boolean isDoneDecodingEvent(DjVuImage image, java.beans.PropertyChangeListener listener, java.beans.PropertyChangeEvent event)
          Check if this is a done decoding event.
 boolean isDoneDecodingEvent(java.beans.PropertyChangeListener listener, java.beans.PropertyChangeEvent event)
          Check if this is a done decoding event.
 void setBorder(java.awt.Dimension parentSize, java.awt.Rectangle imageBounds)
          Computes the size of the border.
 void setBufferBounds(java.awt.Component parent, java.awt.Rectangle bounds)
          Sets the bounds for buffering.
 void setBufferBounds(java.awt.Rectangle bounds)
          Sets the bounds for buffering.
 void setHighlightList(java.util.Vector list)
          Take the list of highlighting rectangles and transform it to a list of non-overlapping rectangles covering the same regions.
 void transformRectangle(GRect rect, java.awt.Rectangle scaled)
          Transform the specified coordinates.
 void transformRectangle(java.awt.Rectangle rect, java.awt.Rectangle scaled)
          Transform the specified coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BROKEN_XOR

public static boolean BROKEN_XOR

WHITE

public static java.awt.Color WHITE
A constant indicating the color white.


BLUE

public static java.awt.Color BLUE
A constant indicating the color blue.


BLACK

public static java.awt.Color BLACK
A constant indicating the color blue.


FIT_WIDTH

public static final int FIT_WIDTH
Magic scale value used to zoom to fit width.

See Also:
Constant Field Values

FIT_PAGE

public static final int FIT_PAGE
Magic scale value used to zoom to fit page.

See Also:
Constant Field Values

colorConstructor

public static final java.lang.reflect.Constructor colorConstructor
Test to determine java version.


XOR_HILITE

public static final int XOR_HILITE
Special value for XOR HIGHLIGHTING

See Also:
Constant Field Values
Constructor Detail

DjVuImage

public DjVuImage(DjVuPage djvuPage,
                 boolean favorFast)
Creates a new DjVuImage object.

Parameters:
djvuPage - the page to draw at full resolution.

DjVuImage

public DjVuImage(DjVuPage djvuPage,
                 int zoom,
                 java.awt.Dimension size,
                 boolean favorFast)
Creates a new DjVuImage object.

Parameters:
djvuPage - the page to draw at full resolution.

DjVuImage

public DjVuImage(DjVuPage djvuPage,
                 int width,
                 int height,
                 boolean favorFast)
Creates a new DjVuImage object.

Parameters:
djvuPage - The page to draw.
width - The width to scale the page to.
height - The height to scale the page to.
Method Detail

createColor

public static java.awt.Color createColor(int rgb,
                                         int alpha)
Equivalent to new Color(rgb,hasAlpha).

Parameters:
rgb - color as an integer
alpha - true if there is an alpha channel
Returns:
the scaled size

computeScaledBounds

public java.awt.Rectangle computeScaledBounds(int zoom,
                                              java.awt.Dimension size)
Compute the page size scaled at the appropriate zoom.

Parameters:
zoom - scale factor
size - target window size
Returns:
the scaled size

getBorderNW

public java.awt.Dimension getBorderNW()
Query the north and west border width and height respectively.

Returns:
The NW corner border.

getBorderSE

public java.awt.Dimension getBorderSE()
Query the south and east border width and height respectively.

Returns:
The SE corner border.

isDecoding

public boolean isDecoding()
Query if decoding is still in progress.

Returns:
True if still decoding.

getDjVuPage

public DjVuPage getDjVuPage()
Query the DjVuPage being rendered.

Returns:
The DjVuPage being rendered.

isDoneDecodingEvent

public boolean isDoneDecodingEvent(java.beans.PropertyChangeListener listener,
                                   java.beans.PropertyChangeEvent event)
Check if this is a done decoding event. If done or the event is not for this page remove the listener.

Parameters:
listener - the listener to check
event - the event to check
Returns:
true if a done decoding event

isDoneDecodingEvent

public static boolean isDoneDecodingEvent(DjVuImage image,
                                          java.beans.PropertyChangeListener listener,
                                          java.beans.PropertyChangeEvent event)
Check if this is a done decoding event. If done or the event is not for this page remove the listener.

Parameters:
image - the image to check
listener - the listener to check
event - the event to check
Returns:
true if a done decoding event

setBorder

public void setBorder(java.awt.Dimension parentSize,
                      java.awt.Rectangle imageBounds)
Computes the size of the border.

Parameters:
parentSize - The size of the parent window.
imageBounds - The scaled size of the DjVuPage.

getBounds

public java.awt.Rectangle getBounds()
Query the scaled size of this image, with an origin at (0,0).

Returns:
The segmented rectangle.

setBufferBounds

public void setBufferBounds(java.awt.Component parent,
                            java.awt.Rectangle bounds)
Sets the bounds for buffering. Any image outside these bounds will be removed from the buffer. If full buffering is used, the image buffer will be filled at this time.

Parameters:
parent - The containing component.
bounds - The desired boundrary.

setBufferBounds

public void setBufferBounds(java.awt.Rectangle bounds)
Sets the bounds for buffering. Any image outside these bounds will be removed from the buffer.

Parameters:
bounds - Desired bounds.

getFilter

public DjVuFilter getFilter(java.awt.Component parent,
                            java.awt.Rectangle bounds)
Get a segmented Image.

Parameters:
parent - Parent component to create the Image in.
bounds - Segmentation bounds.
Returns:
The newly created Image.

getHighlightBounds

public java.awt.Rectangle getHighlightBounds()
Query the bounding rectangle of the area to highlight.

Returns:
bounding rectangle of the area to highlight.

setHighlightList

public void setHighlightList(java.util.Vector list)
Take the list of highlighting rectangles and transform it to a list of non-overlapping rectangles covering the same regions. (Since we use XOR highlighting, overlapping rectangles "cancel" each other out.)

Parameters:
list - of bounds to highlight.

getImage

public java.awt.Image[] getImage(java.awt.Component parent,
                                 java.awt.Rectangle bounds)
Get a segmented Image.

Parameters:
parent - Parent component to create the Image in.
bounds - Segmentation bounds.
Returns:
The newly created Image.

getDjVuInfo

public final DjVuInfo getDjVuInfo()
Query the size and other page information as indicated in the INFO chunk.

Returns:
the page information

getScaledInstance

public DjVuImage getScaledInstance(int width,
                                   int height)
Create a new instance of this class, scaled to the specified size.

Parameters:
width - Scaled width.
height - Scaled height.
Returns:
a new instance of this class.

getScaledInstance

public DjVuImage getScaledInstance(int scale)
Create a new instance of this class, scaled to the specified size.

Parameters:
scale - Scaling, relative to DPI.
Returns:
a new instance of this class.

getSize

public java.awt.Dimension getSize()
Query the scaled size of the DjVuPage.

Returns:
the scaled size of the DjVuPage.

getTextCodec

public Codec getTextCodec(long maxWait)
Query the DjVuText codec for this page. Use a maxWait value of 0L to wait until the codec is available, or the document is decoded.

Parameters:
maxWait - The maximum amount of time to wait. (In milliseconds.)
Returns:
the DjVuText codec.

draw

public void draw(java.awt.Component parent,
                 java.awt.Graphics g,
                 java.awt.image.ImageObserver observer)
Called to create one or more images to draw to.

Parameters:
parent - Component being drawn to.
g - Graphics device to draw to.
observer - The ImageObserver monitoring progressive rendering.

transformRectangle

public void transformRectangle(java.awt.Rectangle rect,
                               java.awt.Rectangle scaled)
Transform the specified coordinates.

Parameters:
rect - rectangle to transform.
scaled - the results of the transform.

transformRectangle

public void transformRectangle(GRect rect,
                               java.awt.Rectangle scaled)
Transform the specified coordinates.

Parameters:
rect - rectangle to transform.
scaled - the results of the transform.

drawHighlight

public void drawHighlight(java.awt.Graphics g,
                          boolean useXOR)
Called to paint the highlight areas onto the image.

Parameters:
g - graphics object to draw.
useXOR - true if XOR highlighting should be used.

fillRect

public void fillRect(java.awt.Graphics g,
                     int color,
                     int opacity,
                     int xmin,
                     int ymin,
                     int xmax,
                     int ymax)
Set the color as specified and then call g.fillRect.

Parameters:
g - Graphics item to use.
color - RGB color to use
opacity - Level of opacity from 0 to 100.
xmin - left edge
ymin - top edge
xmax - right edge
ymax - bottom edge