PulpCore

pulpcore.math
Class Rect

java.lang.Object
  extended by pulpcore.math.Rect

public class Rect
extends Object

The Rect class is used internally for dirty rectangles.


Field Summary
static int BOTTOM
          The bitmask that indicates the right segment of a rectangle.
 int height
           
static int LEFT
          The bitmask that indicates the bottom segment of a rectangle.
static int RIGHT
          The bitmask that indicates the left segment of a rectangle.
static int TOP
          The bitmask that indicates the top segment of a rectangle.
 int width
           
 int x
           
 int y
           
 
Constructor Summary
Rect()
           
Rect(int x, int y, int width, int height)
           
Rect(Rect r)
           
 
Method Summary
 boolean contains(int x, int y)
           
 boolean contains(int x, int y, int width, int height)
           
 boolean contains(Rect r)
           
 boolean equals(int x, int y, int width, int height)
           
 boolean equals(Object obj)
           
 int getArea()
           
 int getBoundary(int side)
          Returns the LEFT (x), TOP (y), RIGHT (x + width - 1), or BOTTOM (y + height - 1) boundary of this rectangle.
 int getIntersectionCode(int x, int y, int width, int height)
          Determines which segments of the specified rectangle are completely or partially inside this rectangle.
 int getIntersectionCode(Rect r)
          Determines which segments of the specified rectangle are completely or partially inside this rectangle.
static int getOppositeSide(int side)
           
 int hashCode()
           
 void intersection(int x, int y, int width, int height)
          Sets this rectangle to the intersection of this rectangle and the specified rectangle.
 void intersection(Rect r)
          Sets this rectangle to the intersection of this rectangle and the specified rectangle.
 boolean intersects(int x, int y, int width, int height)
           
 boolean intersects(Rect r)
           
 void setBoundary(int side, int boundary)
           
 void setBounds(int x, int y, int width, int height)
           
 void setBounds(Rect r)
           
 void setOutsideBoundary(int side, int boundary)
           
 String toString()
           
 void union(int x, int y, int width, int height)
          Sets this rectangle to the union of this rectangle and the specified rectangle.
 void union(Rect r)
          Sets this rectangle to the union of this rectangle and the specified rectangle.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TOP

public static final int TOP
The bitmask that indicates the top segment of a rectangle.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
The bitmask that indicates the left segment of a rectangle.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
The bitmask that indicates the right segment of a rectangle.

See Also:
Constant Field Values

LEFT

public static final int LEFT
The bitmask that indicates the bottom segment of a rectangle.

See Also:
Constant Field Values

x

public int x

y

public int y

width

public int width

height

public int height
Constructor Detail

Rect

public Rect()

Rect

public Rect(int x,
            int y,
            int width,
            int height)

Rect

public Rect(Rect r)
Method Detail

setBounds

public void setBounds(Rect r)

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

equals

public boolean equals(int x,
                      int y,
                      int width,
                      int height)

getArea

public int getArea()

contains

public boolean contains(int x,
                        int y)

contains

public boolean contains(int x,
                        int y,
                        int width,
                        int height)

contains

public boolean contains(Rect r)

intersects

public boolean intersects(Rect r)

intersects

public boolean intersects(int x,
                          int y,
                          int width,
                          int height)

intersection

public void intersection(Rect r)
Sets this rectangle to the intersection of this rectangle and the specified rectangle. If the rectangles don't intersect, the width and height will be zero.


intersection

public void intersection(int x,
                         int y,
                         int width,
                         int height)
Sets this rectangle to the intersection of this rectangle and the specified rectangle. If the rectangles don't intersect, the width and/or height will be zero.


union

public void union(Rect r)
Sets this rectangle to the union of this rectangle and the specified rectangle.


union

public void union(int x,
                  int y,
                  int width,
                  int height)
Sets this rectangle to the union of this rectangle and the specified rectangle.


getOppositeSide

public static int getOppositeSide(int side)

getBoundary

public int getBoundary(int side)
Returns the LEFT (x), TOP (y), RIGHT (x + width - 1), or BOTTOM (y + height - 1) boundary of this rectangle.


setBoundary

public void setBoundary(int side,
                        int boundary)

setOutsideBoundary

public void setOutsideBoundary(int side,
                               int boundary)

getIntersectionCode

public int getIntersectionCode(Rect r)
Determines which segments of the specified rectangle are completely or partially inside this rectangle. The result is a binary OR of the codes TOP, LEFT, BOTTOM, RIGHT, corresponding to each segment.


getIntersectionCode

public int getIntersectionCode(int x,
                               int y,
                               int width,
                               int height)
Determines which segments of the specified rectangle are completely or partially inside this rectangle. The result is a binary OR of the codes TOP, LEFT, BOTTOM, RIGHT, corresponding to each segment.


toString

public String toString()
Overrides:
toString in class Object

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.