view
Class MyPoint2D

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by view.MyPoint2D
All Implemented Interfaces:
Serializable, Cloneable

public class MyPoint2D
extends Point2D
implements Serializable

An extension to point allowing construction with a comma-separated string.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
 
Field Summary
 double x
          The x coordinate in double precision.
 double y
          The y coordinate in double precision.
 
Constructor Summary
MyPoint2D(double x, double y)
          Constructs a enw point from x and y in double precision.
MyPoint2D(Point2D source)
          Constructs a new point from a point.
MyPoint2D(String desc)
          Constrcuts a new point from a comma-separated string.
 
Method Summary
 double getX()
          Returns x.
 double getY()
          Returns y.
static Point2D parsePoint(String desc)
          Parses a point from a String.
 void setLocation(double newx, double newy)
          Sets a new location for this point.
 String toString()
          Overrides the string representation.
static String toString(Point2D p)
          Overrides the string representation.
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
The x coordinate in double precision.


y

public double y
The y coordinate in double precision.

Constructor Detail

MyPoint2D

public MyPoint2D(String desc)
Constrcuts a new point from a comma-separated string. If the string cannot be parsed an IllegalArgumentException is thrown.


MyPoint2D

public MyPoint2D(Point2D source)
Constructs a new point from a point.


MyPoint2D

public MyPoint2D(double x,
                 double y)
Constructs a enw point from x and y in double precision.

Method Detail

getX

public double getX()
Returns x.

Specified by:
getX in class Point2D

getY

public double getY()
Returns y.

Specified by:
getY in class Point2D

setLocation

public void setLocation(double newx,
                        double newy)
Sets a new location for this point.

Specified by:
setLocation in class Point2D

parsePoint

public static Point2D parsePoint(String desc)
Parses a point from a String. Throws an IllegalArgumentException if parsing fails.


toString

public static String toString(Point2D p)
Overrides the string representation. Here, output is reduced to a simple two-integer string, separated by a comma. The output string is feasable for direct-passing it to the constructor of this class. The static version also works with the original Point class.


toString

public String toString()
Overrides the string representation. Here, output is reduced to a simple two-integer string, separated by a comma. The output string is feasable for direct-passing it to the constructor of this class.

Overrides:
toString in class Object