Class AbstractViewport
- java.lang.Object
-
- jadex.extension.envsupport.observer.graphics.AbstractViewport
-
- All Implemented Interfaces:
IViewport
- Direct Known Subclasses:
ViewportJ2D
public abstract class AbstractViewport extends java.lang.Object implements IViewport
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractViewport.MouseController
-
Field Summary
Fields Modifier and Type Field Description protected Vector2Double
areaSize_
Maximum displayable areaprotected java.awt.Color
bgColor_
The background color.protected java.awt.Canvas
canvas_
Canvas for graphical output.protected java.util.Set
drawObjects_
Known drawable Objects.protected IVector2
inversionFlag_
Axis inversion flagprotected java.util.SortedSet
objectLayers_
Registered object layers.protected java.util.List
objectList_
List of objects that should be drawn.protected float
objShiftX_
Object shift x-coordinate.protected float
objShiftY_
Object shift y-coordinate.protected Vector2Double
paddedSize_
Real size of the viewport including padding.protected IPerspective
perspective
IPropertyObject holding properties for layers.protected IVector2
pixPosition_
Pixel-corrected viewport position.protected IVector2
position_
Virtual Viewport position.protected Layer[]
postLayers_
Layers applied after drawable renderingprotected Layer[]
preLayers_
Layers applied before drawable renderingprotected boolean
preserveAR_
Flag aspect ratio preservation.protected boolean
rendering
Flag to indicate that rendering is in progress.protected Vector2Double
size_
Size of the viewport without padding.protected ISpaceController
spacecontroller
The Space Controller
-
Constructor Summary
Constructors Constructor Description AbstractViewport(IPerspective perspective)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addViewportListener(IViewportListener listener)
Adds a IViewportListenerIVector2
getAreaSize()
Gets the maximum displayable size.java.awt.Canvas
getCanvas()
Returns the canvas that is used for displaying the objects.IVector2
getCanvasSize()
Returns the size of the canvas as a vector.java.awt.Rectangle
getClippingBox()
Returns the clipping box.boolean
getInvertX()
Returns true if the x-axis is inverted (right-left instead of left-right).boolean
getInvertY()
Returns true if the y-axis is inverted (top-down instead of bottom-up).IVector2
getObjectShift()
Gets the shift of all objects.IVector2
getPaddedSize()
Returns the padded sizeIPerspective
getPerspective()
Get the perspective.IVector2
getPixelSize()
Returns the size of a pixel.IVector2
getPosition()
Gets the position of the viewport.IVector2
getSize()
Gets the size of the display area.ISpaceController
getSpaceController()
void
getSpaceController(ISpaceController spacecontroller)
IVector2
getWorldCoordinates(int pixelX, int pixelY)
Converts pixel coordinates into world coordinatesboolean
isShowing()
Checks if this IViewport is showing on screen.void
refreshCanvasSize()
Refreshes the size of the canvas.void
removeViewportListener(IViewportListener listener)
Removes a IViewportListenervoid
setAreaSize(IVector2 areaSize)
Sets the maximum displayable size.void
setBackground(java.awt.Color bgColor)
Sets the background color.void
setInvertX(boolean b)
If set to true, inverts the x-axis (right-left instead of left-right).void
setInvertY(boolean b)
If set to true, inverts the y-axis (top-down instead of bottom-up).void
setObjectList(java.util.List objectList)
Sets the current objects to draw.void
setObjectShift(IVector2 objectShift)
Sets the shift of all objects.void
setPosition(IVector2 pos)
Sets the position of the viewport.void
setPostLayers(Layer[] layers)
Sets the post-layers for the viewport.void
setPreLayers(Layer[] layers)
Sets the pre-layers for the viewport.void
setPreserveAspectRation(boolean preserveAR)
Sets whether the viewport should preserve the aspect ratio of the size by padding.void
setSize(IVector2 size)
Sets the size of the display area.void
setZoomLimit(double zoomlimit)
Sets the maximum zoom.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jadex.extension.envsupport.observer.graphics.IViewport
dispose, drawPrimitive, refresh
-
-
-
-
Field Detail
-
spacecontroller
protected ISpaceController spacecontroller
The Space Controller
-
inversionFlag_
protected IVector2 inversionFlag_
Axis inversion flag
-
canvas_
protected java.awt.Canvas canvas_
Canvas for graphical output.
-
bgColor_
protected java.awt.Color bgColor_
The background color.
-
position_
protected IVector2 position_
Virtual Viewport position.
-
pixPosition_
protected IVector2 pixPosition_
Pixel-corrected viewport position.
-
objShiftX_
protected float objShiftX_
Object shift x-coordinate.
-
objShiftY_
protected float objShiftY_
Object shift y-coordinate.
-
preserveAR_
protected boolean preserveAR_
Flag aspect ratio preservation.
-
size_
protected Vector2Double size_
Size of the viewport without padding.
-
areaSize_
protected Vector2Double areaSize_
Maximum displayable area
-
paddedSize_
protected Vector2Double paddedSize_
Real size of the viewport including padding.
-
drawObjects_
protected java.util.Set drawObjects_
Known drawable Objects.
-
objectLayers_
protected java.util.SortedSet objectLayers_
Registered object layers.
-
objectList_
protected java.util.List objectList_
List of objects that should be drawn.
-
preLayers_
protected Layer[] preLayers_
Layers applied before drawable rendering
-
postLayers_
protected Layer[] postLayers_
Layers applied after drawable rendering
-
perspective
protected IPerspective perspective
IPropertyObject holding properties for layers.
-
rendering
protected volatile boolean rendering
Flag to indicate that rendering is in progress.
-
-
Constructor Detail
-
AbstractViewport
public AbstractViewport(IPerspective perspective)
-
-
Method Detail
-
setBackground
public void setBackground(java.awt.Color bgColor)
Sets the background color.- Specified by:
setBackground
in interfaceIViewport
- Parameters:
bgColor
- the background color
-
setObjectList
public void setObjectList(java.util.List objectList)
Sets the current objects to draw.- Specified by:
setObjectList
in interfaceIViewport
- Parameters:
objectList
- objects that should be drawn
-
getCanvas
public java.awt.Canvas getCanvas()
Returns the canvas that is used for displaying the objects.
-
setPreLayers
public void setPreLayers(Layer[] layers)
Sets the pre-layers for the viewport.- Specified by:
setPreLayers
in interfaceIViewport
- Parameters:
layers
- the pre-layers
-
setPostLayers
public void setPostLayers(Layer[] layers)
Sets the post-layers for the viewport.- Specified by:
setPostLayers
in interfaceIViewport
- Parameters:
layers
- the post-layers
-
getSize
public IVector2 getSize()
Gets the size of the display area.
-
setSize
public void setSize(IVector2 size)
Sets the size of the display area.
-
getAreaSize
public IVector2 getAreaSize()
Gets the maximum displayable size.- Specified by:
getAreaSize
in interfaceIViewport
- Returns:
- maximum area size.
-
setAreaSize
public void setAreaSize(IVector2 areaSize)
Sets the maximum displayable size.- Specified by:
setAreaSize
in interfaceIViewport
- Parameters:
areaSize
- maximum area size.
-
getPaddedSize
public IVector2 getPaddedSize()
Returns the padded size- Returns:
- padded size
-
getClippingBox
public java.awt.Rectangle getClippingBox()
Returns the clipping box.- Returns:
- clipping box
-
getPixelSize
public IVector2 getPixelSize()
Returns the size of a pixel.
-
getCanvasSize
public IVector2 getCanvasSize()
Returns the size of the canvas as a vector.- Returns:
- size of the canvas in pixel
-
refreshCanvasSize
public void refreshCanvasSize()
Refreshes the size of the canvas.- Specified by:
refreshCanvasSize
in interfaceIViewport
-
getPosition
public IVector2 getPosition()
Gets the position of the viewport.- Specified by:
getPosition
in interfaceIViewport
-
setPosition
public void setPosition(IVector2 pos)
Sets the position of the viewport.- Specified by:
setPosition
in interfaceIViewport
-
setPreserveAspectRation
public void setPreserveAspectRation(boolean preserveAR)
Description copied from interface:IViewport
Sets whether the viewport should preserve the aspect ratio of the size by padding.- Specified by:
setPreserveAspectRation
in interfaceIViewport
- Parameters:
preserveAR
- true to preserve aspect ratio, false otherwise
-
getInvertX
public boolean getInvertX()
Returns true if the x-axis is inverted (right-left instead of left-right).- Specified by:
getInvertX
in interfaceIViewport
- Returns:
- true, if the x-axis is inverted
-
getInvertY
public boolean getInvertY()
Returns true if the y-axis is inverted (top-down instead of bottom-up).- Specified by:
getInvertY
in interfaceIViewport
- Returns:
- true, if the y-axis is inverted
-
setInvertX
public void setInvertX(boolean b)
If set to true, inverts the x-axis (right-left instead of left-right).- Specified by:
setInvertX
in interfaceIViewport
- Parameters:
b
- if true, inverts the x-axis
-
setInvertY
public void setInvertY(boolean b)
If set to true, inverts the y-axis (top-down instead of bottom-up).- Specified by:
setInvertY
in interfaceIViewport
- Parameters:
b
- if true, inverts the y-axis
-
getObjectShift
public IVector2 getObjectShift()
Gets the shift of all objects.
-
setObjectShift
public void setObjectShift(IVector2 objectShift)
Sets the shift of all objects.- Specified by:
setObjectShift
in interfaceIViewport
-
setZoomLimit
public void setZoomLimit(double zoomlimit)
Sets the maximum zoom.- Specified by:
setZoomLimit
in interfaceIViewport
- Parameters:
zoomlimit
- the zoom limit
-
isShowing
public boolean isShowing()
Checks if this IViewport is showing on screen.
-
addViewportListener
public void addViewportListener(IViewportListener listener)
Adds a IViewportListener- Specified by:
addViewportListener
in interfaceIViewport
- Parameters:
listener
- new listener
-
removeViewportListener
public void removeViewportListener(IViewportListener listener)
Removes a IViewportListener- Specified by:
removeViewportListener
in interfaceIViewport
- Parameters:
listener
- the listener
-
getPerspective
public IPerspective getPerspective()
Get the perspective.- Specified by:
getPerspective
in interfaceIViewport
- Returns:
- The perspective.
-
getWorldCoordinates
public IVector2 getWorldCoordinates(int pixelX, int pixelY)
Converts pixel coordinates into world coordinates- Specified by:
getWorldCoordinates
in interfaceIViewport
- Parameters:
pixelX
- pixel x-coordinatepixelY
- pixel y-coordinate- Returns:
- world coordinates
-
getSpaceController
public ISpaceController getSpaceController()
- Specified by:
getSpaceController
in interfaceIViewport
- Returns:
- the spacecontroller
-
getSpaceController
public void getSpaceController(ISpaceController spacecontroller)
-
-