Module com.googlecode.lanterna
Package com.googlecode.lanterna.graphics
Class SimpleTheme.Definition
- java.lang.Object
-
- com.googlecode.lanterna.graphics.SimpleTheme.Definition
-
- All Implemented Interfaces:
ThemeDefinition
- Enclosing class:
- SimpleTheme
public static class SimpleTheme.Definition extends java.lang.Object implements ThemeDefinition
Internal class insideSimpleTheme
used to allow basic editing of the default style and the optional overrides.
-
-
Field Summary
Fields Modifier and Type Field Description private ThemeStyle
active
private java.util.Map<java.lang.String,java.lang.Character>
characterMap
private java.util.Map<java.lang.Class<?>,SimpleTheme.RendererProvider<?>>
componentRendererMap
private boolean
cursorVisible
private java.util.Map<java.lang.String,ThemeStyle>
customStyles
private ThemeStyle
insensitive
private ThemeStyle
normal
private ThemeStyle
preLight
private java.util.Properties
properties
private ThemeStyle
selected
-
Constructor Summary
Constructors Modifier Constructor Description private
Definition(ThemeStyle normal)
-
Method Summary
All Methods Instance Methods Concrete 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 withboolean
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 customThemeStyle
, 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 aComponentRenderer
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(java.lang.String name, boolean value)
Attaches a boolean value property to thisSimpleTheme
that will be returned if callinggetBooleanProperty(String, boolean)
with the same name.SimpleTheme.Definition
setCharacter(java.lang.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(java.lang.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>
SimpleTheme.DefinitionsetRenderer(java.lang.Class<T> type, SimpleTheme.RendererProvider<T> rendererProvider)
Registered a callback to get a customComponentRenderer
for a particular class.SimpleTheme.Definition
setSelected(TextColor foreground, TextColor background, SGR... styles)
Sets the theme definition style "selected"
-
-
-
Field Detail
-
normal
private final ThemeStyle normal
-
preLight
private ThemeStyle preLight
-
selected
private ThemeStyle selected
-
active
private ThemeStyle active
-
insensitive
private ThemeStyle insensitive
-
customStyles
private final java.util.Map<java.lang.String,ThemeStyle> customStyles
-
properties
private final java.util.Properties properties
-
characterMap
private final java.util.Map<java.lang.String,java.lang.Character> characterMap
-
componentRendererMap
private final java.util.Map<java.lang.Class<?>,SimpleTheme.RendererProvider<?>> componentRendererMap
-
cursorVisible
private boolean cursorVisible
-
-
Constructor Detail
-
Definition
private Definition(ThemeStyle normal)
-
-
Method Detail
-
getNormal
public ThemeStyle getNormal()
Description copied from interface:ThemeDefinition
The normal style of the definition, which can be considered the default to be used.- Specified by:
getNormal
in interfaceThemeDefinition
- Returns:
- ThemeStyle representation for the normal style
-
getPreLight
public ThemeStyle getPreLight()
Description copied from interface:ThemeDefinition
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- Specified by:
getPreLight
in interfaceThemeDefinition
- Returns:
- ThemeStyle representation for the pre-light style
-
setPreLight
public SimpleTheme.Definition setPreLight(TextColor foreground, TextColor background, SGR... styles)
Sets the theme definition style "prelight"- Parameters:
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to use- Returns:
- Itself
-
getSelected
public ThemeStyle getSelected()
Description copied from interface:ThemeDefinition
The "selected" style of this definition, which can used when a component has been actively selected in some way.- Specified by:
getSelected
in interfaceThemeDefinition
- Returns:
- ThemeStyle representation for the selected style
-
setSelected
public SimpleTheme.Definition setSelected(TextColor foreground, TextColor background, SGR... styles)
Sets the theme definition style "selected"- Parameters:
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to use- Returns:
- Itself
-
getActive
public ThemeStyle getActive()
Description copied from interface:ThemeDefinition
The "active" style of this definition, which can be used when a component is being directly interacted with- Specified by:
getActive
in interfaceThemeDefinition
- Returns:
- ThemeStyle representation for the active style
-
setActive
public SimpleTheme.Definition setActive(TextColor foreground, TextColor background, SGR... styles)
Sets the theme definition style "active"- Parameters:
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to use- Returns:
- Itself
-
getInsensitive
public ThemeStyle getInsensitive()
Description copied from interface:ThemeDefinition
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.- Specified by:
getInsensitive
in interfaceThemeDefinition
- Returns:
- ThemeStyle representation for the insensitive style
-
setInsensitive
public SimpleTheme.Definition setInsensitive(TextColor foreground, TextColor background, SGR... styles)
Sets the theme definition style "insensitive"- Parameters:
foreground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to use- Returns:
- Itself
-
getCustom
public ThemeStyle getCustom(java.lang.String name)
Description copied from interface:ThemeDefinition
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.- Specified by:
getCustom
in interfaceThemeDefinition
- Parameters:
name
- Name of the style to look up- Returns:
- The ThemeStyle associated with the name
-
getCustom
public ThemeStyle getCustom(java.lang.String name, ThemeStyle defaultValue)
Description copied from interface:ThemeDefinition
Retrieves a customThemeStyle
, if one is available by this name. Will return a supplied default value if no such style could be found within thisThemeDefinition
. You can use this if you need more categories than the ones available above.- Specified by:
getCustom
in interfaceThemeDefinition
- Parameters:
name
- Name of the style to look updefaultValue
- What to return if the there is no custom style by the given name- Returns:
- The
ThemeStyle
associated with the name, ordefaultValue
if there was no such style
-
setCustom
public SimpleTheme.Definition setCustom(java.lang.String name, TextColor foreground, TextColor background, SGR... styles)
Adds a custom definition style to the theme using the supplied name. This will be returned using the matching call togetCustom(String)
.- Parameters:
name
- Name of the custom styleforeground
- Foreground color for this stylebackground
- Background color for this stylestyles
- SGR styles to use- Returns:
- Itself
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
Description copied from interface:ThemeDefinition
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 thisThemeDefinition
.- Specified by:
getBooleanProperty
in interfaceThemeDefinition
- Parameters:
name
- Name of the boolean property to look updefaultValue
- 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
-
setBooleanProperty
public SimpleTheme.Definition setBooleanProperty(java.lang.String name, boolean value)
Attaches a boolean value property to thisSimpleTheme
that will be returned if callinggetBooleanProperty(String, boolean)
with the same name.- Parameters:
name
- Name of the propertyvalue
- Value to attach to the property name- Returns:
- Itself
-
isCursorVisible
public boolean isCursorVisible()
Description copied from interface:ThemeDefinition
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 useThemeDefinition.getBooleanProperty(String, boolean)
to allow themes more fine-grained control over when cursor should be visible or not.- Specified by:
isCursorVisible
in interfaceThemeDefinition
- Returns:
- A hint to the renderer as to if this theme thinks the cursor should be visible (returns
true
) or not (returnsfalse
)
-
setCursorVisible
public 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).- Parameters:
cursorVisible
- Iftrue
then this theme definition would like the text cursor to be displayed,false
if not.- Returns:
- Itself
-
getCharacter
public char getCharacter(java.lang.String name, char fallback)
Description copied from interface:ThemeDefinition
Retrieves a character from this theme definition by the specified name. This method cannot returnnull
so you need to give a fallback in case the definition didn't have any character by this name.- Specified by:
getCharacter
in interfaceThemeDefinition
- Parameters:
name
- Name of the character to look upfallback
- 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
-
setCharacter
public SimpleTheme.Definition setCharacter(java.lang.String name, char character)
Stores a character value in this definition under a specific name. This is used to customize the appearance of certain components. It is returned with call togetCharacter(String, char)
with the same name.- Parameters:
name
- Symbolic name for the charactercharacter
- Character to attach to the symbolic name- Returns:
- Itself
-
getRenderer
public <T extends Component> ComponentRenderer<T> getRenderer(java.lang.Class<T> type)
Description copied from interface:ThemeDefinition
Returns aComponentRenderer
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.- Specified by:
getRenderer
in interfaceThemeDefinition
- 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 ornull
to use the default
-
setRenderer
public <T extends Component> SimpleTheme.Definition setRenderer(java.lang.Class<T> type, SimpleTheme.RendererProvider<T> rendererProvider)
Registered a callback to get a customComponentRenderer
for a particular class. Use this to make a certain component (built-in or external) to use a custom renderer.- Type Parameters:
T
- Type of class- Parameters:
type
- Class for which to invoke the callback and return theComponentRenderer
rendererProvider
- Callback to invoke when getting aComponentRenderer
- Returns:
- Itself
-
-