Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit.geom
Class Rectangle

java.lang.Object
  extended by com.sun.dtv.lwuit.geom.Rectangle

public class Rectangle
extends Object

Represents a Rectangle position (x, y) and Dimension (width, height), this is useful for measuring coordinates within the application.


Constructor Summary
Rectangle()
          Creates a new instance of Rectangle.
Rectangle(int x, int y, Dimension size)
          Creates a new instance of Rectangle at position (x, y) and with predefine dimension.
Rectangle(int x, int y, int w, int h)
          Creates a new instance of Rectangle at position (x, y) and with predefined width and height.
Rectangle(Point p, int w, int h)
          Create a new instance of Rectangle at a position specified by the Point parameter, and with the predefined width and height.
Rectangle(Rectangle rect)
          A copy Constructor.
Rectangle(Rectangle r)
          Creates a new instance of Rectangle with parameters taken from an instance of java.awt.Rectangle.
 
Method Summary
 boolean contains(int rX, int rY)
          Checks whether or not this Rectangle contains the point at the specified location (rX, rY).
 boolean contains(int rX, int rY, int rWidth, int rHeight)
          Checks whether this Rectangle entirely contains the Rectangle at the specified location (rX, rY) with the specified dimensions (rWidth, rHeight).
 boolean contains(Rectangle rect)
          Checks whether or not this Rectangle entirely contains the specified Rectangle.
 Dimension getSize()
          Return the dimension of the rectangle.
 int getX()
          Return the x coordinate of the rectangle.
 int getY()
          Return the y coordinate of the rectangle.
 boolean intersects(int x, int y, int width, int height)
          Determines whether or not this Rectangle and the specified Rectangle location (x, y) with the specified dimensions (width, height), intersect.
static boolean intersects(int tx, int ty, int tw, int th, int x, int y, int width, int height)
          Helper method allowing us to determine if two coordinate sets intersect.
 boolean intersects(Rectangle rect)
          Determines whether or not this Rectangle and the specified Rectangle location (x, y) with the specified dimensions (width, height), intersect.
 void setX(int x)
          Sets the x position of the rectangle.
 void setY(int y)
          Sets the y position of the rectangle.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rectangle

public Rectangle()
Creates a new instance of Rectangle.


Rectangle

public Rectangle(int x,
                 int y,
                 Dimension size)
Creates a new instance of Rectangle at position (x, y) and with predefine dimension.

Parameters:
x - the x coordinate of the rectangle.
y - the y coordinate of the rectangle.
size - the Dimension of the rectangle.

Rectangle

public Rectangle(int x,
                 int y,
                 int w,
                 int h)
Creates a new instance of Rectangle at position (x, y) and with predefined width and height.

Parameters:
x - the x coordinate of the rectangle.
y - the y coordinate of the rectangle.
w - the width of the rectangle.
h - the height of the rectangle.

Rectangle

public Rectangle(Point p,
                 int w,
                 int h)
Create a new instance of Rectangle at a position specified by the Point parameter, and with the predefined width and height.

Parameters:
p - the Point specifying the upper left corner of the rectangle
w - the width of the rectangle.
h - the height of the rectangle.

Rectangle

public Rectangle(Rectangle rect)
A copy Constructor.

Parameters:
rect - the Rectangle to copy.

Rectangle

public Rectangle(Rectangle r)
Creates a new instance of Rectangle with parameters taken from an instance of java.awt.Rectangle. This is a convenience constructor for improvement of the AWT integration.

Parameters:
r - java.awt.Rectnagle instance to take data from.
Method Detail

getSize

public Dimension getSize()
Return the dimension of the rectangle.

Returns:
the size of the rectangle.

getX

public int getX()
Return the x coordinate of the rectangle.

Returns:
the x coordinate of the rectangle.
See Also:
setX(int)

getY

public int getY()
Return the y coordinate of the rectangle.

Returns:
the y coordinate of the rectangle.
See Also:
setY(int)

toString

public String toString()

Overrides:
toString in class Object

setX

public void setX(int x)
Sets the x position of the rectangle.

Parameters:
x - the x coordinate of the rectangle.
See Also:
getX()

setY

public void setY(int y)
Sets the y position of the rectangle.

Parameters:
y - the y coordinate of the rectangle.
See Also:
getY()

contains

public boolean contains(Rectangle rect)
Checks whether or not this Rectangle entirely contains the specified Rectangle.

Parameters:
rect - the specified Rectangle.
Returns:
true if the Rectangle is contained entirely inside this Rectangle; false otherwise.

contains

public boolean contains(int rX,
                        int rY,
                        int rWidth,
                        int rHeight)
Checks whether this Rectangle entirely contains the Rectangle at the specified location (rX, rY) with the specified dimensions (rWidth, rHeight).

Parameters:
rX - the specified x coordinate.
rY - the specified y coordinate.
rWidth - the width of the Rectangle.
rHeight - the height of the Rectangle.
Returns:
true if the Rectangle specified by (rX, rY, rWidth, rHeight) is entirely enclosed inside this Rectangle; false otherwise.

contains

public boolean contains(int rX,
                        int rY)
Checks whether or not this Rectangle contains the point at the specified location (rX, rY).

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

intersects

public boolean intersects(int x,
                          int y,
                          int width,
                          int height)
Determines whether or not this Rectangle and the specified Rectangle location (x, y) with the specified dimensions (width, height), intersect. Two rectangles intersect if their intersection is nonempty.

Parameters:
x - the specified x coordinate.
y - the specified y coordinate.
width - the width of the Rectangle.
height - the height of the Rectangle.
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.

intersects

public boolean intersects(Rectangle rect)
Determines whether or not this Rectangle and the specified Rectangle location (x, y) with the specified dimensions (width, height), intersect. Two rectangles intersect if their intersection is nonempty.

Parameters:
rect - the Rectangle to check intersection with
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.

intersects

public static boolean intersects(int tx,
                                 int ty,
                                 int tw,
                                 int th,
                                 int x,
                                 int y,
                                 int width,
                                 int height)
Helper method allowing us to determine if two coordinate sets intersect. This saves us the need of creating a rectangle object for a quick calculation.

Parameters:
tx - x coordinate of upper left corner of rectangle 1
ty - y coordinate of upper left corner of rectangle 1
tw - width of rectangle 1
th - height of rectangle 1
x - x coordinate of upper left corner of rectangle 2
y - y coordinate of upper left corner of rectangle 2
width - width of rectangle 2
height - height of rectangle 2
Returns:
true if rectangles intersect

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.