java.lang.Objectcomputational.geometry.Point
public class Point
This class represents a point in a 2-dimensional space, specified in integer precision.
Warning: the X-axis is directed left to right, whether the Y-axis is directed top-down, contrary to the usual geometric conventions.
| Constructor Summary | |
|---|---|
Point(int x,
int y)
Constructs a new point with given coordinates. |
|
Point(java.lang.String label,
int x,
int y)
Constructs a new point with given coordinates and label. |
|
| Method Summary | |
|---|---|
static Point |
add(Point p0,
Point p1)
Computes the sum of two points, i.e. |
Rectangle |
boundingBox()
Returns this point's bounding box, represented as a Rectangle centered in the point's coordinates
and with null dimensions. |
java.lang.Object |
clone()
Object Extension |
boolean |
contains(Point p)
Tells whether the shape encloses a given point. |
int |
distance2(Point p)
Returns the squared distance from another point |
void |
draw(java.awt.Graphics gfx)
Draw this point, using the current graphics context's color. |
void |
drawLabels(java.awt.Graphics gfx)
Draws the shape's associated labels, using the graphics context's color. |
void |
drawPoints(java.awt.Graphics gfx)
Draws the shape's defining points, using the graphics context's color. |
boolean |
equals(java.lang.Object obj)
Determines whether or not two points are equal. |
java.lang.String |
getLabel()
Returns the string label associated to this point. |
java.util.List |
getPoints()
Returns a list containing copies of the shape's defining points. |
int |
getX()
Returns the point's X-coordinate. |
int |
getY()
Returns the point's Y-coordinate. |
void |
setLabel(java.lang.String label)
Sets the point's label. |
static Point |
sub(Point p0,
Point p1)
Computes the difference between two points, i.e. |
java.lang.String |
toString()
Returns a string representation of this point. |
void |
translate(int dx,
int dy)
Translates this points by the given amount. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Point(int x,
int y)
x - the point's X-coordinate.y - the point's Y-coordinate.
public Point(java.lang.String label,
int x,
int y)
label - the string label associated to this point.x - the point's X-coordinate.y - the point's Y-coordinate.| Method Detail |
|---|
public static Point add(Point p0,
Point p1)
p0 - the first point.p1 - the second point.
public Rectangle boundingBox()
Rectangle centered in the point's coordinates
and with null dimensions.
Rectangle bounding this point.public java.lang.Object clone()
clone in class java.lang.Objectpublic boolean contains(Point p)
Shape
contains in interface Shapep - the point we test for encloseness.
public int distance2(Point p)
p - the other point.
public void draw(java.awt.Graphics gfx)
draw in interface Shapegfx - the graphics context where this point has to be drawn.public void drawLabels(java.awt.Graphics gfx)
Shape
drawLabels in interface Shapegfx - the graphics context where this shape's labels have
to be drawn.public void drawPoints(java.awt.Graphics gfx)
Shape
drawPoints in interface Shapegfx - the graphics context where this shape's points have
to be drawn.public boolean equals(java.lang.Object obj)
Point are equal if the values of their
x and y member fields, representing
their position in the coordinate space, are the same.
equals in class java.lang.Objectobj - an object to be compared with this Point
true if the object to be compared is
an instance of Point and has
the same values; false otherwise.public java.lang.String getLabel()
null.
getLabel in interface Shapepublic java.util.List getPoints()
Shape
getPoints in interface Shapepublic int getX()
public int getY()
public void setLabel(java.lang.String label)
setLabel in interface Shapethe - point's new label.
public static Point sub(Point p0,
Point p1)
p0 - the first point.p1 - the second point.
public java.lang.String toString()
toString in class java.lang.Object
public void translate(int dx,
int dy)
translate in interface Shapedx - the amount to translate along the X-axisdx - the amount to translate along the Y-axis