Class 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 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.
      • getApplicationData

        public ApplicationData getApplicationData​(java.lang.String appName)
      • takeScreenshot

        public java.lang.String takeScreenshot()
        Description copied from interface: Renderer
        Takes 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()