-
- All Implemented Interfaces:
public interface Wormhole2D<P extends Position2D<out P>>A Wormhole (in this context) is an entity that "connects" two worlds: the "environment" and the "view". Above all it provides services to convert coordinates from the "environment-space" to the "view-space".
IWormhole2Dis the type of a wormhole whose both environment and view are bi-dimensional spaces. Terminology: - "Environment" is the 'rectangle' we need to render ON the view. - "View" is a 'window' that let us see the environment. - "Environment-space" is the algebraic space on which 'lies' the environment. - "View-space" is the algebraic space on which 'lies' the view. - "Env" before a point's name => it refers to a point into the environment-space. - "View" before a point's name => it refers to a point into the view-space. - "Position" is the point of the view-space every transformation applied to the environment refers to: e.g. if I want to move the environment, I have to change the position; it is also the point the environment rotates around. - "EnvOffset" is the vector from (0; 0) into env-space to the left-bottom corner of the part of the environment we want to render. E.g. if I am representing a map with Earth-coordinates (16; 48), the intersection between the prime meridian and the equator is (0; 0), so I have to set the envOffset to (16; 48) in order to see the "beginning" of the map on the left-bottom corner of the view.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumWormhole2D.ModeWormhole mode.
-
Method Summary
Modifier and Type Method Description abstract PgetEnvPoint(Point viewPoint)Converts a point from the view-space to the env-space. abstract Wormhole2D.ModegetMode()Gets the rendering mode. abstract PointgetViewPoint(P envPoint)Converts a point from the env-space to the view-space. abstract PointgetViewPosition()Gets the Position. abstract Dimension2DgetViewSize()Gets the view's size. abstract doublegetZoom()Gets the zoom factor. abstract booleanisInsideView(Point viewPoint)Check if a point of the view-space is "visible", i.e. abstract voidrotateAroundPoint(Point p, double a)Rotates around a point into the view-space. abstract voidsetEnvPosition(P envPoint)Sets the position to the view-point corresponding to envPoint.abstract voidoptimalZoom()Automatically sets the zoom rate in order to make the environment entirely visible on the view. abstract voidsetRotation(double rad)Rotates the environment around the Position. abstract voidsetViewPosition(Point viewPoint)Sets the Position to viewPoint.abstract voidsetZoom(double value)Changes the zoom factor. abstract voidzoomOnPoint(Point p, double z)Zooms on a point into the view-space. abstract voidcenter()Points the center of the view on the center of the environment. -
-
Method Detail
-
getEnvPoint
abstract P getEnvPoint(Point viewPoint)
Converts a point from the view-space to the env-space.
- Parameters:
viewPoint- is the Point object whose coordinates are from view-space
-
getMode
abstract Wormhole2D.Mode getMode()
Gets the rendering mode.
-
getViewPoint
abstract Point getViewPoint(P envPoint)
Converts a point from the env-space to the view-space.
- Parameters:
envPoint- is the Position2D object whose coordinates are from env-space
-
getViewPosition
abstract Point getViewPosition()
Gets the Position.
-
getViewSize
abstract Dimension2D getViewSize()
Gets the view's size.
-
getZoom
abstract double getZoom()
Gets the zoom factor.
-
isInsideView
abstract boolean isInsideView(Point viewPoint)
Check if a point of the view-space is "visible", i.e. it is inside the view.
- Parameters:
viewPoint- is the Point to check
-
rotateAroundPoint
abstract void rotateAroundPoint(Point p, double a)
Rotates around a point into the view-space.
- Parameters:
p- is the Pointa- is the absolute angle (in radians)
-
setEnvPosition
abstract void setEnvPosition(P envPoint)
Sets the position to the view-point corresponding to
envPoint.- Parameters:
envPoint- is the Position2D object representing the new position with env-coordinates
-
optimalZoom
abstract void optimalZoom()
Automatically sets the zoom rate in order to make the environment entirely visible on the view.
-
setRotation
abstract void setRotation(double rad)
Rotates the environment around the Position.
- Parameters:
rad- is thedoublevalue representing the angle expressed with radians
-
setViewPosition
abstract void setViewPosition(Point viewPoint)
Sets the Position to
viewPoint.- Parameters:
viewPoint- is the Point object representing the new position with view-coordinates
-
setZoom
abstract void setZoom(double value)
Changes the zoom factor.
- Parameters:
value- is thedoublevalue representing the new zoom
-
zoomOnPoint
abstract void zoomOnPoint(Point p, double z)
Zooms on a point into the view-space.
- Parameters:
p- is the Pointz- is the absolute zoom rate
-
center
abstract void center()
Points the center of the view on the center of the environment.
-
-
-
-