|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcore.Coord
public class Coord
Class to hold 2D coordinates and perform simple arithmetics and transformations
| Constructor Summary | |
|---|---|
Coord(double x,
double y)
Constructor. |
|
| Method Summary | |
|---|---|
Coord |
clone()
Returns a clone of this coordinate |
int |
compareTo(Coord other)
Compares this coordinate to other coordinate. |
double |
distance(Coord other)
Returns the distance to another coordinate |
boolean |
equals(Coord c)
Checks if this coordinate's location is equal to other coordinate's |
boolean |
equals(java.lang.Object o)
|
double |
getX()
Returns the x coordinate |
double |
getY()
Returns the y coordinate |
int |
hashCode()
Returns a hash code for this coordinate (actually a hash of the String made of the coordinates) |
void |
setLocation(Coord c)
Sets this coordinate's location to be equal to other coordinates location |
void |
setLocation(double x,
double y)
Sets the location of this coordinate object |
java.lang.String |
toString()
Returns a text representation of the coordinate (rounded to 2 decimals) |
void |
translate(double dx,
double dy)
Moves the point by dx and dy |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Coord(double x,
double y)
x - Initial X-coordinatey - Initial Y-coordinate| Method Detail |
|---|
public void setLocation(double x,
double y)
x - The x coordinate to sety - The y coordinate to setpublic void setLocation(Coord c)
c - The other coordinate
public void translate(double dx,
double dy)
dx - How much to move the point in X-directiondy - How much to move the point in Y-directionpublic double distance(Coord other)
other - The other coordinate
public double getX()
public double getY()
public java.lang.String toString()
toString in class java.lang.Objectpublic Coord clone()
clone in class java.lang.Objectpublic boolean equals(Coord c)
c - The other coordinate
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(Coord other)
compareTo in interface java.lang.Comparable<Coord>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||