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 doublecaseSizeprivate java.util.concurrent.ConcurrentLinkedDeque<Element>elementsprivate java.util.Map<Element,Sprite>elementSpriteMapprivate doubleheightMarginprivate booleaninitializedprivate MapLevelmapLevelprivate intoffsetXprivate intoffsetYprivate javafx.scene.layout.Panerootprivate javafx.scene.Scenesceneprivate javafx.stage.Stagestageprivate booleanstartedprivate doublewidthMargin -
Constructor Summary
Constructors Constructor Description GraphicsEngine()Constructor to instantiate the engine but not initialising its components -
Method Summary
Modifier and Type Method Description voidaddElement(Element element)add an element to display element is resized according to CASE_SIZEvoidaddHudElement(Element element)add an element to display element is NOT resizedvoidclearElements()Empty the all element from the graphic engine and from the viewvoidclearMap()Remove all the current map's elementsprivate voidfitMapToStage()fit the map to the screen, caseSize is calculated to fit exactly, the offset are calculated to center the elementsvoidinit()initialising the graphic engine componentsvoidremoveElement(Element element)remove an element from the graphic engine and from being displayedvoidrun()Graphic engine loopvoidsetMap(MapLevel mapLevel)Set the map to be diplayed, replace the old mapvoidsetStage(javafx.stage.Stage stage)voidsetStageIcon(javafx.scene.image.Image image)set the icon used for the engine'sprivate voidupdateElement(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:
runin 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)
-