com.lizardtech.djvu.anno
Class Rect

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.anno.Rect
All Implemented Interfaces:
DjVuInterface, Hyperlink
Direct Known Subclasses:
Line, Oval, Poly, Text

public class Rect
extends DjVuObject
implements Hyperlink

This class is the base of all annotations by the viewer to display and manage hyperlinks and highlighted areas inside a DjVuPage.

The currently supported areas can be rectangular GMapRect, elliptical GMapOval and polygonal GMapPoly. Every map area besides the definition of its shape contains information about display style and optional URL, which it may refer to. If this URL is not empty then the map area will work like a hyperlink.

The classes also implement some useful functions to ease geometry manipulations

This is the interface for all map areas. This defines some standard interface to access the geometrical properties of the areas and describes the area itself.

target - Defines where the specified URL should be loaded

comment - This is a string displayed in a status line or in a popup window when the mouse pointer moves over the hyperlink area

border_width - describes how the area border should be drawn

area_color - describes how the area should be highlighted.

The map areas can be displayed using two different techniques, which can be combined together:

Visible border - The border of a map area can be drawn in several different ways (like XOR_BORDER or SHADOW_IN_BORDER). It can be made always visible, or appearing only when the mouse pointer moves over the map area.

Highlighted contents - Contents of rectangular map areas can also be highlighted with some given color.


Field Summary
static java.lang.String ARROW_TAG
          arrow tag
static java.lang.String BGCOLOR_TAG
          text background color tag
static java.lang.String BORDER_AVIS_TAG
          border always visible tag
static java.lang.String HILITE_TAG
          hilite tag
static java.lang.String LINE_ARROW_TAG
          line arrow tag
static java.lang.String LINE_CLR_TAG
          line clear tag
static java.lang.String LINE_WIDTH_TAG
          line width tag
static java.lang.String LINECOLOR_TAG
          line color tag
static int MAP_LINE
          line map type
static int MAP_OVAL
          oval map type
static int MAP_POLY
          poly map type
static int MAP_RECT
          rectangle map type
static int MAP_TEXT
          text map type
static java.lang.String MAPAREA_TAG
          maparea tag
static int NO_BORDER
          no border flag
static java.lang.String NO_BORDER_TAG
          no border tag
static int NO_HILITE
          no hilite color
static java.lang.String OPACITY_TAG
          opacity tag
static java.lang.String PUSHPIN_TAG
          text pushpin tag
static java.lang.String RECT_TAG
          rect tag
static int SHADOW_EIN_BORDER
          shadow ein border flag
static java.lang.String SHADOW_EIN_BORDER_TAG
          shadow ein tag
static int SHADOW_EOUT_BORDER
          shadow ein border flag
static java.lang.String SHADOW_EOUT_BORDER_TAG
          shadow eout tag
static int SHADOW_IN_BORDER
          shadow in border flag
static java.lang.String SHADOW_IN_BORDER_TAG
          shadow in tag
static int SHADOW_OUT_BORDER
          shadow out border flag
static java.lang.String SHADOW_OUT_BORDER_TAG
          shadow out tag
static int SOLID_BORDER
          solid border flag
static java.lang.String SOLID_BORDER_TAG
          border tag
static java.lang.String TARGET_SELF
          target self tag
static java.lang.String TEXTCOLOR_TAG
          text foreground color tag
static java.lang.String URL_TAG
          url tag
static int XOR_BORDER
          xor border flag
static java.lang.String XOR_BORDER_TAG
          xor border tag
static int XOR_HILITE
          xor hilite color
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
Rect()
          Creates a new Rect object.
 
Method Summary
 int[] computeArray(boolean needY)
          A method for setting the coordinates
 boolean contains(int x, int y)
          Check if the point is inside the hyperlink area
static Rect createRect(DjVuInterface ref)
          Creates an instance of Rect with the options interherited from the specified reference.
 java.lang.String get_shape_name()
          Query the name of this shape.
 int getBgColor()
          Get the color of text background in the map area.
 int getBorderColor()
          Get the color the area border should be drawn.
 int getBorderType()
          Get the border type.
 int getBorderWidth()
          Get border width in pixels.
 GRect getBounds()
          Query the bounding rectangle.
 java.lang.String getComment()
          Comment - displayed in a status line or as a popup hint when the mouse pointer moves over the map area
 int getHiliteColor()
          Get the specified a color for highlighting the internal area of the map area.
protected  long getInfoHeight()
          Query the info height.
protected  long getInfoWidth()
          Query the info width.
 int getLineColor()
          Get the color of the line across the map area.
 int getLineWidth()
          Set the specified a thickness of a line.
 int getMapType()
          Query the map type.
 int getOpacity()
          Query the opacity.
 java.util.Vector getPoints()
          Method generating a list of defining coordinates.
protected  long getScaledHeight()
          Query the scaled height.
protected  long getScaledWidth()
          Query the scaled width.
 java.lang.String getTarget()
          Get the target for the URL.
 int getTextColor()
          Get the color of text in the map area.
 java.lang.String getURL()
          Get optional URL which this map area can be associated with.
 int[] getXCoordinates()
          Gets an array of X coordinates, converted from bottom up to dop down if the pageInfoHeight has been set to non-zero.
 int[] getYCoordinates()
          Gets an array of Y coordinates, converted from bottom up to dop down if the pageInfoHeight has been set to non-zero.
 Rect init(GRect rect)
          Changes the Rect's geometry
 boolean isArrow()
          Query if an arrow should be drawn.
 boolean isBorderAlwaysVisible()
          Query if the border is always visible, or just when the mouse is over the link.
 boolean isEmpty()
          Query if the area is empty
 boolean isPushpin()
          Query if a pushpin should be used.
 boolean isValid()
          Checks if the object is OK.
 boolean isVisible()
          Query if the border should current by visible.
 void map(Mapper mapper)
          Method maps rectangle from one area to another using mapper
 void move(int dx, int dy)
          Moves the hyperlink along the given vector.
protected  void reset()
          Resets cached results.
 void resize(int width, int height)
          Resize this shape.
 void rotateArea(int rot, int cx, int cy)
          Called to rotate this shape.
 void setArrow(boolean value)
          Set if a arrow should be drawn.
 void setBgColor(java.lang.Number color)
          Set the specified a color for text background of the map area.
 void setBorderAlwaysVisible(boolean visible)
          Set if the border is always visible, or just when the mouse is over the link.
 void setBorderColor(java.lang.Number color)
          Sets the color the area border should be drawn.
 void setBorderType(int borderType)
          Set the border type.
 void setBorderWidth(int width)
          Set border width in pixels.
 void setComment(java.lang.String comment)
          Comment - displayed in a status line or as a popup hint when the mouse pointer moves over the map area
 void setHiliteColor(java.lang.Number color)
          Set the specified a color for highlighting the internal area of the map area.
 void setLineColor(java.lang.Number color)
          Set the specified a color for a line across map area.
 void setLineWidth(java.lang.Number weight)
          Set the specified a thickness of a line.
 void setOpacity(java.lang.Number opacity)
          Set the specified a opacity.
 void setPageSize(int width, int height, int scaledWidth, int scaledHeight)
          Use this method to set the page height and width for translating from bottom up to top down coordinates and scaling.
 void setPushpin(boolean value)
          Set if a pushpin should be used.
 void setTarget(java.lang.String target)
          Set the target for the URL.
 void setTextColor(java.lang.Number color)
          Set the specified a color for text of the map area.
 void setURL(java.lang.String url)
          Set optional URL which this map area can be associated with.
 void setVisible(boolean visible)
          Set if the border should current by visible.
 void transform(GRect grect)
          Move and resize this shape to the new bounding rectangle.
 void unmap(Mapper mapper)
          Method unmaps rectangle from one area to another using mapper
 
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

MAP_RECT

public static final int MAP_RECT
rectangle map type

See Also:
Constant Field Values

MAP_OVAL

public static final int MAP_OVAL
oval map type

See Also:
Constant Field Values

MAP_POLY

public static final int MAP_POLY
poly map type

See Also:
Constant Field Values

MAP_TEXT

public static final int MAP_TEXT
text map type

See Also:
Constant Field Values

MAP_LINE

public static final int MAP_LINE
line map type

See Also:
Constant Field Values

NO_BORDER

public static final int NO_BORDER
no border flag

See Also:
Constant Field Values

XOR_BORDER

public static final int XOR_BORDER
xor border flag

See Also:
Constant Field Values

SOLID_BORDER

public static final int SOLID_BORDER
solid border flag

See Also:
Constant Field Values

SHADOW_IN_BORDER

public static final int SHADOW_IN_BORDER
shadow in border flag

See Also:
Constant Field Values

SHADOW_OUT_BORDER

public static final int SHADOW_OUT_BORDER
shadow out border flag

See Also:
Constant Field Values

SHADOW_EIN_BORDER

public static final int SHADOW_EIN_BORDER
shadow ein border flag

See Also:
Constant Field Values

SHADOW_EOUT_BORDER

public static final int SHADOW_EOUT_BORDER
shadow ein border flag

See Also:
Constant Field Values

MAPAREA_TAG

public static final java.lang.String MAPAREA_TAG
maparea tag

See Also:
Constant Field Values

RECT_TAG

public static final java.lang.String RECT_TAG
rect tag

See Also:
Constant Field Values

NO_BORDER_TAG

public static final java.lang.String NO_BORDER_TAG
no border tag

See Also:
Constant Field Values

XOR_BORDER_TAG

public static final java.lang.String XOR_BORDER_TAG
xor border tag

See Also:
Constant Field Values

SOLID_BORDER_TAG

public static final java.lang.String SOLID_BORDER_TAG
border tag

See Also:
Constant Field Values

SHADOW_IN_BORDER_TAG

public static final java.lang.String SHADOW_IN_BORDER_TAG
shadow in tag

See Also:
Constant Field Values

SHADOW_OUT_BORDER_TAG

public static final java.lang.String SHADOW_OUT_BORDER_TAG
shadow out tag

See Also:
Constant Field Values

SHADOW_EIN_BORDER_TAG

public static final java.lang.String SHADOW_EIN_BORDER_TAG
shadow ein tag

See Also:
Constant Field Values

SHADOW_EOUT_BORDER_TAG

public static final java.lang.String SHADOW_EOUT_BORDER_TAG
shadow eout tag

See Also:
Constant Field Values

BORDER_AVIS_TAG

public static final java.lang.String BORDER_AVIS_TAG
border always visible tag

See Also:
Constant Field Values

HILITE_TAG

public static final java.lang.String HILITE_TAG
hilite tag

See Also:
Constant Field Values

ARROW_TAG

public static final java.lang.String ARROW_TAG
arrow tag

See Also:
Constant Field Values

URL_TAG

public static final java.lang.String URL_TAG
url tag

See Also:
Constant Field Values

TARGET_SELF

public static final java.lang.String TARGET_SELF
target self tag

See Also:
Constant Field Values

PUSHPIN_TAG

public static final java.lang.String PUSHPIN_TAG
text pushpin tag

See Also:
Constant Field Values

BGCOLOR_TAG

public static final java.lang.String BGCOLOR_TAG
text background color tag

See Also:
Constant Field Values

TEXTCOLOR_TAG

public static final java.lang.String TEXTCOLOR_TAG
text foreground color tag

See Also:
Constant Field Values

LINECOLOR_TAG

public static final java.lang.String LINECOLOR_TAG
line color tag

See Also:
Constant Field Values

LINE_ARROW_TAG

public static final java.lang.String LINE_ARROW_TAG
line arrow tag

See Also:
Constant Field Values

LINE_WIDTH_TAG

public static final java.lang.String LINE_WIDTH_TAG
line width tag

See Also:
Constant Field Values

LINE_CLR_TAG

public static final java.lang.String LINE_CLR_TAG
line clear tag

See Also:
Constant Field Values

OPACITY_TAG

public static final java.lang.String OPACITY_TAG
opacity tag

See Also:
Constant Field Values

NO_HILITE

public static final int NO_HILITE
no hilite color

See Also:
Constant Field Values

XOR_HILITE

public static final int XOR_HILITE
xor hilite color

See Also:
Constant Field Values
Constructor Detail

Rect

public Rect()
Creates a new Rect object.

Method Detail

setBorderAlwaysVisible

public void setBorderAlwaysVisible(boolean visible)
Set if the border is always visible, or just when the mouse is over the link.

Parameters:
visible - true if the border should always be visible.

isBorderAlwaysVisible

public boolean isBorderAlwaysVisible()
Query if the border is always visible, or just when the mouse is over the link.

Returns:
true if the border should always be visible.

setPushpin

public void setPushpin(boolean value)
Set if a pushpin should be used.

Parameters:
value - true if this is a pushpin

isPushpin

public boolean isPushpin()
Query if a pushpin should be used.

Returns:
true if this is a pushpin

setArrow

public void setArrow(boolean value)
Set if a arrow should be drawn.

Parameters:
value - true if this should have an arrow

isArrow

public boolean isArrow()
Query if an arrow should be drawn.

Returns:
true if this should have an arrow

setBorderColor

public void setBorderColor(java.lang.Number color)
Sets the color the area border should be drawn. Border color (when relevant) in 0x00RRGGBB format.

Parameters:
color - DOCUMENT ME!

getBorderColor

public int getBorderColor()
Get the color the area border should be drawn. Border color (when relevant) in 0x00RRGGBB format.

Returns:
color in RRGGBB format

setBorderType

public void setBorderType(int borderType)
Set the border type. This defines how the map area border should be drawn
NO_BORDER - No border drawn
XOR_BORDER - The border is drawn using XOR method.
SOLID_BORDER - The border is drawn as a solid line of a given color.
SHADOW_IN_BORDER - Supported for \Ref{Rect} only. The map area area looks as if it was "pushed-in".
SHADOW_OUT_BORDER - The opposite of SHADOW_OUT_BORDER
SHADOW_EIN_BORDER - Also for Rectangle only. Is translated as "shadow etched in"
SHADOW_EOUT_BORDER - The opposite of SHADOW_EIN_BORDER.

Parameters:
borderType - DOCUMENT ME!

getBorderType

public int getBorderType()
Get the border type. This defines how the map area border should be drawn
NO_BORDER - No border drawn
XOR_BORDER - The border is drawn using XOR method.
SOLID_BORDER - The border is drawn as a solid line of a given color.
SHADOW_IN_BORDER - Supported for \Ref{Rect} only. The map area area looks as if it was "pushed-in".
SHADOW_OUT_BORDER - The opposite of SHADOW_OUT_BORDER
SHADOW_EIN_BORDER - Also for Rectangle only. Is translated as "shadow etched in"
SHADOW_EOUT_BORDER - The opposite of SHADOW_EIN_BORDER.

Returns:
DOCUMENT ME!

setBorderWidth

public void setBorderWidth(int width)
Set border width in pixels.

Parameters:
width - DOCUMENT ME!

getBorderWidth

public int getBorderWidth()
Get border width in pixels.

Returns:
DOCUMENT ME!

setComment

public void setComment(java.lang.String comment)
Comment - displayed in a status line or as a popup hint when the mouse pointer moves over the map area

Parameters:
comment - DOCUMENT ME!

getComment

public java.lang.String getComment()
Comment - displayed in a status line or as a popup hint when the mouse pointer moves over the map area

Returns:
the comment

setHiliteColor

public void setHiliteColor(java.lang.Number color)
Set the specified a color for highlighting the internal area of the map area. Will work with rectangular map areas only. The color is specified in #00RRGGBB format. A special value of #FFFFFFFF disables highlighting and #FF000000 is for XOR highlighting.

Parameters:
color - the hilite color

getHiliteColor

public int getHiliteColor()
Get the specified a color for highlighting the internal area of the map area. Will work with rectangular map areas only. The color is specified in #00RRGGBB format. A special value of #FFFFFFFF disables highlighting and #FF000000 is for XOR highlighting.

Returns:
the hilite color

setTextColor

public void setTextColor(java.lang.Number color)
Set the specified a color for text of the map area. Will work with text map areas only. The color is specified in #00RRGGBB format.

Parameters:
color - the text color

getTextColor

public int getTextColor()
Get the color of text in the map area. Will work with text map areas only. The color is specified in #00RRGGBB format.

Returns:
the text color

setBgColor

public void setBgColor(java.lang.Number color)
Set the specified a color for text background of the map area. Will work with text map areas only. The color is specified in #00RRGGBB format.

Parameters:
color - the text color

getBgColor

public int getBgColor()
Get the color of text background in the map area. Will work with text map areas only. The color is specified in #00RRGGBB format.

Returns:
the text color

setLineColor

public void setLineColor(java.lang.Number color)
Set the specified a color for a line across map area. The color is specified in #00RRGGBB format.

Parameters:
color - the line color

setLineWidth

public void setLineWidth(java.lang.Number weight)
Set the specified a thickness of a line.

Parameters:
weight - the line width

getLineColor

public int getLineColor()
Get the color of the line across the map area. Will work with text map areas only. The color is specified in #00RRGGBB format.

Returns:
the line color

getLineWidth

public int getLineWidth()
Set the specified a thickness of a line.

Returns:
the line weight

setOpacity

public void setOpacity(java.lang.Number opacity)
Set the specified a opacity. Will work with text map areas only. The value is from 0 to 100.

Parameters:
opacity - the opacity of this annotation

getOpacity

public int getOpacity()
Query the opacity. Will work with text map areas only. The value is from 0 to 100.

Returns:
the opacity of this annotation

getMapType

public int getMapType()
Query the map type.

Returns:
the map type

setTarget

public void setTarget(java.lang.String target)
Set the target for the URL. Standard targets are:
_blank - Load the link in a new blank window
_self - Load the link into the plugin window
_top - Load the link into the top-level frame

Parameters:
target - DOCUMENT ME!

getTarget

public java.lang.String getTarget()
Get the target for the URL. Standard targets are:
_blank - Load the link in a new blank window
_self - Load the link into the plugin window
_top - Load the link into the top-level frame

Specified by:
getTarget in interface Hyperlink
Returns:
DOCUMENT ME!

setURL

public void setURL(java.lang.String url)
Set optional URL which this map area can be associated with. If it's not empty then clicking this map area with the mouse will make the browser load the HTML page referenced by this url. Note: This may also be a relative URL.

Parameters:
url - DOCUMENT ME!

getURL

public java.lang.String getURL()
Get optional URL which this map area can be associated with. If it's not empty then clicking this map area with the mouse will make the browser load the HTML page referenced by this url. Note: This may also be a relative URL.

Specified by:
getURL in interface Hyperlink
Returns:
the URL string

setVisible

public void setVisible(boolean visible)
Set if the border should current by visible.

Parameters:
visible - true if visible

isVisible

public boolean isVisible()
Query if the border should current by visible.

Returns:
true if visible

createRect

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

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

getBounds

public GRect getBounds()
Query the bounding rectangle.

Returns:
the bounding rectangle

isEmpty

public boolean isEmpty()
Query if the area is empty

Returns:
true if has empty bounds

setPageSize

public final void setPageSize(int width,
                              int height,
                              int scaledWidth,
                              int scaledHeight)
Use this method to set the page height and width for translating from bottom up to top down coordinates and scaling. Using a values of 0 avoids translation.

Parameters:
width - page width
height - page height
scaledWidth - scaled page width
scaledHeight - scaled page height

getPoints

public java.util.Vector getPoints()
Method generating a list of defining coordinates. (default are the opposite corners of the enclosing rectangle)

Returns:
a vector of points

getXCoordinates

public final int[] getXCoordinates()
Gets an array of X coordinates, converted from bottom up to dop down if the pageInfoHeight has been set to non-zero.

Returns:
an array of x coordinates

getYCoordinates

public final int[] getYCoordinates()
Gets an array of Y coordinates, converted from bottom up to dop down if the pageInfoHeight has been set to non-zero.

Returns:
an array of y coordinates

computeArray

public final int[] computeArray(boolean needY)
A method for setting the coordinates

Parameters:
needY - true if the y coordinates should be returned
Returns:
an array of x or y coordinates

isValid

public boolean isValid()
Checks if the object is OK.

Returns:
true if valid

contains

public boolean contains(int x,
                        int y)
Check if the point is inside the hyperlink area

Parameters:
x - horizontal coordinate
y - vertical coordinate
Returns:
true if the given point is inside the hyperlink area

get_shape_name

public java.lang.String get_shape_name()
Query the name of this shape.

Returns:
"rect"

init

public Rect init(GRect rect)
Changes the Rect's geometry

Parameters:
rect - bounding rectangle
Returns:
the initialized shape

map

public void map(Mapper mapper)
Method maps rectangle from one area to another using mapper

Parameters:
mapper - the coordinate mapper

move

public void move(int dx,
                 int dy)
Moves the hyperlink along the given vector. Is used by the hyperlinks editor.

Parameters:
dx - distance to move the x coordinates
dy - distance to move the y coordinates

resize

public void resize(int width,
                   int height)
Resize this shape.

Parameters:
width - the new width
height - the new height

rotateArea

public void rotateArea(int rot,
                       int cx,
                       int cy)
Called to rotate this shape.

Parameters:
rot - angle to rotate divided by 90
cx - horizontal center of rotation
cy - vertical center of rotation

transform

public void transform(GRect grect)
Move and resize this shape to the new bounding rectangle.

Parameters:
grect - new bounding rectangle

unmap

public void unmap(Mapper mapper)
Method unmaps rectangle from one area to another using mapper

Parameters:
mapper - object to map coordinates

getInfoHeight

protected final long getInfoHeight()
Query the info height.

Returns:
the total page height

getInfoWidth

protected final long getInfoWidth()
Query the info width.

Returns:
the total page width

getScaledHeight

protected final long getScaledHeight()
Query the scaled height.

Returns:
the scaled page height

getScaledWidth

protected final long getScaledWidth()
Query the scaled width.

Returns:
the scaled page width

reset

protected void reset()
Resets cached results.