Class SettingsController

Object
SettingsController

public class SettingsController extends Object
Controller responsible for tracking ePub specific settings and emulation flags. It centralizes detection of device capabilities inside an ePub reader, exposes the --emulate CLO option used for debugging, and keeps a single running lab when resources are constrained.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    Shared settings describing the current ePub environment.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Button
    Button used to apply or open standalone lab.
    static final String
    Label of button to apply parameter settings.
    static final String
    Label of button to run in standalone mode.
    private final CLOption
    Command line option to mimic ePub modes and to disable device capabilities.
    private final Label
    Label displaying the current command-line options.
    private final Button
    Button used to reset parameters to default values.
    private final Button
    Button used to open help for command-line options.
    private static EvoLudoWeb
    Reference to the currently running lab in ePub mode.
    private static final SettingsController.Settings
    Global settings describing the capabilities of the surrounding ePub environment.
    private final Button
    Button used to open the settings dialog.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SettingsController(Label cloField, Button applyButton, Button defaultButton, Button helpButton, Button settingsButton)
    Creates a new settings controller.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    applyUiToggles(Runnable dropHandlerRegistrar)
    Applies the appropriate UI toggles based on the current ePub mode.
    private void
    Detects the capabilities of the current ePub host and updates the shared settings accordingly.
    Returns the --emulate command-line option.
    boolean
    Reports whether the ePub reader exposes keyboard input.
    boolean
    Reports whether the ePub reader exposes mouse input.
    boolean
    Reports whether the ePub reader exposes touch input.
    boolean
    Reports whether the environment is an ePub reader.
    static boolean
    Reports whether no other ePub lab is currently running, allowing this lab to start execution.
    boolean
    Reports whether the ePub lab runs on a standalone page instead of inline within text flow.
    static void
    Marks the supplied lab as the currently running ePub instance.
    static void
    Clears the running lab marker once execution stops.
    private void
    updateCLOControls(boolean editCLO)
    Updates the command-line option controls to reflect whether editing is allowed.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BUTTON_STANDALONE

      public static final String BUTTON_STANDALONE
      Label of button to run in standalone mode.
      See Also:
    • BUTTON_APPLY

      public static final String BUTTON_APPLY
      Label of button to apply parameter settings.
      See Also:
    • SETTINGS

      private static final SettingsController.Settings SETTINGS
      Global settings describing the capabilities of the surrounding ePub environment.
    • runningLab

      private static EvoLudoWeb runningLab
      Reference to the currently running lab in ePub mode. Only a single lab may run at a time to avoid exhausting reader resources.
    • cloField

      private final Label cloField
      Label displaying the current command-line options.
    • applyButton

      private final Button applyButton
      Button used to apply or open standalone lab.
    • defaultButton

      private final Button defaultButton
      Button used to reset parameters to default values.
    • helpButton

      private final Button helpButton
      Button used to open help for command-line options.
    • settingsButton

      private final Button settingsButton
      Button used to open the settings dialog.
    • cloEmulate

      private final CLOption cloEmulate
      Command line option to mimic ePub modes and to disable device capabilities.

      Note: for development/debugging only; should be disabled in production

  • Constructor Details

    • SettingsController

      public SettingsController(Label cloField, Button applyButton, Button defaultButton, Button helpButton, Button settingsButton)
      Creates a new settings controller.
      Parameters:
      cloField - the command-line option field
      applyButton - the apply button
      defaultButton - the default button
      helpButton - the help button
      settingsButton - the settings button
  • Method Details

    • getCloEmulate

      public CLOption getCloEmulate()
      Returns the --emulate command-line option.
      Returns:
      CLO option controlling the emulation behaviour
    • applyUiToggles

      public boolean applyUiToggles(Runnable dropHandlerRegistrar)
      Applies the appropriate UI toggles based on the current ePub mode. Enables or disables parameter editing widgets and registers drag-and-drop handlers when editing is permitted.
      Parameters:
      dropHandlerRegistrar - callback that installs drag-and-drop handlers
      Returns:
      true if editing is enabled
    • isEPub

      public boolean isEPub()
      Reports whether the environment is an ePub reader.
      Returns:
      true when running in an ePub context
    • isStandalone

      public boolean isStandalone()
      Reports whether the ePub lab runs on a standalone page instead of inline within text flow.
      Returns:
      true for standalone pages
    • hasKeys

      public boolean hasKeys()
      Reports whether the ePub reader exposes keyboard input.
      Returns:
      true if keyboard events are available
    • hasMouse

      public boolean hasMouse()
      Reports whether the ePub reader exposes mouse input.
      Returns:
      true if mouse events are available
    • hasTouch

      public boolean hasTouch()
      Reports whether the ePub reader exposes touch input.
      Returns:
      true if touch events are available
    • detectFeatures

      private void detectFeatures()
      Detects the capabilities of the current ePub host and updates the shared settings accordingly.
    • updateCLOControls

      private void updateCLOControls(boolean editCLO)
      Updates the command-line option controls to reflect whether editing is allowed.
      Parameters:
      editCLO - true when editing is permitted
    • isReady

      public static boolean isReady()
      Reports whether no other ePub lab is currently running, allowing this lab to start execution.
      Returns:
      true when no other ePub lab is running
    • onModelRunning

      public static void onModelRunning(EvoLudoWeb lab)
      Marks the supplied lab as the currently running ePub instance. Only a single lab may run at once.
      Parameters:
      lab - running lab instance
    • onModelStopped

      public static void onModelStopped(EvoLudoWeb lab)
      Clears the running lab marker once execution stops.
      Parameters:
      lab - lab that just stopped