Class JFXRenderer

java.lang.Object
nl.colorize.multimedialib.renderer.jfx.JFXRenderer
All Implemented Interfaces:
Renderer, SceneContext

public class JFXRenderer extends Object implements Renderer, SceneContext
Renderer based on OpenJFX, which was previously known as JavaFX. Note that JavaFX is only used for the animation loop, graphics, and input. Other renderer capabilities are identical to the Java2D renderer, since both are based on the Java standard library.
  • Method Details

    • start

      public void start(RenderConfig config, Scene initialScene)
      Description copied from interface: Renderer
      Starts this renderer based on the specified configuration. The renderer will initially display the specified scene.

      This method can be called from any thread. The renderer will run in its own thread, which is started by calling this method. All callback methods will be called from the renderer thread.

      Specified by:
      start in interface Renderer
    • terminate

      public void terminate()
      Description copied from interface: SceneContext
      Terminates the renderer, which will end the animation loop and quit the application.
      Specified by:
      terminate in interface SceneContext
    • createMesh

      public Mesh createMesh(Shape3D shape, ColorRGB color)
      Description copied from interface: SceneContext
      Programmatically creates a 3D polygon mesh with a solid color, based on the specified shape.
      Specified by:
      createMesh in interface SceneContext
    • project

      public Point2D project(Point3D position)
      Description copied from interface: SceneContext
      Returns the 3D world coordinates that correspond to the specified 2D canvas coordinates, based on the current camera position.
      Specified by:
      project in interface SceneContext
    • castPickRay

      public boolean castPickRay(Point2D canvasPosition, Box area)
      Description copied from interface: SceneContext
      Casts a pick ray from the specified 2D canvas position, and returns true if the pick ray intersects with the specified 3D world coordinates.
      Specified by:
      castPickRay in interface SceneContext
    • takeScreenshot

      public void takeScreenshot(File screenshotFile)
      Description copied from interface: SceneContext
      Captures a screenshot of the renderer's current graphics and then exports the screenshot to a PNG file.
      Specified by:
      takeScreenshot in interface SceneContext
    • getRendererName

      public String getRendererName()
      Description copied from interface: SceneContext
      Returns the display name for the underlying renderer. The display name will not include the word "renderer".
      Specified by:
      getRendererName in interface SceneContext
    • isSupported

      public boolean isSupported(GraphicsMode graphicsMode)
      Specified by:
      isSupported in interface Renderer
    • launch

      public static JFXRenderer launch()
      Launches the JavaFX renderer. Note that JavaFX does not support multiple instances of the renderer to be active simultaneously.
      Throws:
      IllegalStateException - if this method is called at a moment when another JFXRenderer instance is already active.
    • accessInstance

      protected static JFXRenderer accessInstance()
      Returns the single currently active JFXRenderer instance. This method is used to access the renderer from the JavaFX application thread.
      Throws:
      IllegalStateException - when trying to call this method before the renderer has been initialized.
    • getConfig

      public RenderConfig getConfig()
      Specified by:
      getConfig in interface SceneContext
    • getGraphics

      public JFXGraphics getGraphics()
    • getInput

      public JFXInput getInput()
      Specified by:
      getInput in interface SceneContext
    • getMediaLoader

      public JFXMediaLoader getMediaLoader()
      Specified by:
      getMediaLoader in interface SceneContext
    • getNetwork

      public Network getNetwork()
      Specified by:
      getNetwork in interface SceneContext
    • getSceneManager

      public SceneManager getSceneManager()
      Specified by:
      getSceneManager in interface SceneContext
    • getStage

      public Stage getStage()
      Specified by:
      getStage in interface SceneContext
    • getScreenshotQueue

      public List<File> getScreenshotQueue()