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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intIsa->b->ca counterclockwise (levorotary) turn?clone()doubledistance(int x, int y) Calculates the distance between this point and the one passed as an argumentdoubleCalculates the distance between this point and the one passed as an argumentvoiddraw(Graphics2D g) Draws the component on the given graphicsbooleaninthashCode()voidmove(int x, int y) Moves this point to the given coordinatestoString()voidtraslate(int x, int y) Traslates this element on X and Yintx()Retrieves the X coordinate of this pointinty()Retrieves the Y coordinate of this point
-
Constructor Details
-
GPoint
Copy constructor- Parameters:
e-GPointto copy- Throws:
IllegalArgumentException- ifeisnull
-
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 newGPointwith 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->ca counterclockwise (levorotary) turn?- Parameters:
a- first pointb- second pointc- third point- Returns:
{-1, 0, +1}ifa->b->cis respectively a clockwise, collinear; counterclockwise turn
-
draw
Description copied from class:GraphicEDraws the component on the given graphics -
traslate
public void traslate(int x, int y) Description copied from class:GraphicETraslates 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
-