jwo.utils
Class JWRectangle

java.lang.Object
  |
  +--jwo.utils.JWRectangle

public class JWRectangle
extends Object

Class for storing a rectangle with floating point coordinates. Rectangle has an origin at the lower left and a width and height.

Version:
1.8.0, 1st May, 1999
Author:
Jo Wood

Field Summary
 float height
          Height of rectangle.
 float width
          Width of rectangle.
 float x
          x-coordinate of rectangle origin.
 float y
          y-coordinate of rectangle origin.
 
Constructor Summary
JWRectangle(Dimension dimension)
          Creates a rectangle from a given AWT Dimension object.
JWRectangle(float width, float height)
          Creates a rectangle with given dimensions and 0 origin.
JWRectangle(float x, float y, float width, float height)
          Creates a rectangle with a given origin and dimensions.
JWRectangle(Rectangle rect)
          Creates a JWRectangle from a given AWT Rectangle object.
 
Method Summary
 Dimension getDimension()
          Converts the rectangle into an AWT Dimension object.
 Rectangle getRectangle()
          Converts the rectangle into an AWT Rectangle object.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
x-coordinate of rectangle origin.


y

public float y
y-coordinate of rectangle origin.


width

public float width
Width of rectangle.


height

public float height
Height of rectangle.

Constructor Detail

JWRectangle

public JWRectangle(float width,
                   float height)
Creates a rectangle with given dimensions and 0 origin.

Parameters:
width - Width of rectangle.
height - Height of rectangle.

JWRectangle

public JWRectangle(Dimension dimension)
Creates a rectangle from a given AWT Dimension object.

Parameters:
dimension - AWR Dimension object.

JWRectangle

public JWRectangle(Rectangle rect)
Creates a JWRectangle from a given AWT Rectangle object. Note that as well as converting integer coordinates to floats, the origin is flipped from top left to bottom left.

Parameters:
rect - AWT Rectangle object.

JWRectangle

public JWRectangle(float x,
                   float y,
                   float width,
                   float height)
Creates a rectangle with a given origin and dimensions.

Parameters:
x - x-coordinate of rectangle origin.
y - y-coordinate of rectangle origin.
width - Width of rectangle.
height - Height of rectangle.
Method Detail

getDimension

public Dimension getDimension()
Converts the rectangle into an AWT Dimension object. Note that the origin is lost and the width and height are converted into integers.

Returns:
Dimension of rectangle.

getRectangle

public Rectangle getRectangle()
Converts the rectangle into an AWT Rectangle object. Note that the origin, width and height are converted into integers and the the origin is flipped from the bottom left to top left.

Returns:
AWT Rectangle representation.

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
String String representation of this object.