parent
d94ce414ed
commit
479311bfce
@ -1,92 +0,0 @@ |
||||
package environment; |
||||
|
||||
import environment.World; |
||||
import environment.Node; |
||||
|
||||
public class Point{ |
||||
|
||||
|
||||
private World world; |
||||
private int col, row; |
||||
|
||||
/** |
||||
* @Point world |
||||
* @param col |
||||
* @param row |
||||
*/ |
||||
public Point(World world, int col, int row) { |
||||
this.world = world; |
||||
this.col = col; |
||||
this.row = row; |
||||
} |
||||
|
||||
// Backward conversion
|
||||
public Point(World world, Node node) { |
||||
this.world = world; |
||||
this.col = (node.getX() - world.getSquareCornerOffset()) / world.getSquareEdgeLenght(); |
||||
this.row = (node.getY() - world.getSquareCornerOffset()) / world.getSquareEdgeLenght(); |
||||
} |
||||
|
||||
/** |
||||
* @return |
||||
*/ |
||||
public int getCol() { |
||||
return col; |
||||
} |
||||
|
||||
/** |
||||
* @param col |
||||
*/ |
||||
public void setCol(int col) { |
||||
this.col = col; |
||||
} |
||||
|
||||
/** |
||||
* @return |
||||
*/ |
||||
public int getRow() { |
||||
return row; |
||||
} |
||||
|
||||
/** |
||||
* @param row |
||||
*/ |
||||
public void setRow(int row) { |
||||
this.row = row; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @return true x position in pixels on the world map |
||||
*/ |
||||
public int getX() { |
||||
return col * world.getSquareEdgeLenght() + world.getSquareCornerOffset(); |
||||
} |
||||
|
||||
/** |
||||
* @return true y position in pixels on the world map |
||||
*/ |
||||
public int getY() { |
||||
return row * world.getSquareEdgeLenght() + world.getSquareCornerOffset(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) return true; |
||||
if (o == null || getClass() != o.getClass()) return false; |
||||
|
||||
Point point = (Point) o; |
||||
|
||||
if (col != point.col) return false; |
||||
if (row != point.row) return false; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
int result = col; |
||||
result = world.getSquareEdgeLenght() * result + row; |
||||
return result; |
||||
} |
||||
} |
Loading…
Reference in new issue