Package com.dkt.graphics.elements
Class GPoint
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.GPoint
- All Implemented Interfaces:
Cloneable
This class represents a mutable point
- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Isa->b->c
a counterclockwise (levorotary) turn?clone()
double
distance
(int x, int y) Calculates the distance between this point and the one passed as an argumentdouble
Calculates the distance between this point and the one passed as an argumentvoid
draw
(Graphics2D g) Draws the component on the given graphicsboolean
int
hashCode()
void
move
(int x, int y) Moves this point to the given coordinatestoString()
void
traslate
(int x, int y) Traslates this element on X and Yint
x()
Retrieves the X coordinate of this pointint
y()
Retrieves the Y coordinate of this point
-
Constructor Details
-
GPoint
Copy constructor- Parameters:
e
-GPoint
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
GPoint
public GPoint(int x, int y) Creates a newGPoint
- Parameters:
x
- The x coordinate of the pointy
- The y coordinate of the point
-
GPoint
public GPoint(int x, int y, int cs) Creates a newGPoint
with a given cross size- Parameters:
x
- The x coordinate of the pointy
- The y coordinate of the pointcs
- Cross size
-
-
Method Details
-
x
public int x()Retrieves the X coordinate of this point- Returns:
- x coordinate
-
y
public int y()Retrieves the Y coordinate of this point- Returns:
- y coordinate
-
distance
Calculates the distance between this point and the one passed as an argument- Parameters:
p
- the reference point- Returns:
- distance between points
- Throws:
IllegalArgumentException
- if point isnull
-
distance
public double distance(int x, int y) Calculates the distance between this point and the one passed as an argument- Parameters:
x
- the X coordinate of the pointy
- the Y coordinate of the point- Returns:
- distance between points
-
ccw
Isa->b->c
a counterclockwise (levorotary) turn?- Parameters:
a
- first pointb
- second pointc
- third point- Returns:
{-1, 0, +1}
ifa->b->c
is respectively a clockwise, collinear; counterclockwise turn
-
draw
Description copied from class:GraphicE
Draws the component on the given graphics -
traslate
public void traslate(int x, int y) Description copied from class:GraphicE
Traslates this element on X and Y -
move
public void move(int x, int y) Moves this point to the given coordinates- Parameters:
x
- new x coordinatey
- new y coordinate
-
toString
-
clone
-
hashCode
public int hashCode() -
equals
-