Interface ThemeDefinition

  • All Known Implementing Classes:
    AbstractTheme.DefinitionImpl, DelegatingThemeDefinition, SimpleTheme.Definition

    public interface ThemeDefinition
    A ThemeDefinition contains a collection of ThemeStyle:s, which defines on a lower level which colors and SGRs to apply if you want to draw according to the theme. The different style names are directly inspired from GTK 2. You can also fetch character definitions which are stored inside of the theme, for example if you want to draw a border and make the characters that make up the border customizable.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      ThemeStyle getActive()
      The "active" style of this definition, which can be used when a component is being directly interacted with
      boolean getBooleanProperty​(java.lang.String name, boolean defaultValue)
      Retrieves a custom boolean property, if one is available by this name.
      char getCharacter​(java.lang.String name, char fallback)
      Retrieves a character from this theme definition by the specified name.
      ThemeStyle getCustom​(java.lang.String name)
      Retrieves a custom ThemeStyle, if one is available by this name.
      ThemeStyle getCustom​(java.lang.String name, ThemeStyle defaultValue)
      Retrieves a custom ThemeStyle, if one is available by this name.
      ThemeStyle getInsensitive()
      The insensitive style of this definition, which can be used when a component has been disabled or in some other way isn't able to be interacted with.
      ThemeStyle getNormal()
      The normal style of the definition, which can be considered the default to be used.
      ThemeStyle getPreLight()
      The pre-light style of this definition, which can be used when a component has input focus but isn't active or selected, similar to mouse-hoovering in modern GUIs
      <T extends Component>
      ComponentRenderer<T>
      getRenderer​(java.lang.Class<T> type)
      Returns a ComponentRenderer attached to this definition for the specified type.
      ThemeStyle getSelected()
      The "selected" style of this definition, which can used when a component has been actively selected in some way.
      boolean isCursorVisible()
      Asks the theme definition for this component if the theme thinks that the text cursor should be visible or not.
    • Method Detail

      • getNormal

        ThemeStyle getNormal()
        The normal style of the definition, which can be considered the default to be used.
        Returns:
        ThemeStyle representation for the normal style
      • getPreLight

        ThemeStyle getPreLight()
        The pre-light style of this definition, which can be used when a component has input focus but isn't active or selected, similar to mouse-hoovering in modern GUIs
        Returns:
        ThemeStyle representation for the pre-light style
      • getSelected

        ThemeStyle getSelected()
        The "selected" style of this definition, which can used when a component has been actively selected in some way.
        Returns:
        ThemeStyle representation for the selected style
      • getActive

        ThemeStyle getActive()
        The "active" style of this definition, which can be used when a component is being directly interacted with
        Returns:
        ThemeStyle representation for the active style
      • getInsensitive

        ThemeStyle getInsensitive()
        The insensitive style of this definition, which can be used when a component has been disabled or in some other way isn't able to be interacted with.
        Returns:
        ThemeStyle representation for the insensitive style
      • getCustom

        ThemeStyle getCustom​(java.lang.String name)
        Retrieves a custom ThemeStyle, if one is available by this name. You can use this if you need more categories than the ones available above.
        Parameters:
        name - Name of the style to look up
        Returns:
        The ThemeStyle associated with the name
      • getCustom

        ThemeStyle getCustom​(java.lang.String name,
                             ThemeStyle defaultValue)
        Retrieves a custom ThemeStyle, if one is available by this name. Will return a supplied default value if no such style could be found within this ThemeDefinition. You can use this if you need more categories than the ones available above.
        Parameters:
        name - Name of the style to look up
        defaultValue - What to return if the there is no custom style by the given name
        Returns:
        The ThemeStyle associated with the name, or defaultValue if there was no such style
      • getBooleanProperty

        boolean getBooleanProperty​(java.lang.String name,
                                   boolean defaultValue)
        Retrieves a custom boolean property, if one is available by this name. Will return a supplied default value if no such property could be found within this ThemeDefinition.
        Parameters:
        name - Name of the boolean property to look up
        defaultValue - What to return if the there is no property with this name
        Returns:
        The property value stored in this theme definition, parsed as a boolean
      • isCursorVisible

        boolean isCursorVisible()
        Asks the theme definition for this component if the theme thinks that the text cursor should be visible or not. Note that certain components might have a visible state depending on the context and the current data set, in those cases it can use getBooleanProperty(String, boolean) to allow themes more fine-grained control over when cursor should be visible or not.
        Returns:
        A hint to the renderer as to if this theme thinks the cursor should be visible (returns true) or not (returns false)
      • getCharacter

        char getCharacter​(java.lang.String name,
                          char fallback)
        Retrieves a character from this theme definition by the specified name. This method cannot return null so you need to give a fallback in case the definition didn't have any character by this name.
        Parameters:
        name - Name of the character to look up
        fallback - Character to return if there was no character by the name supplied in this definition
        Returns:
        The character from this definition by the name entered, or fallback if the definition didn't have any character defined with this name
      • getRenderer

        <T extends ComponentComponentRenderer<T> getRenderer​(java.lang.Class<T> type)
        Returns a ComponentRenderer attached to this definition for the specified type. Generally one theme definition is linked to only one component type so it wouldn't need the type parameter to figure out what to return. unlike the other methods of this interface, it will not traverse up in the theme hierarchy if this field is not defined, instead the component will use its default component renderer.
        Type Parameters:
        T - Type of component
        Parameters:
        type - Component class to get the theme's renderer for
        Returns:
        Renderer to use for the type component or null to use the default