Class PointAdapter
-
- All Implemented Interfaces:
-
java.io.Serializable
public final class PointAdapter<P extends Position2D<out P>> implements Serializable
Adapts various representations of bidimensional positions.
-
-
Method Summary
Modifier and Type Method Description double
getX()
double
getY()
PointAdapter<P>
diff(PointAdapter<out Object> op)
boolean
equals(Object obj)
int
hashCode()
PointAdapter<P>
sum(PointAdapter<out Object> op)
Point
toPoint()
Point2D
toPoint2D()
P
toPosition(Environment<out Object, P> environment)
String
toString()
static <P extends Position2D<out P>> PointAdapter<P>
from(double x, double y)
Builds a PointAdapter from coordinates. static <P extends Position2D<out P>> PointAdapter<P>
from(Position2D<out Object> p)
Builds a PointAdapter. static <P extends Position2D<out P>> PointAdapter<P>
from(Point2D p)
Builds a PointAdapter. -
-
Method Detail
-
getX
double getX()
- Returns:
x coordinate
-
getY
double getY()
- Returns:
y coordinate
-
diff
PointAdapter<P> diff(PointAdapter<out Object> op)
- Parameters:
op
- the PointAdapter to sum- Returns:
a new PointAdapter obtained by subtracting the passed argument to this PointAdapter
-
hashCode
int hashCode()
-
sum
PointAdapter<P> sum(PointAdapter<out Object> op)
- Parameters:
op
- the PointAdapter to sum- Returns:
a new PointAdapter obtained by summing the passed argument to this PointAdapter
-
toPoint
Point toPoint()
- Returns:
the Point view of this PointAdapter
-
toPoint2D
Point2D toPoint2D()
- Returns:
the Point2D view of this PointAdapter
-
toPosition
P toPosition(Environment<out Object, P> environment)
- Parameters:
environment
- the environment- Returns:
the it.unibo.alchemist.model.Position view of this PointAdapter
-
from
static <P extends Position2D<out P>> PointAdapter<P> from(double x, double y)
Builds a PointAdapter from coordinates.
- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
-
from
static <P extends Position2D<out P>> PointAdapter<P> from(Position2D<out Object> p)
Builds a PointAdapter.
- Parameters:
p
- the it.unibo.alchemist.model.Position- Returns:
-
from
static <P extends Position2D<out P>> PointAdapter<P> from(Point2D p)
Builds a PointAdapter.
- Parameters:
p
- the Point2D- Returns:
-
-
-
-