Class Rect
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Rect

public class netscape.application.Rect
    extends java.lang.Object
    implements netscape.util.Codable
{
    /* Fields
     */
    public int height;
    public int width;
    public int x;
    public int y;

    /* Constructors
     */
    public Rect();
    public Rect(int, int, int, int);
    public Rect(Rect);

    /* Methods
     */
    public static boolean contains(int, int, int, int, int, int);
    public static Rect rectFromIntersection(Rect, Rect);
    public static Rect rectFromUnion(Rect, Rect);

    public void computeDisunionRects(Rect, Vector);
    public boolean contains(int, int);
    public boolean contains(Point);
    public boolean contains(Rect);
    public void decode(Decoder);
    public void describeClassInfo(ClassInfo);
    public void encode(Encoder);
    public boolean equals(Object);
    public void finishDecoding();
    public void growBy(int, int);
    public int hashCode();
    public void intersectWith(int, int, int, int);
    public void intersectWith(Rect);
    public Rect intersectionRect(Rect);
    public boolean intersects(int, int, int, int);
    public boolean intersects(Rect);
    public boolean isEmpty();
    public int maxX();
    public int maxY();
    public int midX();
    public int midY();
    public void moveBy(int, int);
    public void moveTo(int, int);
    public void setBounds(int, int, int, int);
    public void setBounds(Rect);
    public void setCoordinates(int, int, int, int);
    public void sizeBy(int, int);
    public void sizeTo(int, int);
    public String toString();
    public Rect unionRect(Rect);
    public void unionWith(int, int, int, int);
    public void unionWith(Rect);
}
Object subclass representing a rectangle (its origin and positive size).

Fields

x

  public int x
The Rect's X-coordinate.

y

  public int y
The Rect's Y-coordinate.

width

  public int width
The Rect's width.

height

  public int height
The Rect's height.

Constructors

Rect

  public Rect()
Constructs a Rect with origin (0, 0) and zero width and height.

Rect

  public Rect(int x,
              int y,
              int width,
              int height)
Constructs a Rect with origin (x, y) and size (width, height).

Rect

  public Rect(Rect templateRect)
Constructs a Rect with the same origin and size as templateRect.

Methods

contains

  public static boolean contains(int x,
                                 int y,
                                 int width,
                                 int height,
                                 int pointX,
                                 int pointY)
Returns true if the rect defined by (x, y, width, height) contains the point (pointX, pointY).

rectFromIntersection

  public static Rect rectFromIntersection(Rect rect1,
                                          Rect rect2)
Returns a Rect representing the intersection of rect1 and rect2.

rectFromUnion

  public static Rect rectFromUnion(Rect rect1,
                                   Rect rect2)
Returns a Rect representing the union of rect1 and rect2.

toString

  public String toString()
Returns the Rect's String representation.
Overrides:
toString in class Object

setBounds

  public void setBounds(int x,
                        int y,
                        int width,
                        int height)
Sets the Rect's origin to (x, y) and size to (width, height). If width or height are negative, sets them to zero.

setBounds

  public void setBounds(Rect rect)
Sets the Rect to have the same origin and size as rect. If rect is null, sets the Rect's origin to (0, 0) and zero width and height.
See Also:
setBounds

setCoordinates

  public void setCoordinates(int x1,
                             int y1,
                             int x2,
                             int y2)
Sets the Rect's origin to (x1, y1) and size to (x2 - x1, y2 - y1).

moveTo

  public void moveTo(int x,
                     int y)
Sets the Rect's origin to (x, y).

moveBy

  public void moveBy(int deltaX,
                     int deltaY)
Moves the Rect's origin by (deltaX, deltaY).

sizeTo

  public void sizeTo(int width,
                     int height)
Sets the Rect's size to (width, height).

sizeBy

  public void sizeBy(int deltaWidth,
                     int deltaHeight)
Changes the Rect's size by (deltaWidth, deltaHeight).

growBy

  public void growBy(int deltaX,
                     int deltaY)
Moves the Rect's left and right sides by deltaX pixels and its top and bottom sides by deltaY. For example, starting with a Rect with dimensions (5, 5, 10, 10), growBy(1, -1) leaves the Rect with the dimensions (4, 6, 12, 8).

maxX

  public int maxX()
Convenience method for computing x + width.

maxY

  public int maxY()
Convenience method for computing y + height.

midX

  public int midX()
Convenience method for computing x + width / 2.

midY

  public int midY()
Convenience method for computing y + height / 2.

equals

  public boolean equals(Object anObject)
Returns true if the Rect equals anObject.
Overrides:
equals in class Object

hashCode

  public int hashCode()
Returns the Rect's hash code.
Overrides:
hashCode in class Object

isEmpty

  public boolean isEmpty()
Returns true if the Rect has zero width or height.

contains

  public boolean contains(int x,
                          int y)
Returns true if the Rect contains the point (x, y).

contains

  public boolean contains(Point aPoint)
Returns true if the Rect contains aPoint.
See Also:
contains

contains

  public boolean contains(Rect aRect)
Returns true if the Rect completely contains aRect.

intersects

  public boolean intersects(int x,
                            int y,
                            int width,
                            int height)
Returns true if the Rect and the rectangle (x, y, width, height) overlap.

intersects

  public boolean intersects(Rect aRect)
Returns true if the Rect and aRect overlap.

intersectWith

  public void intersectWith(int x,
                            int y,
                            int width,
                            int height)
Sets the Rect's origin and size to correspond to the intersection of the Rect's current dimensions and the rectangle (x, y, width, height).

intersectWith

  public void intersectWith(Rect aRect)
Sets the Rect's origin and size to correspond to the intersection of the Rect's current dimensions and aRect.

intersectionRect

  public Rect intersectionRect(Rect aRect)
Returns a new Rect corresponding to the intersection of the Rect and aRect

unionWith

  public void unionWith(int x,
                        int y,
                        int width,
                        int height)
Sets the Rect's origin and size to correspond to the union of the the Rect and the rectangle (x, y, width, height).

unionWith

  public void unionWith(Rect aRect)
Sets the Rect's origin and size to correspond to the union of the the Rect and aRect.

unionRect

  public Rect unionRect(Rect aRect)
Returns a new Rect corresponding to the union of the Rect and aRect.

computeDisunionRects

  public void computeDisunionRects(Rect aRect,
                                   Vector rects)
Fills rects with Rects representing the regions within the Rect that do not overlap with aRect. If the two Rects do not overlap, it leaves rects empty.

describeClassInfo

  public void describeClassInfo(ClassInfo info)
Describes the Rect class' coding information.
See Also:
describeClassInfo

encode

  public void encode(Encoder encoder) throws CodingException
Encodes the Rect.
See Also:
encode

decode

  public void decode(Decoder decoder) throws CodingException
Decodes the Rect.
See Also:
decode

finishDecoding

  public void finishDecoding() throws CodingException
Finishes the Rect decoding. This method does nothing.
See Also:
finishDecoding

All Packages  Class Hierarchy  This Package  Previous  Next  Index