com.lizardtech.djvu
Class GRect

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.GRect
All Implemented Interfaces:
DjVuInterface, java.lang.Cloneable
Direct Known Subclasses:
DjVuText.Zone

public class GRect
extends DjVuObject
implements java.lang.Cloneable

A general class for rectange shapes. By convention DjVu images are in bottom up coordinates. Thus, ymax corresponds to the top of a rectangle and ymin to the bottom.

Version:
$Revision: 1.5 $
Author:
$author$

Field Summary
 int xmax
          Left edge
 int xmin
          Right edge
 int ymax
          Top edge.
 int ymin
          Bottom edge.
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
GRect()
          Creates a new GRect object.
GRect(int xmin, int ymin, int width, int height)
          Creates a new GRect object.
 
Method Summary
 long area()
          Compute the area of this rectangle.
 void clear()
          Reset this rectange with all edges at the origin.
 java.lang.Object clone()
          Create a clone of this rectangle.
 boolean contains(GRect rect)
          Test if a rectangle is contained within this rectangle.
 boolean contains(int x, int y)
          Test if a point is contained in this rectangle.
 boolean equals(java.lang.Object ref)
          Test if two rectangles are equal.
 int height()
          Query the height of this rectangle.
 boolean inflate(int dx, int dy)
          Grow the size of this rectangle by moving all the edges outwards.
 boolean intersect(GRect rect1, GRect rect2)
          Set this rectangle as the intersection of two rectangles.
 boolean isEmpty()
          Query if the rectange is empty.
 boolean recthull(GRect rect1, GRect rect2)
          Set this rectangle as the union of two rectangles.
 boolean translate(int dx, int dy)
          Shift this rectangle
 int width()
          Compute the width of this rectangle.
 
Methods inherited from class com.lizardtech.djvu.DjVuObject
checkLockTime, create, create, createSoftReference, createWeakReference, getDjVuOptions, getFromReference, invoke, setDjVuOptions
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmax

public int xmax
Left edge


xmin

public int xmin
Right edge


ymax

public int ymax
Top edge.


ymin

public int ymin
Bottom edge.

Constructor Detail

GRect

public GRect()
Creates a new GRect object.


GRect

public GRect(int xmin,
             int ymin,
             int width,
             int height)
Creates a new GRect object.

Parameters:
xmin - left edge
ymin - bottom edge
width - horizontal length
height - vertical length
Method Detail

isEmpty

public boolean isEmpty()
Query if the rectange is empty.

Returns:
true if no pixels are enclosed

area

public long area()
Compute the area of this rectangle.

Returns:
area, width()*height()

clear

public void clear()
Reset this rectange with all edges at the origin.


clone

public java.lang.Object clone()
Create a clone of this rectangle.

Overrides:
clone in class java.lang.Object
Returns:
the newly created copy

contains

public boolean contains(int x,
                        int y)
Test if a point is contained in this rectangle.

Parameters:
x - horizontal coordinate
y - vertical coordinate
Returns:
true if the point is within this rectangle

contains

public boolean contains(GRect rect)
Test if a rectangle is contained within this rectangle.

Parameters:
rect - rectangle to test
Returns:
true if the rectangle is contained

equals

public boolean equals(java.lang.Object ref)
Test if two rectangles are equal.

Overrides:
equals in class java.lang.Object
Parameters:
ref - reference rectangle to compare with
Returns:
true if all the edges are equal

height

public int height()
Query the height of this rectangle.

Returns:
the rectangle height

inflate

public boolean inflate(int dx,
                       int dy)
Grow the size of this rectangle by moving all the edges outwards.

Parameters:
dx - Amount to grow the horizontal edges
dy - Amount to grow the vertical edges
Returns:
true if not empty.

intersect

public boolean intersect(GRect rect1,
                         GRect rect2)
Set this rectangle as the intersection of two rectangles.

Parameters:
rect1 - rectangle to intersect
rect2 - rectangle to intersect
Returns:
true if the intersection is not empty

recthull

public boolean recthull(GRect rect1,
                        GRect rect2)
Set this rectangle as the union of two rectangles.

Parameters:
rect1 - rectangle to union
rect2 - rectangle to union
Returns:
true if the results are non-empty

translate

public boolean translate(int dx,
                         int dy)
Shift this rectangle

Parameters:
dx - horizontal distance to shift
dy - vertical distance to shift
Returns:
true if not empty

width

public int width()
Compute the width of this rectangle.

Returns:
the width of this rectangle.