Class GraphicsEngine
java.lang.Object
fr.r1r0r0.deltaengine.model.engines.GraphicsEngine
- All Implemented Interfaces:
Engine
,java.lang.Runnable
final class GraphicsEngine extends java.lang.Object implements Engine
Graphic engine takes care of maintaining the view updated
-
Field Summary
Fields Modifier and Type Field Description private double
caseSize
private java.util.concurrent.ConcurrentLinkedDeque<Element>
elements
private java.util.Map<Element,Sprite>
elementSpriteMap
private double
heightMargin
private boolean
initialized
private MapLevel
mapLevel
private int
offsetX
private int
offsetY
private javafx.scene.layout.Pane
root
private javafx.scene.Scene
scene
private javafx.stage.Stage
stage
private boolean
started
private double
widthMargin
-
Constructor Summary
Constructors Constructor Description GraphicsEngine()
Constructor to instantiate the engine but not initialising its components -
Method Summary
Modifier and Type Method Description void
addElement(Element element)
add an element to display element is resized according to CASE_SIZEvoid
addHudElement(Element element)
add an element to display element is NOT resizedvoid
clearElements()
Empty the all element from the graphic engine and from the viewvoid
clearMap()
Remove all the current map's elementsprivate void
fitMapToStage()
fit the map to the screen, caseSize is calculated to fit exactly, the offset are calculated to center the elementsvoid
init()
initialising the graphic engine componentsvoid
removeElement(Element element)
remove an element from the graphic engine and from being displayedvoid
run()
Graphic engine loopvoid
setMap(MapLevel mapLevel)
Set the map to be diplayed, replace the old mapvoid
setStage(javafx.stage.Stage stage)
void
setStageIcon(javafx.scene.image.Image image)
set the icon used for the engine'sprivate void
updateElement(Element e)
Update an element's graphical view if the sprite of the element is a new object, the old sprite is removed and the new one added.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
elements
-
elementSpriteMap
-
caseSize
private double caseSize -
offsetX
private int offsetX -
offsetY
private int offsetY -
mapLevel
-
stage
private javafx.stage.Stage stage -
root
private javafx.scene.layout.Pane root -
scene
private javafx.scene.Scene scene -
initialized
private boolean initialized -
started
private boolean started -
widthMargin
private double widthMargin -
heightMargin
private double heightMargin
-
-
Constructor Details
-
GraphicsEngine
public GraphicsEngine()Constructor to instantiate the engine but not initialising its components
-
-
Method Details
-
init
public void init()initialising the graphic engine components -
run
public void run()Graphic engine loop- Specified by:
run
in interfacejava.lang.Runnable
-
updateElement
Update an element's graphical view if the sprite of the element is a new object, the old sprite is removed and the new one added.- Parameters:
e
- the element to be updated
-
setMap
Set the map to be diplayed, replace the old map- Parameters:
mapLevel
- map to be shown
-
fitMapToStage
private void fitMapToStage()fit the map to the screen, caseSize is calculated to fit exactly, the offset are calculated to center the elements -
addElement
add an element to display element is resized according to CASE_SIZE- Parameters:
element
- element to display
-
removeElement
remove an element from the graphic engine and from being displayed- Parameters:
element
- an element from the graphic engine
-
clearMap
public void clearMap()Remove all the current map's elements -
addHudElement
add an element to display element is NOT resized- Parameters:
element
- element to display
-
clearElements
public void clearElements()Empty the all element from the graphic engine and from the view -
setStageIcon
public void setStageIcon(javafx.scene.image.Image image)set the icon used for the engine's- Parameters:
image
- icon used
-
setStage
public void setStage(javafx.stage.Stage stage)
-