y.geom
Class YRectangle

java.lang.Object
  |
  +--y.geom.YDimension
        |
        +--y.geom.YRectangle
All Implemented Interfaces:
Comparable, PlaneObject

public class YRectangle
extends YDimension
implements PlaneObject

This class defines a rectangle und provides utility methods for it.


Field Summary
 double x
          The x coordinate of the upper left corner.
 double y
          The y coordinate of the upper left corner.
 
Fields inherited from class y.geom.YDimension
height, width
 
Constructor Summary
YRectangle()
          Creates a new rectangle with upper left corner (0,0) and size (0,0).
YRectangle(double x, double y, double width, double height)
          Creates a new rectangle with given upper left corner and size.
YRectangle(YPoint pos, YDimension size)
          Creates a new rectangle with given upper left corner and size.
 
Method Summary
 int compareTo(Object o)
           
 boolean contains(double x, double y)
          checks whether or not this YRectangle contains the given point.
 boolean contains(YPoint p)
          checks whether or not this YRectangle contains the given point.
 boolean equals(Object o)
          Tests a dimension to equality to another dimension.
 YRectangle getBoundingBox()
          Returns this object.
 YPoint getLocation()
          Returns coordinates of upper left corner.
 double getX()
          Returns x-coordinate of upper left corner.
 double getY()
          Returns y-coordinate of upper left corner.
 int hashCode()
           
static boolean intersects(YRectangle r1, YRectangle r2)
          Returns whether or not the given rectangles intersect.
 String toString()
          Returns a string representation of this rectangle
 
Methods inherited from class y.geom.YDimension
getHeight, getWidth
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public final double x
The x coordinate of the upper left corner.


y

public final double y
The y coordinate of the upper left corner.

Constructor Detail

YRectangle

public YRectangle()
Creates a new rectangle with upper left corner (0,0) and size (0,0).


YRectangle

public YRectangle(YPoint pos,
                  YDimension size)
Creates a new rectangle with given upper left corner and size.

Parameters:
pos - upper left corner of the rectangle.
size - size of the rectangle.

YRectangle

public YRectangle(double x,
                  double y,
                  double width,
                  double height)
Creates a new rectangle with given upper left corner and size.

Parameters:
x - x-coordinate of upper left corner of the rectangle.
y - y-coordiante of upper left corner of the rectangle.
width - width of the rectangle.
height - height of the rectangle.
Method Detail

getX

public final double getX()
Returns x-coordinate of upper left corner.


getY

public final double getY()
Returns y-coordinate of upper left corner.


getLocation

public final YPoint getLocation()
Returns coordinates of upper left corner.


getBoundingBox

public YRectangle getBoundingBox()
Returns this object.

Specified by:
getBoundingBox in interface PlaneObject

contains

public boolean contains(double x,
                        double y)
checks whether or not this YRectangle contains the given point.


contains

public boolean contains(YPoint p)
checks whether or not this YRectangle contains the given point.


intersects

public static boolean intersects(YRectangle r1,
                                 YRectangle r2)
Returns whether or not the given rectangles intersect.


toString

public String toString()
Returns a string representation of this rectangle

Overrides:
toString in class YDimension

hashCode

public int hashCode()
Overrides:
hashCode in class YDimension

equals

public boolean equals(Object o)
Description copied from class: YDimension
Tests a dimension to equality to another dimension.

Overrides:
equals in class YDimension

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class YDimension

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003