Class AWTContext

java.lang.Object
com.jme3.system.AWTContext
All Implemented Interfaces:
JmeContext

public class AWTContext extends Object implements JmeContext
A JMonkey context that is dedicated to AWT component rendering.

This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX)

  • Field Details

    • settings

      protected final AppSettings settings
      The settings.
    • keyInput

      protected final AWTKeyInput keyInput
      The key input.
    • mouseInput

      protected final AWTMouseInput mouseInput
      The mouse input.
    • backgroundContext

      protected JmeContext backgroundContext
      The background context.
  • Constructor Details

    • AWTContext

      public AWTContext()
  • Method Details

    • getHeight

      public int getHeight()
      Returns:
      the current height.
    • setHeight

      public void setHeight(int height)
      Parameters:
      height - the current height.
    • getWidth

      public int getWidth()
      Returns:
      the current width.
    • setWidth

      public void setWidth(int width)
      Parameters:
      width - the current width.
    • createSettings

      protected AppSettings createSettings()
      Returns:
      new settings.
    • createBackgroundContext

      protected JmeContext createBackgroundContext()
      Returns:
      new context/
    • getType

      public JmeContext.Type getType()
      Specified by:
      getType in interface JmeContext
      Returns:
      The type of the context.
    • setSettings

      public void setSettings(AppSettings settings)
      Specified by:
      setSettings in interface JmeContext
      Parameters:
      settings - the display settings to use for the created context. If the context has already been created, then restart() must be called for the changes to be applied.
    • getSystemListener

      public SystemListener getSystemListener()
      Accesses the listener that receives events related to this context.
      Specified by:
      getSystemListener in interface JmeContext
      Returns:
      the pre-existing instance
    • setSystemListener

      public void setSystemListener(SystemListener listener)
      Description copied from interface: JmeContext
      Sets the listener that will receive events relating to context creation, update, and destroy.
      Specified by:
      setSystemListener in interface JmeContext
      Parameters:
      listener - the desired listener
    • getSettings

      public AppSettings getSettings()
      Specified by:
      getSettings in interface JmeContext
      Returns:
      The current display settings. Note that they might be different from the ones set with setDisplaySettings() if the context was restarted or the settings changed internally.
    • getRenderer

      public Renderer getRenderer()
      Specified by:
      getRenderer in interface JmeContext
      Returns:
      The renderer for this context, or null if not created yet.
    • getOpenCLContext

      public Context getOpenCLContext()
      Specified by:
      getOpenCLContext in interface JmeContext
      Returns:
      The OpenCL context if available.
    • getMouseInput

      public AWTMouseInput getMouseInput()
      Specified by:
      getMouseInput in interface JmeContext
      Returns:
      Mouse input implementation. May be null if not available.
    • getKeyInput

      public AWTKeyInput getKeyInput()
      Specified by:
      getKeyInput in interface JmeContext
      Returns:
      Keyboard input implementation. May be null if not available.
    • getJoyInput

      public JoyInput getJoyInput()
      Specified by:
      getJoyInput in interface JmeContext
      Returns:
      Joystick input implementation. May be null if not available.
    • getTouchInput

      public TouchInput getTouchInput()
      Specified by:
      getTouchInput in interface JmeContext
      Returns:
      Touch device input implementation. May be null if not available.
    • getTimer

      public Timer getTimer()
      Specified by:
      getTimer in interface JmeContext
      Returns:
      The timer for this context, or null if not created yet.
    • setTitle

      public void setTitle(String title)
      Description copied from interface: JmeContext
      Sets the title of the display (if available). This does nothing for fullscreen, headless, or canvas contexts.
      Specified by:
      setTitle in interface JmeContext
      Parameters:
      title - The new title of the display.
    • isCreated

      public boolean isCreated()
      Specified by:
      isCreated in interface JmeContext
      Returns:
      True if the context has been created but not yet destroyed.
    • isRenderable

      public boolean isRenderable()
      Specified by:
      isRenderable in interface JmeContext
      Returns:
      True if the context contains a valid render surface, if any of the rendering methods in Renderer are called while this is false, then the result is undefined.
    • setAutoFlushFrames

      public void setAutoFlushFrames(boolean enabled)
      Specified by:
      setAutoFlushFrames in interface JmeContext
      Parameters:
      enabled - If enabled, the context will automatically flush frames to the video card (swap buffers) after an update cycle.
    • create

      public void create(boolean waitFor)
      Description copied from interface: JmeContext
      Creates the context and makes it active.
      Specified by:
      create in interface JmeContext
      Parameters:
      waitFor - If true, will wait until context has initialized.
    • restart

      public void restart()
      Description copied from interface: JmeContext
      Destroys and then re-creates the context. This should be called after the display settings have been changed.
      Specified by:
      restart in interface JmeContext
    • destroy

      public void destroy(boolean waitFor)
      Description copied from interface: JmeContext
      Destroys the context completely, making it inactive.
      Specified by:
      destroy in interface JmeContext
      Parameters:
      waitFor - If true, will wait until the context is destroyed fully.
    • getFramebufferHeight

      public int getFramebufferHeight()
      Returns the height of the framebuffer.
      Specified by:
      getFramebufferHeight in interface JmeContext
      Returns:
      the height (in pixels)
    • getFramebufferWidth

      public int getFramebufferWidth()
      Returns the width of the framebuffer.
      Specified by:
      getFramebufferWidth in interface JmeContext
      Returns:
      the width (in pixels)
    • getWindowXPosition

      public int getWindowXPosition()
      Returns the screen X coordinate of the left edge of the content area.
      Specified by:
      getWindowXPosition in interface JmeContext
      Returns:
      the screen X coordinate
      Throws:
      UnsupportedOperationException
    • getWindowYPosition

      public int getWindowYPosition()
      Returns the screen Y coordinate of the top edge of the content area.
      Specified by:
      getWindowYPosition in interface JmeContext
      Returns:
      the screen Y coordinate
      Throws:
      UnsupportedOperationException