Important: The information in this document is obsolete and should not be used for new development.
Inherits from | Object |
Implements |
Cloneable |
Package | com.apple.cocoa.foundation |
Companion guide | Geometry and Range Utilities |
An NSSize object represents a dimension, a specification of width and height. An NSSize, together with an NSPoint, can be used to represent a rectangle (NSRect). The methods of NSSize allow you to access the height and width of an object, to compare and test NSSizes, to convert NSSizes to AWT Dimension objects, and to convert NSSizes to and from string objects.
public NSSize
()
Initializes the instance to a dimensionless NSSize.
public NSSize
(float w, float h)
Initializes the NSSize with the width dimension w and the height dimension y.
Normally, the values of w and h are non-negative. The constructors that create an NSSize do not prevent you from setting a negative value for these attributes. If the value of w or h is negative, however, the behavior of some methods may be undefined.
public NSSize
(NSSize aSize)
Initializes the new NSSize with the width and height values of an existing NSSize, aSize; this constructor is used in cloning the receiver.
public NSSize
(java.awt.Dimension javaDimension)
Initializes the NSSize with the values extracted from an AWT Dimension object, javaDimension.
public static NSSize fromString
(String sizeAsString)
Creates an NSSize from the string sizeAsString, which must be of the form “{w, h}” where w is a float representation of the width and h is a float representation of the height. Throws an IllegalArgumentException
if the string is improperly formatted.
Creates and returns a copy of the receiver.
public Object clone
()
Returns whether otherObject is an NSSize and is equal in width and height to the receiver.
public boolean equals
(Object otherObject)
Provides an appropriate hash code useful for storing the receiver in a hash-based data structure.
public int hashCode
()
This value is the sum of the receiver’s width and height, rounded to the nearest integer.
Returns the height dimension of the receiver.
public float height
()
Returns whether either dimension (width or height) of the receiver is 0.
public boolean isEmpty
()
Returns whether the NSSize aSize is equal in width and height to the receiver.
public boolean isEqualToSize
(NSSize aSize)
Returns the receiver as an AWT Dimension object.
public java.awt.Dimension toAWTDimension
()
The float values of width and height are rounded up to the nearest integers with which the resulting Dimension object can enclose the original size.
Returns the receiver as converted to a string object.
public String toString
()
The string has the form of “{w, h}”, where w is the float representation of width and h is the float representation of height.
Returns the width of the receiver.
public float width
()
NSSize provides the following constant as a convenience; you can use it to compare values returned by some NSSize methods:
Constant |
Description |
---|---|
|
An NSSize set to 0 in both dimensions |
© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)