com.yospace.yae.yogi
Class Point

java.lang.Object
  |
  +--com.yospace.yae.yogi.Point

public class Point
extends java.lang.Object

A point representing a location in (x, y) coordinate space, specified in integer precision.


Field Summary
 int x
          The x coordinate.
 int y
          The y coordinate.
 
Constructor Summary
Point()
          Constructs a default Point with the location (0,0).
Point(int x, int y)
          Constructs a new Point at the specified coordinates (x,y).
Point(Point p)
          Constructs a Point with the same location as the specified Point p.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determines whether two points are equal.
 void move(int x, int y)
          Move this Point to the specified coordinates.
static Point parsePoint(java.lang.String s)
          Parses a String representation of a Point object.
 java.lang.String toString()
          Returns a string representation of this point and its location in the (x, y) coordinate space.
 void translate(int x, int y)
          Translate this Point by the specified values.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x
The x coordinate.

y

public int y
The y coordinate.
Constructor Detail

Point

public Point()
Constructs a default Point with the location (0,0).

Point

public Point(Point p)
Constructs a Point with the same location as the specified Point p.
Parameters:
p - the Point to initialize the new Point with.

Point

public Point(int x,
             int y)
Constructs a new Point at the specified coordinates (x,y).
Parameters:
x - the x coordinate.
y - the y coordinate.
Method Detail

move

public void move(int x,
                 int y)
Move this Point to the specified coordinates.
Parameters:
x - the new x coordinate.
y - the new y coordinate.

translate

public void translate(int x,
                      int y)
Translate this Point by the specified values.
Parameters:
x - the amount to translate the x coordinate of the Point.
y - the amount to translate the y coordinate of the Point.

equals

public boolean equals(java.lang.Object obj)
Determines whether two points are equal. Two instances of Point are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with.
Returns:
true if obj is a Point and has the same coordinates as this Point, false otherwise.

toString

public java.lang.String toString()
Returns a string representation of this point and its location in the (x, y) coordinate space. The String is the x and y coordinates separated by a comma.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this object.

parsePoint

public static Point parsePoint(java.lang.String s)
Parses a String representation of a Point object. A valid string is a comma-separated pair of values representing the x and y elements of the object. E.G. "4,6".
Parameters:
s - the String to parse.
Returns:
the Point represented by the String s, or null if the String is invalid.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.