Class AbstractWormhole2D
-
- All Implemented Interfaces:
-
it.unibo.alchemist.boundary.ui.api.Wormhole2D
public abstract class AbstractWormhole2D<P extends Position2D<out P>> implements Wormhole2D<P>
Partial, abstract, implementation for the interface Wormhole2D. This implementation considers the particular case of the view as an entity into the sceern-space: the y-axis grows on the bottom side of the screen. This abstract class is independent from the 2D graphical component wrapped.
-
-
Field Summary
Fields Modifier and Type Field Description public double
zoom
protected double
rotation
public Wormhole2D.Mode
mode
-
Constructor Summary
Constructors Constructor Description AbstractWormhole2D(Environment<out Object, P> environment, T view, Function<T, PointAdapter<P>> viewTypeToPointAdapter)
Wormhole constructor for any ViewPort.
-
Method Summary
Modifier and Type Method Description double
getZoom()
Gets the zoom factor. void
setZoom(double zoom)
Changes the zoom factor. void
setRotation(double rad)
Wormhole2D.Mode
getMode()
Gets the rendering mode. P
getEnvPoint(Point viewPoint)
Converts a point from the view-space to the env-space. Point
getViewPoint(P envPoint)
Converts a point from the env-space to the view-space. Point
getViewPosition()
Gets the Position. void
setViewPosition(Point viewPoint)
Sets the Position to viewPoint
.Dimension2D
getViewSize()
Gets the view's size. boolean
isInsideView(Point viewPoint)
Check if a point of the view-space is "visible", i.e. void
rotateAroundPoint(Point p, double a)
Rotates around a point into the view-space. void
setEnvPosition(P envPoint)
Sets the position to the view-point corresponding to envPoint
.void
optimalZoom()
Automatically sets the zoom rate in order to make the environment entirely visible on the view. void
zoomOnPoint(Point point, double zoomRate)
Zooms on a point into the view-space. void
center()
Points the center of the view on the center of the environment. -
-
Constructor Detail
-
AbstractWormhole2D
AbstractWormhole2D(Environment<out Object, P> environment, T view, Function<T, PointAdapter<P>> viewTypeToPointAdapter)
Wormhole constructor for any ViewPort.- Parameters:
environment
- the Environmentview
- the ViewPort of the UI used for implementing the wormhole.viewTypeToPointAdapter
- a Function used to create the initial position of the wormhole.
-
-
Method Detail
-
getZoom
double getZoom()
Gets the zoom factor.
-
setZoom
void setZoom(double zoom)
Changes the zoom factor.
-
setRotation
void setRotation(double rad)
-
getMode
Wormhole2D.Mode getMode()
Gets the rendering mode.
-
getEnvPoint
P getEnvPoint(Point viewPoint)
Converts a point from the view-space to the env-space.
-
getViewPoint
Point getViewPoint(P envPoint)
Converts a point from the env-space to the view-space.
-
getViewPosition
Point getViewPosition()
Gets the Position.
-
setViewPosition
void setViewPosition(Point viewPoint)
Sets the Position to
viewPoint
.
-
getViewSize
Dimension2D getViewSize()
Gets the view's size.
-
isInsideView
boolean isInsideView(Point viewPoint)
Check if a point of the view-space is "visible", i.e. it is inside the view.
-
rotateAroundPoint
void rotateAroundPoint(Point p, double a)
Rotates around a point into the view-space.
-
setEnvPosition
void setEnvPosition(P envPoint)
Sets the position to the view-point corresponding to
envPoint
.
-
optimalZoom
void optimalZoom()
Automatically sets the zoom rate in order to make the environment entirely visible on the view.
-
zoomOnPoint
void zoomOnPoint(Point point, double zoomRate)
Zooms on a point into the view-space.
-
center
void center()
Points the center of the view on the center of the environment.
-
-
-
-