Record Class AppConfig

java.lang.Object
java.lang.Record
cit244.app.AppConfig

public record AppConfig(int viewportW, int viewportH, RenderMode renderMode, int paramsFontSize, int hudFontSize, WindowMode windowMode, int fullscreenDisplay, String title) extends Record
Immutable configuration for the app framework.

This record captures window sizing, rendering mode selection, and UI font sizing. Use defaults() as a baseline, then derive variants with the helper methods like windowed(int, int) or withFontSizes(int, int).

Notes:

  • viewportW/viewportH describe the main drawing viewport (not including any extra HUD region)
  • fullscreenDisplay is only meaningful when windowMode == FULLSCREEN_DISPLAY
  • title may be null or blank to indicate "use the framework default"
  • Constructor Summary

    Constructors
    Constructor
    Description
    AppConfig(int viewportW, int viewportH, RenderMode renderMode, int paramsFontSize, int hudFontSize, WindowMode windowMode, int fullscreenDisplay, String title)
    Canonical constructor with validation and null-defaulting for windowMode.
  • Method Summary

    Modifier and Type
    Method
    Description
    static AppConfig
    Returns the framework default configuration.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns a copy of this config set to fullscreen mode.
    fullscreen(int display1Based)
    Returns a copy of this config set to fullscreen on a specific display.
    int
    Returns the value of the fullscreenDisplay record component.
    Returns a copy of this config set to fullscreen spanning displays (if supported).
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the hudFontSize record component.
    boolean
    Returns true if this configuration uses a fullscreen window mode.
    static AppConfig
    of(int viewportW, int viewportH)
    Convenience factory that returns a WINDOWED config with the given viewport size, based on defaults().
    int
    Returns the value of the paramsFontSize record component.
    Returns the value of the renderMode record component.
    Returns the value of the title record component.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the viewportH record component.
    int
    Returns the value of the viewportW record component.
    windowed(int viewportW, int viewportH)
    Returns a copy of this config set to WINDOWED with the given viewport size.
    Returns the value of the windowMode record component.
    withFontSizes(int paramsSize, int hudSize)
    Returns a copy with both parameter and HUD font sizes updated.
    withHudFontSize(int size)
    Returns a copy with the HUD font size updated.
    Returns a copy with the parameter UI font size updated.
    Returns a copy with the render mode updated.
    Returns a copy with the window title updated.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AppConfig

      public AppConfig(int viewportW, int viewportH, RenderMode renderMode, int paramsFontSize, int hudFontSize, WindowMode windowMode, int fullscreenDisplay, String title)
      Canonical constructor with validation and null-defaulting for windowMode.

      Not intended for direct use. Prefer defaults() or of(int,int).

      Throws:
      IllegalArgumentException - if viewport dimensions or font sizes are non-positive, or if fullscreenDisplay < 1 when using FULLSCREEN_DISPLAY
      NullPointerException - if renderMode is null
  • Method Details

    • of

      public static AppConfig of(int viewportW, int viewportH)
      Convenience factory that returns a WINDOWED config with the given viewport size, based on defaults().
      Parameters:
      viewportW - viewport width in pixels (positive)
      viewportH - viewport height in pixels (positive)
      Returns:
      a windowed AppConfig with the requested viewport dimensions
    • defaults

      public static AppConfig defaults()
      Returns the framework default configuration.
      Returns:
      the default AppConfig
    • isFullscreen

      public boolean isFullscreen()
      Returns true if this configuration uses a fullscreen window mode.
      Returns:
      true for any fullscreen mode, false for WINDOWED
    • windowed

      public AppConfig windowed(int viewportW, int viewportH)
      Returns a copy of this config set to WINDOWED with the given viewport size.
      Parameters:
      viewportW - viewport width in pixels (positive)
      viewportH - viewport height in pixels (positive)
      Returns:
      a new AppConfig in WINDOWED mode
    • fullscreen

      public AppConfig fullscreen()
      Returns a copy of this config set to fullscreen mode.
      Returns:
      a new AppConfig in FULLSCREEN_PREF mode
    • fullscreen

      public AppConfig fullscreen(int display1Based)
      Returns a copy of this config set to fullscreen on a specific display.
      Parameters:
      display1Based - 1-based display index
      Returns:
      a new AppConfig in FULLSCREEN_DISPLAY mode
    • fullscreenSpan

      public AppConfig fullscreenSpan()
      Returns a copy of this config set to fullscreen spanning displays (if supported).

      You probably don't want this unless you have multiple monitors and a beefy computer.

      Returns:
      a new AppConfig in FULLSCREEN_SPAN mode
    • withFontSizes

      public AppConfig withFontSizes(int paramsSize, int hudSize)
      Returns a copy with both parameter and HUD font sizes updated.
      Parameters:
      paramsSize - params UI font size (positive)
      hudSize - HUD font size (positive)
      Returns:
      a new AppConfig with updated font sizes
    • withParamsFontSize

      public AppConfig withParamsFontSize(int size)
      Returns a copy with the parameter UI font size updated.
      Parameters:
      size - params UI font size (positive)
      Returns:
      a new AppConfig with updated params font size
    • withHudFontSize

      public AppConfig withHudFontSize(int size)
      Returns a copy with the HUD font size updated.
      Parameters:
      size - HUD font size (positive)
      Returns:
      a new AppConfig with updated HUD font size
    • withRenderMode

      public AppConfig withRenderMode(RenderMode renderMode)
      Returns a copy with the render mode updated.
      Parameters:
      renderMode - the new render mode (non-null)
      Returns:
      a new AppConfig with updated render mode
    • withTitle

      public AppConfig withTitle(String title)
      Returns a copy with the window title updated.

      Passing null or blank indicates "use the framework default" which is the class name.

      Parameters:
      title - title override (nullable)
      Returns:
      a new AppConfig with updated title
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • viewportW

      public int viewportW()
      Returns the value of the viewportW record component.
      Returns:
      the value of the viewportW record component
    • viewportH

      public int viewportH()
      Returns the value of the viewportH record component.
      Returns:
      the value of the viewportH record component
    • renderMode

      public RenderMode renderMode()
      Returns the value of the renderMode record component.
      Returns:
      the value of the renderMode record component
    • paramsFontSize

      public int paramsFontSize()
      Returns the value of the paramsFontSize record component.
      Returns:
      the value of the paramsFontSize record component
    • hudFontSize

      public int hudFontSize()
      Returns the value of the hudFontSize record component.
      Returns:
      the value of the hudFontSize record component
    • windowMode

      public WindowMode windowMode()
      Returns the value of the windowMode record component.
      Returns:
      the value of the windowMode record component
    • fullscreenDisplay

      public int fullscreenDisplay()
      Returns the value of the fullscreenDisplay record component.
      Returns:
      the value of the fullscreenDisplay record component
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component