PATH
Documentation >
Mac OS X >
Foundation Reference: Java
- Inherits
from:
- Object
- Implements:
- Cloneable
- Package:
- com.apple.yellow.foundation
Class Description
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 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.
NSSize provides the following constant as a convenience; you
can use it to compare values returned by some NSSize methods:
Constant |
Type |
Description |
ZeroSize |
NSSize |
An NSSize set to zero in both dimensions. |
Method Types
- Constructors
- NSSize
- Accessing dimensions
- height
- width
- Testing NSSizes
- equals
- hashCode
- isEmpty
- isEqualToSize
- Transforming NSSizes
- toAWTDimension
- toString
- fromString
Constructors
public NSSize()
Initializes the instance to a dimension-less
NSSize.
public NSSize(
float w,
float h)
Initializes the NSSize with the width dimension w and
the height dimension y; throws an IllegalArgumentException
if either value is negative.
public NSSize(NSSize aSize)
Initializes the new NSSize with the width and
height values of an existing NSSize; 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.
Static Methods
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.See Also: toString
Instance Methods
public Object clone()
Description forthcoming.
public boolean equals(Object otherObject)
Returns whether otherObject is
an NSSize and is equal in width and height to the receiver.See
Also: isEqualToSize
public int hashCode()
Provides an appropriate hash code useful for
storing the receiver in a hash-based data structure. This value
is the sum of the receiver's width and height, rounded to the
nearest integer.
public float height()
Returns the height dimension of the receiver.See
Also: width
public boolean isEmpty()
Returns whether either dimension (width or height)
of the receiver is zero.
public boolean isEqualToSize(NSSize aSize)
Returns whether the NSSize aSize is
equal in width and height to the receiver.See
Also: equals
public java.awt.Dimension toAWTDimension()
Returns the receiver as a AWT Dimension object.
The float values of width and height are rounded up to the nearest
integers with which the resulting Dimension can enclose the original
size.See Also: toString
public String toString()
Returns the receiver as converted to a string
object in the form of "{w,h}"
where w is the float representation
of width and h is the float representation
of height.See Also: fromString
public float width()
Returns the width of the receiver.See
Also: height