com.incrediblesoft.redjey
Class Rectangle

java.lang.Object
  extended by com.incrediblesoft.redjey.Rectangle

public class Rectangle
extends java.lang.Object

Author:
Yevgen Krapiva
Homepage: http://code.google.com/p/redjey/
Feedback: ykrapiva@gmail.com
Copyright (C) 2008 Yevgen Krapiva
Code used in this class was taken from java.awt package.

Field Summary
 int height
           
 int width
           
 int x
           
 int y
           
 
Constructor Summary
Rectangle()
           
Rectangle(int width, int height)
           
Rectangle(int x, int y, int width, int height)
           
Rectangle(Rectangle rect)
           
 
Method Summary
 boolean contains(int X, int Y, int W, int H)
           
 boolean contains(Rectangle rect)
           
 int getHeight()
           
 int getWidth()
           
 int getX()
           
 int getY()
           
 boolean inside(int X, int Y)
           
static boolean inside(Rectangle rect, int X, int Y)
           
 Rectangle intersection(Rectangle r)
          Computes the intersection of this Rectangle with the specified Rectangle.
 boolean intersects(Rectangle r)
           
static boolean Intersects(Rectangle r1, Rectangle r2)
           
 boolean isEmpty()
           
 void setLocation(int x, int y)
           
 void setRect(int x, int y, int width, int height)
           
 void setSize(int width, int height)
           
 java.lang.String toString()
           
 Rectangle union(Rectangle r)
          Computes the union of this Rectangle with the specified Rectangle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

width

public int width

height

public int height
Constructor Detail

Rectangle

public Rectangle()

Rectangle

public Rectangle(int width,
                 int height)

Rectangle

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

Rectangle

public Rectangle(Rectangle rect)
Method Detail

getX

public int getX()

getY

public int getY()

getWidth

public int getWidth()

getHeight

public int getHeight()

setLocation

public void setLocation(int x,
                        int y)

setSize

public void setSize(int width,
                    int height)

setRect

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

intersects

public boolean intersects(Rectangle r)

Intersects

public static boolean Intersects(Rectangle r1,
                                 Rectangle r2)

contains

public boolean contains(Rectangle rect)

contains

public boolean contains(int X,
                        int Y,
                        int W,
                        int H)

inside

public boolean inside(int X,
                      int Y)

inside

public static boolean inside(Rectangle rect,
                             int X,
                             int Y)

intersection

public Rectangle intersection(Rectangle r)
Computes the intersection of this Rectangle with the specified Rectangle. Returns a new Rectangle that represents the intersection of the two rectangles. If the two rectangles do not intersect, the result will be an empty rectangle.

Parameters:
r - the specified Rectangle
Returns:
the largest Rectangle contained in both the specified Rectangle and in this Rectangle; or if the rectangles do not intersect, an empty rectangle.

union

public Rectangle union(Rectangle r)
Computes the union of this Rectangle with the specified Rectangle. Returns a new Rectangle that represents the union of the two rectangles.

If either Rectangle has any dimension less than zero the rules for non-existant rectangles apply. If only one has a dimension less than zero, then the result will be a copy of the other Rectangle. If both have dimension less than zero, then the result will have at least one dimension less than zero.

If the resulting Rectangle would have a dimension too large to be expressed as an int, the result will have a dimension of Integer.MAX_VALUE along that dimension.

Parameters:
r - the specified Rectangle
Returns:
the smallest Rectangle containing both the specified Rectangle and this Rectangle.

isEmpty

public boolean isEmpty()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object