Important: The information in this document is obsolete and should not be used for new development.
Inherits from | NSRect : Object |
Package | com.apple.cocoa.foundation |
Companion guide | Geometry and Range Utilities |
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. NSMutableRects are also useful for performance reasons; instead of creating multiple NSRects in a loop, you can create just one NSMutablePoint and reuse it.
public NSMutableRect
()
Initializes an empty mutable rectangle (that is, a rectangle with at least one dimension of 0).
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 0, it initializes an empty rectangle.
public NSMutableRect
(NSPoint aPoint, NSSize aSize)
Initializes an NSMutableRect from an NSPoint object, aPoint, and an NSSize object, aSize.
public NSMutableRect
(NSPoint pointOne, NSPoint pointTwo)
Initializes an NSMutableRect from two NSPoint objects, pointOne and pointTwo. Creates the smallest rectangle containing the two points.
public NSMutableRect
(java.awt.Rectangle javaRectangle)
Initializes an NSMutableRect from an AWT Rectangle object, javaRectangle.
public NSMutableRect
(NSRect aRectangle)
Initializes an NSMutableRect from an NSRect object, aRectangle; this constructor is used in cloning the receiver.
Creates and returns a copy of the receiver.
public Object clone
()
Returns the height dimension of the receiver.
public float height
()
NSMutableRect overrides this method because implementation details make overriding necessary.
Modifies the receiver to be inset from both upper and lower edges by vertDistance and from both left and right edges by horizDistance.
public void insetRect
(float vertDistance, float horizDistance)
The values vertDistance and horizDistance can be negative. An IllegalArgumentException
is thrown if the resulting width or height would be negative.
Modifies the receiver to be the intersection of itself and otherRectangle.
public void intersectRect
(NSRect 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}.
Changes the receiver so that its origin and size are rounded to the nearest integer, ensuring that the receiver completely contains the original rectangle.
public void makeIntegral
()
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}.
Changes the receiver so that its x coordinate is moved by horizOffset and its y coordinate is moved by vertOffset.
public void offsetRect
(float horizOffset, float vertOffset)
Both arguments can be negative values.
Sets the width of the receiver to newHeight.
public void setHeight
(float newHeight)
Throws an IllegalArgumentException
if newHeight is NaN (an invalid float value) or is a negative value.
Sets the origin point of the receiver to newOrigin.
public void setOrigin
(NSPoint newOrigin)
origin
(NSRect)Sets the size of the receiver to newSize.
public void setSize
(NSSize newSize)
size
(NSRect)Sets the width of the receiver to newWidth.
public void setWidth
(float newWidth)
Throws an IllegalArgumentException
if newWidth is NaN (an invalid float value) or is a negative value.
Sets the x-coordinate of the receiver to newX.
public void setX
(float newX)
Throws an IllegalArgumentException
if newX is NaN (an invalid float value) or is a negative value.
Sets the y-coordinate of the receiver to newY.
public void setY
(float newY)
Throws an IllegalArgumentException
if newY is NaN (an invalid float value) or is a negative value.
Modifies the receiver to be the union of itself and otherRectangle.
public void unionRect
(NSRect 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.
Returns the width of the receiver.
public float width
()
NSMutableRect overrides this method because implementation details make overriding necessary.
Returns the origin x coordinate of the receiver.
public float x
()
NSMutableRect overrides this method because implementation details make overriding necessary.
Returns the origin y coordinate of the receiver.
public float y
()
NSMutablePoint overrides this method because implementation details make overriding necessary.
© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)