TinyLine
v2.0

com.tinyline.tiny2d
Class TinyRect

java.lang.Object
  extended bycom.tinyline.tiny2d.TinyRect

public final class TinyRect
extends java.lang.Object

The TinyRect class specifies an area in a coordinate space that is enclosed by the TinyRect object's top-left point (xminymin ) and down-right point (xmaxymax ) in the coordinate space.

Version:
1.7

Author:
Andrew Girow

Field Summary
 int xmax
          the down-right corner X coordinate
 int xmin
          the top-left corner X coordinate
 int ymax
          the down-right corner Y coordinate
 int ymin
          the top-left corner Y coordinate
 
Constructor Summary
TinyRect()
          Constructs a new TinyRect empty rectangle.
TinyRect(int x0, int y0, int x1, int y1)
          Constructs a new TinyRect whose top-left corner is specified as (x0y0) and whose down-right corner is specified as (x1y1).
TinyRect(TinyRect rect)
          Constructs a new TinyRect, initialized from the specificed TinyRect.
 
Method Summary
 void add(TinyPoint point)
          Adds a point to this TinyRect.
 boolean contains(TinyPoint point)
          Checks whether or not this TinyRect contains the specified Point.
 void copy(TinyRect src)
          Copyies TinyRect src to this TinyRect .
 TinyRect grow(int dx, int dy)
          This TinyRect grows from the center in each direction.
 TinyRect intersection(TinyRect r)
          Computes the intersection of this TinyRect with the specified TinyRect.
 boolean intersects(TinyRect rect)
          Determines whether or not this TinyRect and the specified TinyRect intersect.
 boolean isEmpty()
          Determines whether or not this TinyRect is empty.
 void setEmpty()
          Sets this TinyRect empty.
 void union(TinyRect rect)
          Computes the union of this TinyRect with the specified TinyRect.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmin

public int xmin
the top-left corner X coordinate


ymin

public int ymin
the top-left corner Y coordinate


xmax

public int xmax
the down-right corner X coordinate


ymax

public int ymax
the down-right corner Y coordinate

Constructor Detail

TinyRect

public TinyRect()
Constructs a new TinyRect empty rectangle.


TinyRect

public TinyRect(TinyRect rect)
Constructs a new TinyRect, initialized from the specificed TinyRect.

Parameters:
rect - the TinyRect from which to copy initial values.

TinyRect

public TinyRect(int x0,
                int y0,
                int x1,
                int y1)
Constructs a new TinyRect whose top-left corner is specified as (x0y0) and whose down-right corner is specified as (x1y1).

Method Detail

copy

public void copy(TinyRect src)
Copyies TinyRect src to this TinyRect .

[this] = [src]

Parameters:
src - the TinyRect object.

grow

public TinyRect grow(int dx,
                     int dy)
This TinyRect grows from the center in each direction. Returs a new TinyRect whose top-left corner is specified as ((xmin - dx, ymin - dy) and whose down-right corner is specified as (xmax + dx, ymax + dy).

Parameters:
dx - and dy are the specified coordinates deltas.
Returns:
the new TinyRect.

setEmpty

public void setEmpty()
Sets this TinyRect empty.


union

public void union(TinyRect rect)
Computes the union of this TinyRect with the specified TinyRect. Returns a new TinyRect that represents the union of the two rectangles

Parameters:
rect - the specified TinyRect
Returns:
the smallest TinyRect containing both the specified TinyRect and this TinyRect.

intersection

public TinyRect intersection(TinyRect r)
Computes the intersection of this TinyRect with the specified TinyRect. Returns a new rectangle that represents the intersection of the two rectangles.

Parameters:
r - the specified TinyRect.
Returns:
the largest TinyRect contained in both the specified TinyRect and in this TinyRect.

add

public void add(TinyPoint point)
Adds a point to this TinyRect. The resulting TinyRect is the smallest TinyRect that contains both the original TinyRect and the specified point.

Parameters:
point - the new point

isEmpty

public boolean isEmpty()
Determines whether or not this TinyRect is empty.

Returns:
true if this TinyRect is empty; false otherwise.

contains

public boolean contains(TinyPoint point)
Checks whether or not this TinyRect contains the specified Point.

Parameters:
point - the Point to test
Returns:
true if the Point (xy) is inside this TinyRect; false otherwise.

intersects

public boolean intersects(TinyRect rect)
Determines whether or not this TinyRect and the specified TinyRect intersect.

Parameters:
rect - the specified TinyRect
Returns:
true if the specified TinyRect and this TinyRect insersect; false otherwise.

TinyLine
v2.0

Provided under the terms of the TinyLine License Agreement that has been included with this distribution