Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.infomatiq.jsi
Class Rectangle

    java.lang.Object
      com.infomatiq.jsi.Rectangle

    public class Rectangle

extends java.lang.Object

Currently hardcoded to 2 dimensions, but could be extended.

Version:
  1.0b6
Author:
  aled@sourceforge.net

Field Summary
`float` | `maxX` use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.
`float` | `maxY` use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.
`float` | `minX` use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.
`float` | `minY` use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.

Constructor Summary
`Rectangle()`
`Rectangle(float x1, float y1, float x2, float y2)` Constructor.

Method Summary
`void` | `add(Point p)` Computes the union of this rectangle and the passed point, storing the result in this rectangle.
`void` | `add(Rectangle r)` Computes the union of this rectangle and the passed rectangle, storing the result in this rectangle.
`float` | `area()` Compute the area of this rectangle.
`static float` | `area(float minX, float minY, float maxX, float maxY)` Compute the area of a rectangle.
`float` | `aspectRatio()`
`Point` | `centre()`
`boolean` | `containedBy(Rectangle r)` Determine whether this rectangle is contained by the passed rectangle
`static boolean` | `contains(float r1MinX, float r1MinY, float r1MaxX, float r1MaxY, float r2MinX, float r2MinY, float r2MaxX, float r2MaxY)` Determine whether or not one rectangle contains another.
`boolean` | `contains(Rectangle r)` Determine whether this rectangle contains the passed rectangle
`Rectangle` | `copy()` Make a copy of this rectangle
`static float` | `distance(float minX, float minY, float maxX, float maxY, float pX, float pY)` Return the distance between a rectangle and a point.
`float` | `distance(Point p)` Return the distance between this rectangle and the passed point.
`float` | `distance(Rectangle r)` Return the distance between this rectangle and the passed rectangle.
`static float` | `distanceSq(float minX, float minY, float maxX, float maxY, float pX, float pY)`
`boolean` | `edgeOverlaps(Rectangle r)` Determine whether an edge of this rectangle overlies the equivalent edge of the passed rectangle
`static float` | `enlargement(float r1MinX, float r1MinY, float r1MaxX, float r1MaxY, float r2MinX, float r2MinY, float r2MaxX, float r2MaxY)` Calculate the area by which a rectangle would be enlarged if added to the passed rectangle..
`float` | `enlargement(Rectangle r)` Calculate the area by which this rectangle would be enlarged if added to the passed rectangle.
`boolean` | `equals(java.lang.Object o)` Determine whether this rectangle is equal to a given object.
`float` | `height()`
`static boolean` | `intersects(float r1MinX, float r1MinY, float r1MaxX, float r1MaxY, float r2MinX, float r2MinY, float r2MaxX, float r2MaxY)` Determine whether or not two rectangles intersect
`boolean` | `intersects(Rectangle r)` Determine whether this rectangle intersects the passed rectangle
`boolean` | `sameObject(java.lang.Object o)` Determine whether this rectangle is the same as another object Note that two rectangles can be equal but not the same object, if they both have the same bounds.
`void` | `set(float x1, float y1, float x2, float y2)` Sets the size of the rectangle.
`void` | `set(Rectangle r)` Sets the size of this rectangle to equal the passed rectangle.
`java.lang.String` | `toString()` Return a string representation of this rectangle, in the form: (1.2, 3.4), (5.6, 7.8)
`Rectangle` | `union(Rectangle r)` Find the the union of this rectangle and the passed rectangle.
`float` | `width()` Utility methods (not used by JSI); added to enable this to be used as a generic rectangle class

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### minX

    public float minX

  use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.

### minY

    public float minY

  use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.

### maxX

    public float maxX

  use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.

### maxY

    public float maxY

  use primitives instead of arrays for the coordinates of the rectangle, to reduce memory requirements.

Constructor Detail

### Rectangle

    public Rectangle()

### Rectangle

    public Rectangle(float x1,
                     float y1,
                     float x2,
                     float y2)

  Constructor.

  Parameters:
    `x1` - coordinate of any corner of the rectangle
    `y1` - (see x1)
    `x2` - coordinate of the opposite corner
    `y2` - (see x2)

Method Detail

### set

    public void set(float x1,
                    float y1,
                    float x2,
                    float y2)

  Sets the size of the rectangle.

  Parameters:
    `x1` - coordinate of any corner of the rectangle
    `y1` - (see x1)
    `x2` - coordinate of the opposite corner
    `y2` - (see x2)

### set

    public void set(Rectangle r)

  Sets the size of this rectangle to equal the passed rectangle.

### copy

    public Rectangle copy()

  Make a copy of this rectangle

  Returns:
    copy of this rectangle

### edgeOverlaps

    public boolean edgeOverlaps(Rectangle r)

  Determine whether an edge of this rectangle overlies the equivalent edge of the passed rectangle

### intersects

    public boolean intersects(Rectangle r)

  Determine whether this rectangle intersects the passed rectangle

  Parameters:
    `r` - The rectangle that might intersect this rectangle
  Returns:
    true if the rectangles intersect, false if they do not intersect

### intersects

    public static boolean intersects(float r1MinX,
                                     float r1MinY,
                                     float r1MaxX,
                                     float r1MaxY,
                                     float r2MinX,
                                     float r2MinY,
                                     float r2MaxX,
                                     float r2MaxY)

  Determine whether or not two rectangles intersect

  Parameters:
    `r1MinX` - minimum X coordinate of rectangle 1
    `r1MinY` - minimum Y coordinate of rectangle 1
    `r1MaxX` - maximum X coordinate of rectangle 1
    `r1MaxY` - maximum Y coordinate of rectangle 1
    `r2MinX` - minimum X coordinate of rectangle 2
    `r2MinY` - minimum Y coordinate of rectangle 2
    `r2MaxX` - maximum X coordinate of rectangle 2
    `r2MaxY` - maximum Y coordinate of rectangle 2
  Returns:
    true if r1 intersects r2, false otherwise.

### contains

    public boolean contains(Rectangle r)

  Determine whether this rectangle contains the passed rectangle

  Parameters:
    `r` - The rectangle that might be contained by this rectangle
  Returns:
    true if this rectangle contains the passed rectangle, false if it does not

### contains

    public static boolean contains(float r1MinX,
                                   float r1MinY,
                                   float r1MaxX,
                                   float r1MaxY,
                                   float r2MinX,
                                   float r2MinY,
                                   float r2MaxX,
                                   float r2MaxY)

  Determine whether or not one rectangle contains another.

  Parameters:
    `r1MinX` - minimum X coordinate of rectangle 1
    `r1MinY` - minimum Y coordinate of rectangle 1
    `r1MaxX` - maximum X coordinate of rectangle 1
    `r1MaxY` - maximum Y coordinate of rectangle 1
    `r2MinX` - minimum X coordinate of rectangle 2
    `r2MinY` - minimum Y coordinate of rectangle 2
    `r2MaxX` - maximum X coordinate of rectangle 2
    `r2MaxY` - maximum Y coordinate of rectangle 2
  Returns:
    true if r1 contains r2, false otherwise.

### containedBy

    public boolean containedBy(Rectangle r)

  Determine whether this rectangle is contained by the passed rectangle

  Parameters:
    `r` - The rectangle that might contain this rectangle
  Returns:
    true if the passed rectangle contains this rectangle, false if it does not

### distance

    public float distance(Point p)

  Return the distance between this rectangle and the passed point. If the rectangle contains the point, the distance is zero.

  Parameters:
    `p` - Point to find the distance to
  Returns:
    distance beween this rectangle and the passed point.

### distance

    public static float distance(float minX,
                                 float minY,
                                 float maxX,
                                 float maxY,
                                 float pX,
                                 float pY)

  Return the distance between a rectangle and a point. If the rectangle contains the point, the distance is zero.

  Parameters:
    `minX` - minimum X coordinate of rectangle
    `minY` - minimum Y coordinate of rectangle
    `maxX` - maximum X coordinate of rectangle
    `maxY` - maximum Y coordinate of rectangle
    `pX` - X coordinate of point
    `pY` - Y coordinate of point
  Returns:
    distance beween this rectangle and the passed point.

### distanceSq

    public static float distanceSq(float minX,
                                   float minY,
                                   float maxX,
                                   float maxY,
                                   float pX,
                                   float pY)

### distance

    public float distance(Rectangle r)

  Return the distance between this rectangle and the passed rectangle. If the rectangles overlap, the distance is zero.

  Parameters:
    `r` - Rectangle to find the distance to
  Returns:
    distance between this rectangle and the passed rectangle

### enlargement

    public float enlargement(Rectangle r)

  Calculate the area by which this rectangle would be enlarged if added to the passed rectangle. Neither rectangle is altered.

  Parameters:
    `r` - Rectangle to union with this rectangle, in order to compute the difference in area of the union and the original rectangle
  Returns:
    enlargement

### enlargement

    public static float enlargement(float r1MinX,
                                    float r1MinY,
                                    float r1MaxX,
                                    float r1MaxY,
                                    float r2MinX,
                                    float r2MinY,
                                    float r2MaxX,
                                    float r2MaxY)

  Calculate the area by which a rectangle would be enlarged if added to the passed rectangle..

  Parameters:
    `r1MinX` - minimum X coordinate of rectangle 1
    `r1MinY` - minimum Y coordinate of rectangle 1
    `r1MaxX` - maximum X coordinate of rectangle 1
    `r1MaxY` - maximum Y coordinate of rectangle 1
    `r2MinX` - minimum X coordinate of rectangle 2
    `r2MinY` - minimum Y coordinate of rectangle 2
    `r2MaxX` - maximum X coordinate of rectangle 2
    `r2MaxY` - maximum Y coordinate of rectangle 2
  Returns:
    enlargement

### area

    public float area()

  Compute the area of this rectangle.

  Returns:
    The area of this rectangle

### area

    public static float area(float minX,
                             float minY,
                             float maxX,
                             float maxY)

  Compute the area of a rectangle.

  Parameters:
    `minX` - the minimum X coordinate of the rectangle
    `minY` - the minimum Y coordinate of the rectangle
    `maxX` - the maximum X coordinate of the rectangle
    `maxY` - the maximum Y coordinate of the rectangle
  Returns:
    The area of the rectangle

### add

    public void add(Rectangle r)

  Computes the union of this rectangle and the passed rectangle, storing the result in this rectangle.

  Parameters:
    `r` - Rectangle to add to this rectangle

### add

    public void add(Point p)

  Computes the union of this rectangle and the passed point, storing the result in this rectangle.

  Parameters:
    `p` - Point to add to this rectangle

### union

    public Rectangle union(Rectangle r)

  Find the the union of this rectangle and the passed rectangle. Neither rectangle is altered

  Parameters:
    `r` - The rectangle to union with this rectangle

### equals

    public boolean equals(java.lang.Object o)

  Determine whether this rectangle is equal to a given object. Equality is determined by the bounds of the rectangle.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `o` - The object to compare with this rectangle

### sameObject

    public boolean sameObject(java.lang.Object o)

  Determine whether this rectangle is the same as another object Note that two rectangles can be equal but not the same object, if they both have the same bounds.

  Parameters:
    `o` - The object to compare with this rectangle.

### toString

    public java.lang.String toString()

  Return a string representation of this rectangle, in the form: (1.2, 3.4), (5.6, 7.8)

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    String String representation of this rectangle.

### width

    public float width()

  Utility methods (not used by JSI); added to enable this to be used as a generic rectangle class

### height

    public float height()

### aspectRatio

    public float aspectRatio()

### centre

    public Point centre()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD