PATH
Documentation >
Mac OS X >
Foundation Reference: Java
- Inherits
from:
- Object
- Implements:
- Cloneable
- Package:
- com.apple.yellow.foundation
Class Description
An NSPoint represents a location in a coordinate
system. It has two primary values, an x-coordinate (horizontal)
and a y-coordinate (vertical). The methods of NSPoint give access
to these values, convert between an NSPoint and its string representation,
measure the distance between two NSPoints, and compare two NSPoints
for equality.NSPoint provides the following constant as a convenience;
you can use it to compare values returned by some NSRect methods:
Constant |
Type |
Description |
ZeroPoint |
NSPoint |
An NSPoint with both x and y coordinates set to zero. |
Method Types
- Constructors
- NSPoint
- Accessing coordinate
values
- x
- y
- Converting points
- hashCode
- fromString
- toAWTPoint
- toString
- Finding the distance
between points
- distanceToPoint
- Testing points
- equals
- isEqualToPoint
Constructors
public NSPoint()
Initializes both x and y coordinates to zero.
public NSPoint(
float x,
float y)
Initializes the NSPoint with the horizontal
coordinate x and the vertical coordinate y.
public NSPoint(NSPoint aPoint)
Initializes the new NSPoint with the coordinate
values of existing NSPoint aPoint;
this constructor is used in cloning the receiver.
public NSPoint(java.awt.Point javaPoint)
Initializes the NSPoint with the values extracted
from an AWT Point object.
Static Methods
public static NSPoint fromString(String pointAsString)
Creates an NSPoint from the string pointAsString,
which must be of the form "{x,y}" where x is a float representation
of the x-coordinate and y is a float representation of the y-coordinate. Throws an IllegalArgumentException
if the string is improperly formatted.See
Also: toString
Instance Methods
public Object clone()
Description forthcoming.
public float distanceToPoint(NSPoint aPoint)
Computes and returns the distance between aPoint and
the receiver.
public boolean equals(Object otherObject)
Returns whether otherObject is
an NSPoint and has the same x-coordinate and y-coordinate values as
the receiver.See Also: isEqualToPoint
public int hashCode()
Provide an appropriate hash code useful for
storing the receiver in a hash-based data structure. This value
is the sum of the receiver's x-coordinate and y-coordinate, rounded
to the nearest integer.
public boolean isEqualToPoint(NSPoint aPoint)
Returns whether aPoint has
the same x-coordinate and y-coordinate as the receiver.See
Also: equals
public java.awt.Point toAWTPoint()
Returns the receiver as a AWT Point object.
The float values of the x-coordinate and the y-coordinate are rounded
down to the nearest integer (that is, the point is moved "down"
and to the "left" to the nearest integer).See
Also: toString
public String toString()
Returns the receiver as converted to a string
object in the form of "{x,y}" where x is the float representation
of the x-coordinate value and y is the float representation of the
y-coordinate value.See Also: fromString
public float x()
Returns the x-coordinate of the receiver.
public float y()
Returns the y-coordinate of the receiver.