|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--y.geom.YPoint
This class represents a point in the plane with double coordinates. This class implements the immutable design pattern.
Field Summary | |
static YPoint |
ORIGIN
A YPoint constant with coordinates (0,0). |
double |
x
The x coordinate of the point. |
double |
y
The y coordinate of the point. |
Constructor Summary | |
YPoint()
Creates a new YPoint at location (0,0) |
|
YPoint(double x,
double y)
Creates a new YPoint object for a given position. |
Method Summary | |
static YPoint |
add(YPoint p1,
YPoint p2)
Adds two points and return the result. |
int |
compareTo(Object o)
Comparable implementation. |
static double |
distance(double x1,
double y1,
double x2,
double y2)
Returns the euclidean distance between two points. |
static double |
distance(YPoint p1,
YPoint p2)
Returns the euclidean distance between two points. |
boolean |
equals(Object o)
Tests a point to equality to another point. |
double |
getX()
Returns the x-coordinate of the point object. |
double |
getY()
Returns the y-coordinate of the point object. |
int |
hashCode()
|
static YPoint |
midPoint(YPoint p1,
YPoint p2)
Returns a point that geometrically lies in in the middel of the line formed by the given points. |
YPoint |
moveBy(double x,
double y)
Returns the point, got by moving this point to another position. |
static YPoint |
swap(YPoint p)
Returns a copy of the given point with exchanged x- and y-coordinates. |
String |
toString()
Returns the coordinates of the point as string. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public final double x
public final double y
public static final YPoint ORIGIN
Constructor Detail |
public YPoint()
public YPoint(double x, double y)
x
- the x coordinate of the point.y
- the y coordinate of the point.Method Detail |
public final double getX()
public final double getY()
public static double distance(YPoint p1, YPoint p2)
p1
- an arbitrary pointp2
- an arbitrary point
public static double distance(double x1, double y1, double x2, double y2)
x1
- x-coord of first pointy1
- y-coord of first pointx2
- x-coord of second pointy2
- y-coord of second point
public static YPoint add(YPoint p1, YPoint p2)
p1
- an arbitrary instance of YPoint.p2
- an arbitrary instance of YPoint.public static YPoint midPoint(YPoint p1, YPoint p2)
p1
- an arbitrary instance of YPoint.p2
- an arbitrary instance of YPoint.public static YPoint swap(YPoint p)
p
- an arbitrary instance of YPoint.public YPoint moveBy(double x, double y)
x
- the value which is added on the x-coordinate of the point.y
- the value which is added on the y-coordinate of the point.
public boolean equals(Object o)
o
is also an instance of
YPoint and has the same coordinates as the instance on which equals is
invoked.
equals
in class Object
o
- an arbitrary instance.public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public int compareTo(Object o)
compareTo
in interface Comparable
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |