Class HeadlessRenderer

java.lang.Object
nl.colorize.multimedialib.renderer.headless.HeadlessRenderer
All Implemented Interfaces:
InputDevice, Renderer, Updatable

public class HeadlessRenderer extends Object implements Renderer, InputDevice
Headless renderer implementation intended for testing or simulating on platforms without a graphics environment. The renderer does not actually run an animation loop, frame updates need to be performed manually by calling doFrame(). Graphics and input can be simulated using the methods provided by this class.

Although the headless renderer does not display graphics, it is capable of loading images. See HeadlessMediaLoader for more information.

  • Field Details

  • Constructor Details

    • HeadlessRenderer

      public HeadlessRenderer(DisplayMode displayMode, boolean graphicsEnvironmentEnabled)
    • HeadlessRenderer

      public HeadlessRenderer(Canvas canvas, int framerate)
    • HeadlessRenderer

      public HeadlessRenderer()
  • Method Details

    • start

      public void start(Scene initialScene, ErrorHandler errorHandler)
      Description copied from interface: Renderer
      Initializes this renderer and starts playing the requested scene. Errors that occur during the application will be forwarded to the specified error handler.

      As explained in the class documentation, this is the only method in Renderer that can be safely called from outside the renderer's application loop.

      Specified by:
      start in interface Renderer
    • terminate

      public void terminate()
      Description copied from interface: Renderer
      Ends the animation loop, stops this renderer, and quits the application. Renderer instances cannot be reused, restarting a previously terminated renderer is not possible.
      Specified by:
      terminate in interface Renderer
    • doFrame

      public void doFrame()
    • update

      public void update(float deltaTime)
      Description copied from interface: Updatable
      Updates this object for the current frame. deltaTime indicates the elapsed time since the last frame update, in seconds.
      Specified by:
      update in interface Updatable
    • getPointers

      public Iterable<Pointer> getPointers()
      Description copied from interface: InputDevice
      Returns all currently active pointers. Depending on the current platform and device, pointers could be based on mouse input, a trackpad, or touch controls.

      Note that the type of pointer will also influence its behavior. The mouse pointer is always included in this list, since the mouse cursor is always visible. Touch pointer are only available during the touch, as the pointer disappears once the touch event has ended.

      Specified by:
      getPointers in interface InputDevice
    • clearPointerState

      public void clearPointerState()
      Description copied from interface: InputDevice
      Clears all pointer state for all currently active pointers.
      Specified by:
      clearPointerState in interface InputDevice
    • isKeyPressed

      public boolean isKeyPressed(KeyCode keyCode)
      Description copied from interface: InputDevice
      Returns true if the key with the specified key code was pressed during the current frame.
      Specified by:
      isKeyPressed in interface InputDevice
    • isKeyReleased

      public boolean isKeyReleased(KeyCode keyCode)
      Description copied from interface: InputDevice
      Returns true if the key with the specified key code was released during the current frame.
      Specified by:
      isKeyReleased in interface InputDevice
    • requestTextInput

      public String requestTextInput(String label, String initialValue)
      Description copied from interface: InputDevice
      Shows a dialog window requesting the user to enter text. This method exists only because text fields, unlike other input elements such as buttons, cannot be emulated by the renderer without losing common functionality such as copy/paste. Text input must therefore be delegated to the platform so that a native text field can be used.
      Specified by:
      requestTextInput in interface InputDevice
    • fillClipboard

      public void fillClipboard(String text)
      Description copied from interface: InputDevice
      Copies the specified text to the system clipboard.
      Specified by:
      fillClipboard in interface InputDevice
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getGraphicsMode

      public GraphicsMode getGraphicsMode()
      Specified by:
      getGraphicsMode in interface Renderer
    • getWindowOptions

      public WindowOptions getWindowOptions()
    • getDisplayMode

      public DisplayMode getDisplayMode()
      Specified by:
      getDisplayMode in interface Renderer
    • getGraphics

      public StageVisitor getGraphics()
    • getMediaLoader

      public HeadlessMediaLoader getMediaLoader()
    • getNetwork

      public Network getNetwork()
    • getContext

      public SceneContext getContext()
    • isTouchAvailable

      public boolean isTouchAvailable()
      Specified by:
      isTouchAvailable in interface InputDevice
    • isKeyboardAvailable

      public boolean isKeyboardAvailable()
      Specified by:
      isKeyboardAvailable in interface InputDevice
    • getPointer

      public Point2D getPointer()
    • isPointerPressed

      public boolean isPointerPressed()
    • isPointerReleased

      public boolean isPointerReleased()
    • setGraphicsMode

      public void setGraphicsMode(GraphicsMode graphicsMode)
    • setWindowOptions

      public void setWindowOptions(WindowOptions windowOptions)
    • setDisplayMode

      public void setDisplayMode(DisplayMode displayMode)
    • setGraphics

      public void setGraphics(StageVisitor graphics)
    • setMediaLoader

      public void setMediaLoader(HeadlessMediaLoader mediaLoader)
    • setNetwork

      public void setNetwork(Network network)
    • setContext

      public void setContext(SceneContext context)
    • setTouchAvailable

      public void setTouchAvailable(boolean touchAvailable)
    • setKeyboardAvailable

      public void setKeyboardAvailable(boolean keyboardAvailable)
    • setPointer

      public void setPointer(Point2D pointer)
    • setPointerPressed

      public void setPointerPressed(boolean pointerPressed)
    • setPointerReleased

      public void setPointerReleased(boolean pointerReleased)