Class Java2DRenderer
- java.lang.Object
-
- nl.colorize.multimedialib.renderer.AbstractRenderer
-
- nl.colorize.multimedialib.renderer.java2d.Java2DRenderer
-
- All Implemented Interfaces:
Renderer
- Direct Known Subclasses:
HeadlessRenderer
public class Java2DRenderer extends AbstractRenderer
Implementation of a renderer that uses APIs from the Java standard library. Graphics are displayed using Java 2D, AWT is used to create windows and capture keyboard events, and Java Sound is used to play audio.The renderer will use two different threads: the rendering thread is used to update the graphics, while the Swing thread is used to listen for user input.
-
-
Constructor Summary
Constructors Constructor Description Java2DRenderer(Canvas canvas, int framerate, WindowOptions windowOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidblitGraphicsContext(java.awt.image.BufferStrategy windowBuffer)Updates the window graphics with the contents of the buffer.ApplicationDatagetApplicationData(java.lang.String appName)InputDevicegetInputDevice()InternetAccessgetInternetAccess()MediaLoadergetMediaLoader()protected javax.swing.JFrameinitializeWindow(WindowOptions windowOptions)protected voidprepareCanvas()protected java.awt.image.BufferStrategyprepareWindowBuffer()Prepares the window buffer for the current frame.java.lang.StringtakeScreenshot()Takes a screenshots of the renderer's current graphics, and saves it to an image.voidterminate()-
Methods inherited from class nl.colorize.multimedialib.renderer.AbstractRenderer
addRenderCallback, addUpdateCallback, getCanvas, getPlatform, notifyRenderCallbacks, notifyUpdateCallbacks
-
-
-
-
Constructor Detail
-
Java2DRenderer
public Java2DRenderer(Canvas canvas, int framerate, WindowOptions windowOptions)
-
-
Method Detail
-
initializeWindow
protected javax.swing.JFrame initializeWindow(WindowOptions windowOptions)
-
prepareCanvas
protected void prepareCanvas()
-
prepareWindowBuffer
protected java.awt.image.BufferStrategy prepareWindowBuffer()
Prepares the window buffer for the current frame. This buffer will be used to display the graphics once the entire frame has been rendered.
-
blitGraphicsContext
protected void blitGraphicsContext(java.awt.image.BufferStrategy windowBuffer)
Updates the window graphics with the contents of the buffer.
-
getInputDevice
public InputDevice getInputDevice()
-
getMediaLoader
public MediaLoader getMediaLoader()
-
getApplicationData
public ApplicationData getApplicationData(java.lang.String appName)
-
getInternetAccess
public InternetAccess getInternetAccess()
-
takeScreenshot
public java.lang.String takeScreenshot()
Description copied from interface:RendererTakes a screenshots of the renderer's current graphics, and saves it to an image. The image is returned as a data URL for a PNG image.
-
terminate
public void terminate()
-
-