-
- All Implemented Interfaces:
-
it.unibo.alchemist.boundary.wormhole.interfaces.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 private doublezoomprivate doublerotationprivate Wormhole2D.Modemode
-
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 doublegetZoom()Gets the zoom factor. voidsetZoom(double zoom)Changes the zoom factor. doublegetRotation()Getter method for the rotation angle, in radians. voidsetRotation(double rad)Wormhole2D.ModegetMode()Gets the rendering mode. voidsetMode(Wormhole2D.Mode mode)Allows child-classes to modify the mode field. PgetEnvPoint(Point viewPoint)Converts a point from the view-space to the env-space. PointgetViewPoint(P envPoint)Converts a point from the env-space to the view-space. PointgetViewPosition()Gets the Position. voidsetViewPosition(Point viewPoint)Sets the Position to viewPoint.Dimension2DgetViewSize()Gets the view's size. booleanisInsideView(Point viewPoint)Check if a point of the view-space is "visible", i.e. voidrotateAroundPoint(Point p, double a)Rotates around a point into the view-space. voidsetEnvPosition(P envPoint)Sets the position to the view-point corresponding to envPoint.voidoptimalZoom()Automatically sets the zoom rate in order to make the environment entirely visible on the view. voidzoomOnPoint(Point point, double zoomRate)Zooms on a point into the view-space. voidcenter()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.
-
getRotation
double getRotation()
Getter method for the rotation angle, in radians.
-
setRotation
void setRotation(double rad)
-
getMode
Wormhole2D.Mode getMode()
Gets the rendering mode.
-
setMode
void setMode(Wormhole2D.Mode mode)
Allows child-classes to modify the mode field.
- Parameters:
mode- is the new 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.
-
-
-
-