Class HeadlessRenderer
java.lang.Object
nl.colorize.multimedialib.renderer.headless.HeadlessRenderer
- All Implemented Interfaces:
InputDevice
,Renderer
,Updatable
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 Summary
Modifier and TypeFieldDescriptionstatic final FontFace
static final int
static final int
static final int
-
Constructor Summary
ConstructorDescriptionHeadlessRenderer
(Canvas canvas, int framerate) HeadlessRenderer
(DisplayMode displayMode, boolean graphicsEnvironmentEnabled) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears all pointer state for all currently active pointers.void
doFrame()
void
fillClipboard
(String text) Copies the specified text to the system clipboard.Returns all currently active pointers.boolean
boolean
isKeyPressed
(KeyCode keyCode) Returns true if the key with the specified key code was pressed during the current frame.boolean
isKeyReleased
(KeyCode keyCode) Returns true if the key with the specified key code was released during the current frame.boolean
boolean
boolean
requestTextInput
(String label, String initialValue) Shows a dialog window requesting the user to enter text.void
setContext
(SceneContext context) void
setDisplayMode
(DisplayMode displayMode) void
setGraphics
(StageVisitor graphics) void
setGraphicsMode
(GraphicsMode graphicsMode) void
setKeyboardAvailable
(boolean keyboardAvailable) void
setMediaLoader
(HeadlessMediaLoader mediaLoader) void
setNetwork
(Network network) void
setPointer
(Point2D pointer) void
setPointerPressed
(boolean pointerPressed) void
setPointerReleased
(boolean pointerReleased) void
setTouchAvailable
(boolean touchAvailable) void
setWindowOptions
(WindowOptions windowOptions) void
start
(Scene initialScene, ErrorHandler errorHandler) Initializes this renderer and starts playing the requested scene.void
Ends the animation loop, stops this renderer, and quits the application.toString()
void
update
(float deltaTime) Updates this object for the current frame.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.colorize.multimedialib.renderer.InputDevice
isPointerPressed, isPointerReleased
-
Field Details
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTH- See Also:
-
DEFAULT_HEIGHT
public static final int DEFAULT_HEIGHT- See Also:
-
DEFAULT_FRAMERATE
public static final int DEFAULT_FRAMERATE- See Also:
-
DEFAULT_FONT
-
-
Constructor Details
-
HeadlessRenderer
-
HeadlessRenderer
-
HeadlessRenderer
public HeadlessRenderer()
-
-
Method Details
-
start
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. -
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. -
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. -
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 interfaceInputDevice
-
clearPointerState
public void clearPointerState()Description copied from interface:InputDevice
Clears all pointer state for all currently active pointers.- Specified by:
clearPointerState
in interfaceInputDevice
-
isKeyPressed
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 interfaceInputDevice
-
isKeyReleased
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 interfaceInputDevice
-
requestTextInput
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 interfaceInputDevice
-
fillClipboard
Description copied from interface:InputDevice
Copies the specified text to the system clipboard.- Specified by:
fillClipboard
in interfaceInputDevice
-
toString
-
getGraphicsMode
- Specified by:
getGraphicsMode
in interfaceRenderer
-
getWindowOptions
-
getDisplayMode
- Specified by:
getDisplayMode
in interfaceRenderer
-
getGraphics
-
getMediaLoader
-
getNetwork
-
getContext
-
isTouchAvailable
public boolean isTouchAvailable()- Specified by:
isTouchAvailable
in interfaceInputDevice
-
isKeyboardAvailable
public boolean isKeyboardAvailable()- Specified by:
isKeyboardAvailable
in interfaceInputDevice
-
getPointer
-
isPointerPressed
public boolean isPointerPressed() -
isPointerReleased
public boolean isPointerReleased() -
setGraphicsMode
-
setWindowOptions
-
setDisplayMode
-
setGraphics
-
setMediaLoader
-
setNetwork
-
setContext
-
setTouchAvailable
public void setTouchAvailable(boolean touchAvailable) -
setKeyboardAvailable
public void setKeyboardAvailable(boolean keyboardAvailable) -
setPointer
-
setPointerPressed
public void setPointerPressed(boolean pointerPressed) -
setPointerReleased
public void setPointerReleased(boolean pointerReleased)
-