Class GUI

java.lang.Object
com.iragui.GUI

public class GUI extends Object
Represents the core GUI manager responsible for rendering, updating, and managing GUIObjects.

A GUI contains a Window, a collection of GUI objects, and manages their rendering order by layers. It also provides utilities for cursor graphics, frame rendering, and logging.

  • Field Details

    • objectsByName

      protected HashMap<String, GUIObject> objectsByName
    • objectsByLayer

      protected TreeMap<Integer, ArrayList<GUIObject>> objectsByLayer
    • logOutput

      public boolean logOutput
      Whether to log debug output to the console.
    • horizontalMouse

      public WrappedBufferedImage horizontalMouse
      Mouse cursor image used for horizontal resizing.
    • verticalMouse

      public WrappedBufferedImage verticalMouse
      Mouse cursor image used for vertical resizing.
    • diagonalLeftMouse

      public WrappedBufferedImage diagonalLeftMouse
      Mouse cursor image used for diagonal (left) resizing.
    • diagonalRightMouse

      public WrappedBufferedImage diagonalRightMouse
      Mouse cursor image used for diagonal (right) resizing.
  • Constructor Details

    • GUI

      public GUI(String name, int sizeX, int sizeY, int displayX, int displayY, boolean resizable, boolean decorated, boolean maximized, boolean exitOnClose, boolean redrawEveryFrame, boolean nearestFilter)
      Constructs a new GUI with the specified window settings.
      Parameters:
      name - the window title
      sizeX - window width in pixels
      sizeY - window height in pixels
      displayX - display scaling width
      displayY - display scaling height
      resizable - whether the window can be resized
      decorated - whether the window should have decorations
      maximized - whether the window should start maximized
      exitOnClose - whether to exit the program on window close
      redrawEveryFrame - whether to continuously redraw frames
      nearestFilter - whether to use nearest-neighbor texture filtering
  • Method Details

    • begin

      public void begin()
      Initializes the GUI system, rendering the first frame and loading default mouse cursors.
    • update

      public void update()
      Updates all GUIObjects in the GUI.

      Determines if a new frame should be shown based on the showFrame and redrawEveryFrame flags.

    • showNextFrame

      public void showNextFrame()
      Forces the next frame to be drawn.
    • canShowFrame

      public boolean canShowFrame()
      Returns:
      whether a frame should currently be drawn
    • removeObject

      public void removeObject(GUIObject o)
      Removes a GUIObject from the GUI, unregistering it from layers and event listeners.
      Parameters:
      o - the object to remove
    • addObject

      public void addObject(GUIObject o)
      Adds a new GUIObject to the GUI, registering it in name maps, layers, and event listeners.
      Parameters:
      o - the object to add
    • confirmLayerUpdate

      public void confirmLayerUpdate(int oldLayer, GUIObject o)
      Moves a GUIObject to a new layer.
      Parameters:
      oldLayer - the object's old layer
      o - the object to update
    • getObjectsByLayer

      public TreeMap<Integer, ArrayList<GUIObject>> getObjectsByLayer()
      Returns:
      the objects grouped by rendering layer
    • render

      public void render()
      Renders the GUI by delegating to the Window. Draws if showFrame or redrawEveryFrame is true.
    • setBackground

      public void setBackground(float r, float g, float b, float a)
      Sets the background color of the Window.
      Parameters:
      r - red component (0–1)
      g - green component (0–1)
      b - blue component (0–1)
      a - alpha component (0–1)
    • getWindow

      public Window getWindow()
      Returns:
      the underlying Window for this GUI
    • getObjectCount

      public int getObjectCount()
      Returns:
      the total number of objects managed by this GUI
    • getObjectsByName

      public HashMap<String, GUIObject> getObjectsByName()
      Returns:
      a map of objects by name
    • println

      public void println(String string)
      Prints a string to console if logOutput is enabled.
      Parameters:
      string - the text to print