Package swingtree

Class SwingTreeInitConfig

java.lang.Object
swingtree.SwingTreeInitConfig

public final class SwingTreeInitConfig extends Object
An immutable configuration object for the SwingTree library, which can be configured using a functional SwingTreeConfigurator lambda passed to SwingTree.initializeUsing(SwingTreeConfigurator).

It allows for the configuration of the default font, font installation, scaling, event processing and application wide StyleSheet among other things.

  • Method Details

    • defaults

      public static SwingTreeInitConfig defaults()
    • defaultFont

      public SwingTreeInitConfig defaultFont(Font newDefaultFont)
      Used to configure the default font, which may be used by the SwingTree to derive the UI scaling factor and or to install the font in the UIManager depending on the SwingTreeInitConfig.FontInstallation mode (see defaultFont(Font, FontInstallation)).
      Parameters:
      newDefaultFont - The new default font, or null to unset the default font.
      Returns:
      A new SwingTreeInitConfig instance with the new default font.
    • defaultFont

      public SwingTreeInitConfig defaultFont(Font newDefaultFont, SwingTreeInitConfig.FontInstallation newFontInstallation)
      Used to configure both the default Font and the SwingTreeInitConfig.FontInstallation mode.

      The SwingTreeInitConfig.FontInstallation mode determines how the Font is installed in the UIManager (see SwingTreeInitConfig.FontInstallation).

      If the SwingTreeInitConfig.FontInstallation mode is SwingTreeInitConfig.FontInstallation.SOFT, then the Font will only be installed as the "defaultFont" property in the UIManager. If on the other hand the SwingTreeInitConfig.FontInstallation mode is SwingTreeInitConfig.FontInstallation.HARD, then the Font will be installed by replacing all Fonts in the UIManager.

      Parameters:
      newDefaultFont - The new default font, or null to unset the default font.
      newFontInstallation - The new SwingTreeInitConfig.FontInstallation mode.
      Returns:
      A new SwingTreeInitConfig instance with the new default font and SwingTreeInitConfig.FontInstallation mode.
    • eventProcessor

      public SwingTreeInitConfig eventProcessor(EventProcessor newEventProcessor)
      Used to configure the EventProcessor, which is used to process both UI and application events. You may create your own EventProcessor implementation or use one of the predefined ones like EventProcessor.COUPLED_STRICT, EventProcessor.COUPLED or EventProcessor.DECOUPLED.
      Parameters:
      newEventProcessor - The new EventProcessor.
      Returns:
      A new SwingTreeInitConfig instance with the new EventProcessor.
    • styleSheet

      public SwingTreeInitConfig styleSheet(StyleSheet newStyleSheet)
      Used to configure a global StyleSheet serving as a base for all StyleSheets used inside your application (see UIFactoryMethods.use(swingtree.style.StyleSheet, Supplier)).
      Parameters:
      newStyleSheet - The new StyleSheet, or null to unset the StyleSheet.
      Returns:
      A new SwingTreeInitConfig instance with the new StyleSheet.
    • uiScaleFactor

      public SwingTreeInitConfig uiScaleFactor(float newUiScale)
      Use this to configure the UI scaling factor. The default factor determined by the system property "swingtree.uiScale".

      If Java runtime scales (Java 9 or later), this scale factor is applied on top of the Java system scale factor. Java 8 does not scale and this scale factor replaces the user scale factor that SwingTree computes based on the font. To replace the Java 9+ system scale factor, use system property "sun.java2d.uiScale", which has the same syntax as this one.

      Allowed Values e.g. 1.5, 1.5x, 150% or 144dpi (96dpi is 100%)

      Parameters:
      newUiScale - The new UI scaling factor.
      Returns:
      A new SwingTreeInitConfig instance with the new UI scaling factor.
    • isUiScaleFactorEnabled

      public SwingTreeInitConfig isUiScaleFactorEnabled(boolean newUiScaleEnabled)
      Used to configure whether the UI scaling mode is enabled as is specified by the system property swingtree.uiScale.enabled.

      Allowed Values false and true
      Default true

      Parameters:
      newUiScaleEnabled - The new UI scaling mode.
      Returns:
      A new SwingTreeInitConfig instance with the new UI scaling mode.
    • isUiScaleDownAllowed

      public SwingTreeInitConfig isUiScaleDownAllowed(boolean newUiScaleAllowScaleDown)
      Used to configure whether values smaller than 100% are allowed for the user scale factor as is specified by the system property swingtree.uiScale.allowScaleDown.

      Allowed Values false and true
      Default false

      Parameters:
      newUiScaleAllowScaleDown - The new UI scaling mode.
      Returns:
      A new SwingTreeInitConfig instance with the new UI scaling mode.
    • defaultAnimationInterval

      public SwingTreeInitConfig defaultAnimationInterval(long newDefaultAnimationInterval)
      Used to configure the default animation interval in milliseconds, which is a property that determines the delay between two consecutive animation steps. You can think of it as the time between the heartbeats of the animation. The smaller the interval, the higher the refresh rate and the smoother the animation will look. However, the smaller the interval, the more CPU time will be used. The default interval is 16 ms which corresponds to 60 fps. See defaults(), returning an instance of this config with the default value.
      This property is used as default value by the LifeTime object which is used to define the duration of an Animation.
      Parameters:
      newDefaultAnimationInterval - The new default animation interval.
      Returns:
      A new SwingTreeInitConfig instance with the new default animation interval.
    • logMarker

      public SwingTreeInitConfig logMarker(org.slf4j.Marker newLogMarker)
      Allows you to configure the logging Marker used by SwingTree for all its logging. This is typically passed to methods like logger.debug(Marker, String), logger.info(Marker, String) and so on.
      You may use this marker to channel SwingTree logs to a separate log file or to filter them in any other way you like.
      Parameters:
      newLogMarker - The new logging Marker which is passed to methods of the SLF4J logger.
      Returns:
      A new SwingTreeInitConfig instance with the new logging Marker.
    • recordDebugSourceTrace

      public SwingTreeInitConfig recordDebugSourceTrace(boolean isEnabled)
      Used to configure whether SwingTree should record a source code trace for every component built by SwingTree for debugging purposes. Such a source code trace is stored in the form of a Tuple of StackTraceElements as a client property on the component under the key "built-at".
      You can inspect the source code trace using the SwingTree dev tools by pressing the keystroke specified by devToolKeyStrokeShortcut(String), which is by default "ctrl shift I". In the dev tool you can hold control and click on a component to see the source code trace among other debug information about the component.
      Parameters:
      isEnabled - Whether the recording of the source code trace should be enabled.
      Returns:
      A new SwingTreeInitConfig instance with the new recording mode for the source code trace.
      See Also:
    • devToolKeyStrokeShortcut

      public SwingTreeInitConfig devToolKeyStrokeShortcut(String keyStroke)
      Use this method to configure the keystroke to access the SwingTree dev tools, which by default is "ctrl shift I".
      In the dev tool you can hold control and click on a component to summon a dialog showing valuable debug information about the component.
      This includes basic things like the name, style, layout information and the dimensions of the component.
      However, you may also want to see a stack trace of when the component was created and added to the component hierarchy. This is also something you can inspect in this dev tool if the recordDebugSourceTrace(boolean) mode is set to true (which by default it is).
      Because this is the mode that creates the source code trace in the first place.
      Parameters:
      keyStroke - The new keystroke to access the SwingTree dev tools, e.g. "ctrl shift I".
      Returns:
      A new SwingTreeInitConfig instance with the new keystroke to access the SwingTree dev tools.
      See Also: