Class SimpleTheme

  • All Implemented Interfaces:
    Theme

    public class SimpleTheme
    extends java.lang.Object
    implements Theme
    Very basic implementation of Theme that allows you to quickly define a theme in code. It is a very simple implementation that doesn't implement any intelligent fallback based on class hierarchy or package names. If a particular class has not been defined with an explicit override, it will get the default theme style definition.
    • Constructor Detail

      • SimpleTheme

        public SimpleTheme​(TextColor foreground,
                           TextColor background,
                           SGR... styles)
        Creates a new SimpleTheme object that uses the supplied constructor arguments as the default style
        Parameters:
        foreground - Color to use as the foreground unless overridden
        background - Color to use as the background unless overridden
        styles - Extra SGR styles to apply unless overridden
    • Method Detail

      • makeTheme

        public static SimpleTheme makeTheme​(boolean activeIsBold,
                                            TextColor baseForeground,
                                            TextColor baseBackground,
                                            TextColor editableForeground,
                                            TextColor editableBackground,
                                            TextColor selectedForeground,
                                            TextColor selectedBackground,
                                            TextColor guiBackground)
        Helper method that will quickly setup a new theme with some sensible component overrides.
        Parameters:
        activeIsBold - Should focused components also use bold SGR style?
        baseForeground - The base foreground color of the theme
        baseBackground - The base background color of the theme
        editableForeground - Foreground color for editable components, or editable areas of components
        editableBackground - Background color for editable components, or editable areas of components
        selectedForeground - Foreground color for the selection marker when a component has multiple selection states
        selectedBackground - Background color for the selection marker when a component has multiple selection states
        guiBackground - Background color of the GUI, if this theme is assigned to the TextGUI
        Returns:
        Assembled SimpleTheme using the parameters from above
      • getDefaultDefinition

        public SimpleTheme.Definition getDefaultDefinition()
        Description copied from interface: Theme
        Returns what this theme considers to be the default definition
        Specified by:
        getDefaultDefinition in interface Theme
        Returns:
        The default theme definition
      • getDefinition

        public SimpleTheme.Definition getDefinition​(java.lang.Class<?> clazz)
        Description copied from interface: Theme
        Returns the theme definition associated with this class. The implementation of Theme should ensure that this call never returns null, it should always give back a valid value (falling back to the default is nothing else can be used).
        Specified by:
        getDefinition in interface Theme
        Parameters:
        clazz - Class to get the theme definition for
        Returns:
        The ThemeDefinition for the class passed in
      • addOverride

        public SimpleTheme.Definition addOverride​(java.lang.Class<?> clazz,
                                                  TextColor foreground,
                                                  TextColor background,
                                                  SGR... styles)
        Adds an override for a particular class, or overwrites a previously defined override.
        Parameters:
        clazz - Class to override the theme for
        foreground - Color to use as the foreground color for this override style
        background - Color to use as the background color for this override style
        styles - SGR styles to apply for this override
        Returns:
        The newly created SimpleTheme.Definition that corresponds to this override.
      • getWindowPostRenderer

        public WindowPostRenderer getWindowPostRenderer()
        Description copied from interface: Theme
        Returns a post-renderer to invoke after drawing each window, unless the GUI system or individual windows has their own renderers set. If null, no post-renderer will be done (unless the GUI system or the windows has a post-renderer).
        Specified by:
        getWindowPostRenderer in interface Theme
        Returns:
        A WindowPostRenderer to invoke after drawing each window unless overridden, or null if none
      • setWindowPostRenderer

        public SimpleTheme setWindowPostRenderer​(WindowPostRenderer windowPostRenderer)
        Changes the WindowPostRenderer this theme will return. If called with null, the theme returns no post renderer and the GUI system will use whatever is the default.
        Parameters:
        windowPostRenderer - Post-renderer to use along with this theme, or null to remove
        Returns:
        Itself
      • setWindowDecorationRenderer

        public SimpleTheme setWindowDecorationRenderer​(WindowDecorationRenderer windowDecorationRenderer)
        Changes the WindowDecorationRenderer this theme will return. If called with null, the theme returns no decoration renderer and the GUI system will use whatever is the default.
        Parameters:
        windowDecorationRenderer - Decoration renderer to use along with this theme, or null to remove
        Returns:
        Itself