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_SIZE
    void addHudElement​(Element element)
    add an element to display element is NOT resized
    void clearElements()
    Empty the all element from the graphic engine and from the view
    void clearMap()
    Remove all the current map's elements
    private void fitMapToStage()
    fit the map to the screen, caseSize is calculated to fit exactly, the offset are calculated to center the elements
    void init()
    initialising the graphic engine components
    void removeElement​(Element element)
    remove an element from the graphic engine and from being displayed
    void run()
    Graphic engine loop
    void setMap​(MapLevel mapLevel)
    Set the map to be diplayed, replace the old map
    void setStage​(javafx.stage.Stage stage)  
    void setStageIcon​(javafx.scene.image.Image image)
    set the icon used for the engine's
    private 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

      private java.util.concurrent.ConcurrentLinkedDeque<Element> elements
    • elementSpriteMap

      private java.util.Map<Element,​Sprite> elementSpriteMap
    • caseSize

      private double caseSize
    • offsetX

      private int offsetX
    • offsetY

      private int offsetY
    • mapLevel

      private MapLevel 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
      Specified by:
      init in interface Engine
    • run

      public void run()
      Graphic engine loop
      Specified by:
      run in interface java.lang.Runnable
    • updateElement

      private 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.
      Parameters:
      e - the element to be updated
    • setMap

      public void setMap​(MapLevel mapLevel)
      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

      public void addElement​(Element element)
      add an element to display element is resized according to CASE_SIZE
      Parameters:
      element - element to display
    • removeElement

      public void removeElement​(Element element)
      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

      public void addHudElement​(Element element)
      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)