com.lizardtech.djvu.anno
Class Poly

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.anno.Rect
          extended by com.lizardtech.djvu.anno.Poly
All Implemented Interfaces:
DjVuInterface, Hyperlink

public class Poly
extends Rect

Implements polygonal map areas. The only supported types of border are NO_BORDER, XOR_BORDER and SOLID_BORDER. Its contents can not be highlighted either. It's worth mentioning here that despite its name the polygon may be open, which basically makes it a broken line. This very specific mode is used by the hyperlink editor when creating the polygonal hyperlink.


Field Summary
static java.lang.String POLY_TAG
          The tag name for this shape.
 
Fields inherited from class com.lizardtech.djvu.anno.Rect
ARROW_TAG, BGCOLOR_TAG, BORDER_AVIS_TAG, HILITE_TAG, LINE_ARROW_TAG, LINE_CLR_TAG, LINE_WIDTH_TAG, LINECOLOR_TAG, MAP_LINE, MAP_OVAL, MAP_POLY, MAP_RECT, MAP_TEXT, MAPAREA_TAG, NO_BORDER, NO_BORDER_TAG, NO_HILITE, OPACITY_TAG, PUSHPIN_TAG, RECT_TAG, SHADOW_EIN_BORDER, SHADOW_EIN_BORDER_TAG, SHADOW_EOUT_BORDER, SHADOW_EOUT_BORDER_TAG, SHADOW_IN_BORDER, SHADOW_IN_BORDER_TAG, SHADOW_OUT_BORDER, SHADOW_OUT_BORDER_TAG, SOLID_BORDER, SOLID_BORDER_TAG, TARGET_SELF, TEXTCOLOR_TAG, URL_TAG, XOR_BORDER, XOR_BORDER_TAG, XOR_HILITE
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
Poly()
          Creates a new Poly object.
 
Method Summary
 int add_vertex(int x, int y)
          Adds a new vertex and returns number of vertices in the polygon
 boolean contains(int xin, int yin)
          Check if the point is inside the hyperlink area
static Poly createPoly(DjVuInterface ref)
          Creates an instance of Poly with the options interherited from the specified reference.
 boolean does_side_cross_rect(GRect grect, int side)
          Query if side crosses the specified rectangle rect.
 GRect getBounds()
          Query the bounding rectangle for this shape.
 int getMapType()
          Query the map type.
 java.util.Vector getPoints()
          Method generating a list of defining coordinates
 java.lang.String getShapeName()
          Query the shape tag name
 Poly init(int[] xx, int[] yy, int points)
          Initialize a closed polygon from specified coordinates.
 Poly init(int[] xx, int[] yy, int points, boolean open)
          Initialize from specified coordinates.
 boolean isDataValid()
          Checks validity of the polygon
 boolean isEmpty()
          Query if the poly is closed
 boolean isOpen()
          Query if this is an open polygon.
 boolean isValid()
          Checks if the object is OK.
 void map(Mapper mapper)
          Method maps polygon from one area to another using mapper
 void move_vertex(int i, int x, int y)
          Moves vertex i to position (x, y)
 void move(int dx, int dy)
          Move all the points of the polygon.
 void optimize_data()
          Optimizes the polygon
 void reset()
          Resets cached results.
 void resize(int width, int height)
          Rescale the polygon to the specified bounds size.
 void rotateArea(int rot, int cx, int cy)
          Rotate this area about the specified origin
 void setOpen(boolean open)
          Closes or open the polygon
 int size()
          Query the number sides in the polygon
 void transform(GRect grect)
          Move and scale this polygon to the specified bounding rectangle.
 void unmap(Mapper mapper)
          Method unmaps polygon from one area to another using mapper
 
Methods inherited from class com.lizardtech.djvu.anno.Rect
computeArray, createRect, get_shape_name, getBgColor, getBorderColor, getBorderType, getBorderWidth, getComment, getHiliteColor, getInfoHeight, getInfoWidth, getLineColor, getLineWidth, getOpacity, getScaledHeight, getScaledWidth, getTarget, getTextColor, getURL, getXCoordinates, getYCoordinates, init, isArrow, isBorderAlwaysVisible, isPushpin, isVisible, setArrow, setBgColor, setBorderAlwaysVisible, setBorderColor, setBorderType, setBorderWidth, setComment, setHiliteColor, setLineColor, setLineWidth, setOpacity, setPageSize, setPushpin, setTarget, setTextColor, setURL, setVisible
 
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

POLY_TAG

public static final java.lang.String POLY_TAG
The tag name for this shape.

See Also:
Constant Field Values
Constructor Detail

Poly

public Poly()
Creates a new Poly object.

Method Detail

getBounds

public GRect getBounds()
Query the bounding rectangle for this shape.

Overrides:
getBounds in class Rect
Returns:
the bounding rectangle

getMapType

public int getMapType()
Query the map type.

Overrides:
getMapType in class Rect
Returns:
MAP_POLY

createPoly

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

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

isEmpty

public boolean isEmpty()
Query if the poly is closed

Overrides:
isEmpty in class Rect
Returns:
true if closed or does not have valid data.

isDataValid

public boolean isDataValid()
Checks validity of the polygon

Returns:
true if there are enough segments, all of which are valid.

setOpen

public void setOpen(boolean open)
Closes or open the polygon

Parameters:
open - true if this should be an open polygon

isOpen

public boolean isOpen()
Query if this is an open polygon.

Returns:
true if an open polygon

getPoints

public java.util.Vector getPoints()
Method generating a list of defining coordinates

Overrides:
getPoints in class Rect
Returns:
the vector of points

getShapeName

public java.lang.String getShapeName()
Query the shape tag name

Returns:
POLY_TAG

isValid

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

Overrides:
isValid in class Rect
Returns:
true if valid

add_vertex

public int add_vertex(int x,
                      int y)
Adds a new vertex and returns number of vertices in the polygon

Parameters:
x - horizontal position
y - vertical position
Returns:
the number of points

contains

public boolean contains(int xin,
                        int yin)
Check if the point is inside the hyperlink area

Overrides:
contains in class Rect
Parameters:
xin - horizontal position
yin - vertical position
Returns:
true if the given point is inside the hyperlink area

does_side_cross_rect

public boolean does_side_cross_rect(GRect grect,
                                    int side)
Query if side crosses the specified rectangle rect.

Parameters:
grect - the rectangle to check
side - the side number to check
Returns:
true if side crosses the specified rectangle rect.

init

public Poly init(int[] xx,
                 int[] yy,
                 int points,
                 boolean open)
Initialize from specified coordinates.

Parameters:
xx - array of horizontal positions
yy - array of vertical positions
points - number of points
open - true if an open polygon
Returns:
the initialized Poly

init

public Poly init(int[] xx,
                 int[] yy,
                 int points)
Initialize a closed polygon from specified coordinates.

Parameters:
xx - array of horizontal positions
yy - array of vertical positions
points - number of points
Returns:
the initialized Poly

map

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

Overrides:
map in class Rect
Parameters:
mapper - used to remap the points

move

public void move(int dx,
                 int dy)
Move all the points of the polygon.

Overrides:
move in class Rect
Parameters:
dx - Delta x value to add.
dy - Delta y value to add.

move_vertex

public void move_vertex(int i,
                        int x,
                        int y)
Moves vertex i to position (x, y)

Parameters:
i - point to move
x - horizontal position
y - vertical position

optimize_data

public void optimize_data()
Optimizes the polygon


resize

public void resize(int width,
                   int height)
Rescale the polygon to the specified bounds size.

Overrides:
resize in class Rect
Parameters:
width - horizontal length to scale to
height - vertical length to scale to

rotateArea

public void rotateArea(int rot,
                       int cx,
                       int cy)
Rotate this area about the specified origin

Overrides:
rotateArea in class Rect
Parameters:
rot - angle to rotate divided by 90
cx - horizontal position of the center of rotation
cy - vertical position of the center of rotation

size

public int size()
Query the number sides in the polygon

Returns:
the number sides in the polygon

transform

public void transform(GRect grect)
Move and scale this polygon to the specified bounding rectangle.

Overrides:
transform in class Rect
Parameters:
grect - the new bounding rectangle

unmap

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

Overrides:
unmap in class Rect
Parameters:
mapper - the mapper to transform the coordinates

reset

public void reset()
Resets cached results.

Overrides:
reset in class Rect