eu.webtoolkit.jwt
Class WRectF

java.lang.Object
  extended by eu.webtoolkit.jwt.WRectF

public class WRectF
extends java.lang.Object

A value class that defines a rectangle.

The rectangle is defined by a top-left point and a width and height.


Constructor Summary
WRectF()
          Default constructor.
WRectF(double x, double y, double width, double height)
          Creates a rectangle.
WRectF(WPointF topLeft, WPointF bottomRight)
          Creates a rectangle.
 
Method Summary
 WRectF assign(WRectF rhs)
          Internal assign method.
 boolean contains(double x, double y)
          Tests if a rectangle contains a point.
 boolean contains(WPointF p)
          Tests if a rectangle contains a point.
 boolean equals(WRectF rhs)
          Indicates whether some other object is "equal to" this one.
 double getBottom()
          Returns the bottom side offset.
 WPointF getBottomLeft()
          Returns the bottom left point.
 WPointF getBottomRight()
          Returns the bottom right point.
 WPointF getCenter()
          Returns the center point.
 double getHeight()
          Returns the height.
 double getLeft()
          Returns the X position (left side offset).
 WRectF getNormalized()
          Returns a normalized rectangle.
 double getRight()
          Returns the the right side offset.
 double getTop()
          Returns the Y position (top side offset).
 WPointF getTopLeft()
          Returns the top left point.
 WPointF getTopRight()
          Returns the top right point.
 double getWidth()
          Returns the width.
 double getX()
          Returns the X-position (left side offset).
 double getY()
          Returns the Y-position (top side offset).
 boolean intersects(WRectF other)
          Tests if two rectangles intersect.
 boolean isEmpty()
          Determines whether or not this rectangle is empty.
 void setHeight(double height)
          Sets the Y-position of the top side.
 void setWidth(double width)
          Sets the width.
 void setX(double x)
          Sets the X-position of the left side.
 void setY(double y)
          Sets the Y-position of the top side.
 WRectF united(WRectF other)
          Makes the union of to rectangles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WRectF

public WRectF()
Default constructor.

Constructs an empty rectangle at point (0, 0).


WRectF

public WRectF(double x,
              double y,
              double width,
              double height)
Creates a rectangle.

Constructs a rectangle with top left point (x, y) and size width x height.


WRectF

public WRectF(WPointF topLeft,
              WPointF bottomRight)
Creates a rectangle.

Constructs a rectangle from the two points topLeft and bottomRight.

If you want to create a rectangle from two arbitrary corner points, you can use this constructor too, but should call getNormalized() afterwords.

Method Detail

assign

public WRectF assign(WRectF rhs)
Internal assign method.


equals

public boolean equals(WRectF rhs)
Indicates whether some other object is "equal to" this one.


isEmpty

public boolean isEmpty()
Determines whether or not this rectangle is empty.

A rectangle is empty if its width and height are zero.


setX

public void setX(double x)
Sets the X-position of the left side.

The right side of the rectangle does not move, and as a result, the rectangle may be resized.


setY

public void setY(double y)
Sets the Y-position of the top side.

The bottom side of the rectangle does not move, and as a result, the rectangle may be resized.


setWidth

public void setWidth(double width)
Sets the width.

The right side of the rectangle may move, but this does not affect the left side.


setHeight

public void setHeight(double height)
Sets the Y-position of the top side.

The bottom side of the rectangle may move, but this does not affect the Y position of the top side.


getX

public double getX()
Returns the X-position (left side offset).

This is equivalent to getLeft().

See Also:
getY(), getLeft()

getY

public double getY()
Returns the Y-position (top side offset).

This is equivalent to getTop().

See Also:
getX(), getTop()

getWidth

public double getWidth()
Returns the width.

See Also:
getHeight()

getHeight

public double getHeight()
Returns the height.

See Also:
getWidth()

getLeft

public double getLeft()
Returns the X position (left side offset).

See Also:
getX(), getRight()

getTop

public double getTop()
Returns the Y position (top side offset).

See Also:
getY(), getBottom()

getRight

public double getRight()
Returns the the right side offset.

See Also:
getLeft()

getBottom

public double getBottom()
Returns the bottom side offset.

See Also:
getTop()

getTopLeft

public WPointF getTopLeft()
Returns the top left point.

See Also:
getLeft(), getTop()

getTopRight

public WPointF getTopRight()
Returns the top right point.

See Also:
getRight(), getTop()

getCenter

public WPointF getCenter()
Returns the center point.


getBottomLeft

public WPointF getBottomLeft()
Returns the bottom left point.

See Also:
getLeft(), getBottom()

getBottomRight

public WPointF getBottomRight()
Returns the bottom right point.

See Also:
getRight(), getBottom()

contains

public boolean contains(WPointF p)
Tests if a rectangle contains a point.


contains

public boolean contains(double x,
                        double y)
Tests if a rectangle contains a point.


intersects

public boolean intersects(WRectF other)
Tests if two rectangles intersect.


united

public WRectF united(WRectF other)
Makes the union of to rectangles.


getNormalized

public WRectF getNormalized()
Returns a normalized rectangle.

A normalized rectangle has a positive width and height.