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
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).
public static Rect rectFromIntersection(Rect rect1,
Rect rect2)
- Returns a Rect representing the intersection of rect1 and
rect2.
public static Rect rectFromUnion(Rect rect1,
Rect rect2)
- Returns a Rect representing the union of rect1 and
rect2.
public String toString()
- Returns the Rect's String representation.
- Overrides:
- toString in class Object
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.
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
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).
public void moveTo(int x,
int y)
- Sets the Rect's origin to (x, y).
public void moveBy(int deltaX,
int deltaY)
- Moves the Rect's origin by (deltaX, deltaY).
public void sizeTo(int width,
int height)
- Sets the Rect's size to (width, height).
public void sizeBy(int deltaWidth,
int deltaHeight)
- Changes the Rect's size by (deltaWidth, deltaHeight).
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).
public int maxX()
- Convenience method for computing x + width.
public int maxY()
- Convenience method for computing y + height.
public int midX()
- Convenience method for computing x + width / 2.
public int midY()
- Convenience method for computing y + height / 2.
public boolean equals(Object anObject)
- Returns true if the Rect equals anObject.
- Overrides:
- equals in class Object
public int hashCode()
- Returns the Rect's hash code.
- Overrides:
- hashCode in class Object
public boolean isEmpty()
- Returns true if the Rect has zero width or height.
public boolean contains(int x,
int y)
- Returns true if the Rect contains the point
(x, y).
public boolean contains(Point aPoint)
- Returns true if the Rect contains aPoint.
- See Also:
- contains
public boolean contains(Rect aRect)
- Returns true if the Rect completely contains aRect.
public boolean intersects(int x,
int y,
int width,
int height)
- Returns true if the Rect and the rectangle (x, y,
width, height) overlap.
public boolean intersects(Rect aRect)
- Returns true if the Rect and aRect overlap.
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).
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.
public Rect intersectionRect(Rect aRect)
- Returns a new Rect corresponding to the intersection of the Rect and
aRect
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).
public void unionWith(Rect aRect)
- Sets the Rect's origin and size to correspond to the union of the
the Rect and aRect.
public Rect unionRect(Rect aRect)
- Returns a new Rect corresponding to the union of the Rect and
aRect.
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.
public void describeClassInfo(ClassInfo info)
- Describes the Rect class' coding information.
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Encodes the Rect.
- See Also:
- encode
public void decode(Decoder decoder) throws CodingException
- Decodes the Rect.
- See Also:
- decode
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
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997