ThemeDefinition
public static class SimpleTheme.Definition extends Object implements ThemeDefinition
SimpleTheme
used to allow basic editing of the default style and the optional
overrides.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(String name,
boolean defaultValue) |
Retrieves a custom boolean property, if one is available by this name.
|
char |
getCharacter(String name,
char fallback) |
Retrieves a character from this theme definition by the specified name.
|
ThemeStyle |
getCustom(String name) |
Retrieves a custom ThemeStyle, if one is available by this name.
|
ThemeStyle |
getCustom(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> |
getRenderer(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.
|
SimpleTheme.Definition |
setActive(TextColor foreground,
TextColor background,
SGR... styles) |
Sets the theme definition style "active"
|
SimpleTheme.Definition |
setBooleanProperty(String name,
boolean value) |
Attaches a boolean value property to this
SimpleTheme that will be returned if calling
getBooleanProperty(String, boolean) with the same name. |
SimpleTheme.Definition |
setCharacter(String name,
char character) |
Stores a character value in this definition under a specific name.
|
SimpleTheme.Definition |
setCursorVisible(boolean cursorVisible) |
Sets the value that suggests if the cursor should be visible or not (it's still up to the component renderer
if it's going to honour this or not).
|
SimpleTheme.Definition |
setCustom(String name,
TextColor foreground,
TextColor background,
SGR... styles) |
Adds a custom definition style to the theme using the supplied name.
|
SimpleTheme.Definition |
setInsensitive(TextColor foreground,
TextColor background,
SGR... styles) |
Sets the theme definition style "insensitive"
|
SimpleTheme.Definition |
setPreLight(TextColor foreground,
TextColor background,
SGR... styles) |
Sets the theme definition style "prelight"
|
<T extends Component> |
setRenderer(Class<T> type,
SimpleTheme.RendererProvider<T> rendererProvider) |
Registered a callback to get a custom
ComponentRenderer for a particular class. |
SimpleTheme.Definition |
setSelected(TextColor foreground,
TextColor background,
SGR... styles) |
Sets the theme definition style "selected"
|
public ThemeStyle getNormal()
ThemeDefinition
getNormal
in interface ThemeDefinition
public ThemeStyle getPreLight()
ThemeDefinition
getPreLight
in interface ThemeDefinition
public SimpleTheme.Definition setPreLight(TextColor foreground, TextColor background, SGR... styles)
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to usepublic ThemeStyle getSelected()
ThemeDefinition
getSelected
in interface ThemeDefinition
public SimpleTheme.Definition setSelected(TextColor foreground, TextColor background, SGR... styles)
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to usepublic ThemeStyle getActive()
ThemeDefinition
getActive
in interface ThemeDefinition
public SimpleTheme.Definition setActive(TextColor foreground, TextColor background, SGR... styles)
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to usepublic ThemeStyle getInsensitive()
ThemeDefinition
getInsensitive
in interface ThemeDefinition
public SimpleTheme.Definition setInsensitive(TextColor foreground, TextColor background, SGR... styles)
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to usepublic ThemeStyle getCustom(String name)
ThemeDefinition
getCustom
in interface ThemeDefinition
name
- Name of the style to look uppublic ThemeStyle getCustom(String name, ThemeStyle defaultValue)
ThemeDefinition
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.getCustom
in interface ThemeDefinition
name
- Name of the style to look updefaultValue
- What to return if the there is no custom style by the given nameThemeStyle
associated with the name, or defaultValue
if there was no such stylepublic SimpleTheme.Definition setCustom(String name, TextColor foreground, TextColor background, SGR... styles)
getCustom(String)
.name
- Name of the custom styleforeground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to usepublic boolean getBooleanProperty(String name, boolean defaultValue)
ThemeDefinition
ThemeDefinition
.getBooleanProperty
in interface ThemeDefinition
name
- Name of the boolean property to look updefaultValue
- What to return if the there is no property with this namepublic SimpleTheme.Definition setBooleanProperty(String name, boolean value)
SimpleTheme
that will be returned if calling
getBooleanProperty(String, boolean)
with the same name.name
- Name of the propertyvalue
- Value to attach to the property namepublic boolean isCursorVisible()
ThemeDefinition
ThemeDefinition.getBooleanProperty(String, boolean)
to allow themes more fine-grained control
over when cursor should be visible or not.isCursorVisible
in interface ThemeDefinition
true
) or
not (returns false
)public SimpleTheme.Definition setCursorVisible(boolean cursorVisible)
cursorVisible
- If true
then this theme definition would like the text cursor to be displayed,
false
if not.public char getCharacter(String name, char fallback)
ThemeDefinition
null
so
you need to give a fallback in case the definition didn't have any character by this name.getCharacter
in interface ThemeDefinition
name
- Name of the character to look upfallback
- Character to return if there was no character by the name supplied in this definitionfallback
if the definition didn't have
any character defined with this namepublic SimpleTheme.Definition setCharacter(String name, char character)
getCharacter(String, char)
with the
same name.name
- Symbolic name for the charactercharacter
- Character to attach to the symbolic namepublic <T extends Component> ComponentRenderer<T> getRenderer(Class<T> type)
ThemeDefinition
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.getRenderer
in interface ThemeDefinition
T
- Type of componenttype
- Component class to get the theme's renderer fortype
component or null
to use the defaultpublic <T extends Component> SimpleTheme.Definition setRenderer(Class<T> type, SimpleTheme.RendererProvider<T> rendererProvider)
ComponentRenderer
for a particular class. Use this to make a
certain component (built-in or external) to use a custom renderer.T
- Type of classtype
- Class for which to invoke the callback and return the ComponentRenderer
rendererProvider
- Callback to invoke when getting a ComponentRenderer
Copyright © 2020. All rights reserved.