PATH
Documentation >
Mac OS X >
Foundation Reference: Java
- Inherits
from:
- NSRect : Object
- Package:
- com.apple.yellow.foundation
Class Description
An NSMutableRect is an object representing
a rectangle that can be modified. The elemental attributes of a
rectangle are its origin (its starting x-coordinate and y-coordinate)
and its size (its width and height as measured from the origin).
The methods of NSMutableRect allow you to change these elemental values.
They also let you inset and offset rectangles by specific amounts
and alter an NSMutableRect based on its union or intersection with
another NSRect object.
The main purpose for NSMutableRects is to provide a way for
methods to return rectangle values in an "out" parameter. A
client creates and passes in one or more NSMutableRects to a method
and gets back converted objects when the method returns. NSMutableRect
are also useful for performance reasons; instead of creating multiple
NSRects in a loop, you can create just one NSMutablePoint and reuse
it.
Method Types
- Constructors
- NSMutableRect
- Accessing and setting
coordinate values
- setOrigin
- x
- y
- setX
- setY
- Accessing and setting
size values
- height
- setHeight
- setSize
- width
- setWidth
- Transforming mutable
rectangles
- insetRect
- intersectRect
- makeIntegral
- offsetRect
- unionRect
Constructors
public NSMutableRect()
Initializes an empty mutable rectangle (that
is, a rectangle with at least one dimension of zero).
public NSMutableRect(
float x,
float y,
float w,
float h)
Initializes an NSMutableRect from a starting
x-coordinate (x), a starting y-coordinate
(y), a width value (w),
and a height value (h). If either
width and height is zero, it initializes an empty rectangle.
public NSMutableRect(
NSPoint aPoint,
NSSize aSize)
Initializes an NSMutableRect from an NSPoint
object and an NSSize object.
public NSMutableRect(
NSPoint pointOne,
NSPoint pointTwo)
Initializes an NSMutableRect from two NSPoint
objects. Creates the smallest rectangle containing the two points.
public NSMutableRect(java.awt.Rectangle aRectangle)
Initializes an NSMutableRect from an AWT Rectangle
object.
public NSMutableRect(NSRect aRectangle)
Initializes an NSMutableRect from a NSRect object;
this constructor is used in cloning the receiver
Instance Methods
public Object clone()
Description forthcoming.
public float height()
Returns the height dimension of the receiver.
NSMutableRect overrides this method because implementation details
make that necessarySee Also: setHeight, width
public void insetRect(
float vertDistance,
float horizDistance)
Modifies the receiver to be inset from both
upper and lower edges by vertDistance and
from both left and right edges by horzDistance.
The values vertDistance and horizDistance can
be negative. An IllegalArgumentException is thrown if the resulting
width or height would be negative.See Also: offsetRect
public void intersectRect(NSRect otherRectangle)
Modifies the receiver to be the intersection
of itself and otherRectangle. If
either the receiver or otherRectangle has
an empty dimension, it modifies the receiver to be an empty rectangle
(all dimensions) at point {0.0f,0.0f}.See
Also: unionRect
public void makeIntegral()
Changes the receiver so that its origin and
size are rounded to the nearest integer, ensuring that the receiver
completely contains the original rectangle. The x-coordinate and
the y-coordinate are rounded down and the height and width are rounded
up. If the receiver has an empty dimension, it is modified to be
an empty rectangle (all dimensions) at point {0.0f,0.0f}.
public void offsetRect(
float horizOffset,
float vertOffset)
Changes the receiver so that its x-coordinate
is moved by horizOffset and its y-coordinate
is moved by vertOffset. Both arguments
can be negative values.See Also: insetRect
public void setHeight(float newHeight)
Sets the width of the receiver to newHeight. Throws an
IllegalArgumentException if newHeight is NaN
(an invalid float value) or is a negative value.See
Also: height, setWidth
public void setOrigin(NSPoint newOrigin)
Sets the origin point of the receiver to newOrigin.See
Also: origin (NSRect)
public void setSize(NSSize newSize)
Sets the size of the receiver to newSize.See
Also: size (NSRect)
public void setWidth(float newWidth)
Sets the width of the receiver to newWidth. Throws an
IllegalArgumentException if newWidth is
NaN (an invalid float value) or is a negative value.See
Also: setHeight, width
public void setX(float newX)
Sets the x-coordinate of the receiver to newX. Throws an
IllegalArgumentException if newX is
NaN (an invalid float value) or is a negative value.See
Also: setY, x
public void setY(float newY)
Sets the y-coordinate of the receiver to newY. Throws an
IllegalArgumentException if newY is
NaN (an invalid float value) or is a negative value.See
Also: setX, y
public void unionRect(NSRect otherRectangle)
Modifies the receiver to be the union of itself
and otherRectangle. If the receiver
and otherRectangle both have an empty
dimension, it modifies the receiver to be an empty rectangle (all
dimensions) at point {0.0f,0.0f}. If otherRectangle has
an empty dimension, but the receiver doesn't, the receiver is unchanged.See
Also: intersectRect
public float width()
Returns the width of the receiver. NSMutableRect
overrides this method because implementation details make that necessary.See
Also: height
public float x()
Returns the origin x-coordinate of the receiver.
NSMutableRect overrides this method because implementation details
make that necessary.See Also: setX, y
public float y()
Returns the origin y-coordinate of the receiver.
NSMutablePoint overrides this method because implementation details
make that necessary.See Also: x, setY