jaron.gui
Class Rect

java.lang.Object
  extended by jaron.gui.Rect
Direct Known Subclasses:
ActuatorXY

public class Rect
extends java.lang.Object

The Rect class represents a rectangle in a coordinate system.
It is defined by its upper left corner (top, left), a width and a height.

Since:
1.0
Version:
1.2
Author:
jarontec gmail com

Constructor Summary
Rect()
          Creates an new Rect object.
Rect(int left, int top, int width, int height)
          Creates an new Rect object.
 
Method Summary
 java.lang.Boolean contains(int x, int y)
          Checks whether or not this Rect contains the point at the specified location (x,y).
 Rect createIntersection(Rect rect)
          Computes the intersection of this Rectangle with the specified Rect.
 int getHeight()
          Returns the height of the Rect.
 int getLeft()
          Returns the x coordinate of the Rect.
 int getTop()
          Returns the y coordinate of the Rect.
 int getWidth()
          Returns the width of the Rect.
 void setHeight(int height)
          Sets the height of the Rect.
 void setLeft(int left)
          Sets the x coordinate of the Rect.
 void setLocation(int left, int top)
          Moves the Rect to the specified location.
 void setSize(int width, int height)
          Sets the width and height of the Rect.
 void setTop(int top)
          Sets the y coordinate of the Rect.
 void setWidth(int width)
          Sets the width of the Rect.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rect

public Rect(int left,
            int top,
            int width,
            int height)
Creates an new Rect object.

Parameters:
left - the x coordinate
top - the y coordinate
width - the width
height - the height

Rect

public Rect()
Creates an new Rect object. Its coordinates, its width and and height are set to 0.

Method Detail

contains

public java.lang.Boolean contains(int x,
                                  int y)
Checks whether or not this Rect contains the point at the specified location (x,y).

Parameters:
x - the specified x coordinate
y - the specified y coordinate
Returns:
true if the point (x,y) is inside this rectangle; false otherwise

createIntersection

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

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

getHeight

public int getHeight()
Returns the height of the Rect.

Returns:
the height

getLeft

public int getLeft()
Returns the x coordinate of the Rect.

Returns:
the x coordinate

getTop

public int getTop()
Returns the y coordinate of the Rect.

Returns:
the y coordinate

getWidth

public int getWidth()
Returns the width of the Rect.

Returns:
the width

setHeight

public void setHeight(int height)
Sets the height of the Rect.

Parameters:
height - the height

setLeft

public void setLeft(int left)
Sets the x coordinate of the Rect.

Parameters:
left - the x coordinate

setLocation

public void setLocation(int left,
                        int top)
Moves the Rect to the specified location.

Parameters:
left - the x coordinate of the new location
top - the y coordinate of the new location

setSize

public void setSize(int width,
                    int height)
Sets the width and height of the Rect.

Parameters:
width - the new width
height - the new height

setTop

public void setTop(int top)
Sets the y coordinate of the Rect.

Parameters:
top - the y coordinate

setWidth

public void setWidth(int width)
Sets the width of the Rect.

Parameters:
width - the width