Module com.googlecode.lanterna
Package com.googlecode.lanterna.graphics
Class DelegatingThemeDefinition
- java.lang.Object
-
- com.googlecode.lanterna.graphics.DelegatingThemeDefinition
-
- All Implemented Interfaces:
ThemeDefinition
public class DelegatingThemeDefinition extends java.lang.Object implements ThemeDefinition
Allows you to more easily wrap an existing theme definion and alter the behaviour in some special cases. You normally create a new class that extends from this and override some of the methods to divert the call depending on what you are trying to do. For an example, please see Issue409 in the test code.- See Also:
DelegatingTheme,DefaultMutableThemeStyle,Theme
-
-
Field Summary
Fields Modifier and Type Field Description private ThemeDefinitionthemeDefinition
-
Constructor Summary
Constructors Constructor Description DelegatingThemeDefinition(ThemeDefinition themeDefinition)Creates a newDelegatingThemeDefinitionwith a default implementation that will forward all calls to theThemeDefinitionthat is passed in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThemeStylegetActive()The "active" style of this definition, which can be used when a component is being directly interacted withbooleangetBooleanProperty(java.lang.String name, boolean defaultValue)Retrieves a custom boolean property, if one is available by this name.chargetCharacter(java.lang.String name, char fallback)Retrieves a character from this theme definition by the specified name.ThemeStylegetCustom(java.lang.String name)Retrieves a custom ThemeStyle, if one is available by this name.ThemeStylegetCustom(java.lang.String name, ThemeStyle defaultValue)Retrieves a customThemeStyle, if one is available by this name.ThemeStylegetInsensitive()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.ThemeStylegetNormal()The normal style of the definition, which can be considered the default to be used.ThemeStylegetPreLight()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 aComponentRendererattached to this definition for the specified type.ThemeStylegetSelected()The "selected" style of this definition, which can used when a component has been actively selected in some way.booleanisCursorVisible()Asks the theme definition for this component if the theme thinks that the text cursor should be visible or not.
-
-
-
Field Detail
-
themeDefinition
private final ThemeDefinition themeDefinition
-
-
Constructor Detail
-
DelegatingThemeDefinition
public DelegatingThemeDefinition(ThemeDefinition themeDefinition)
Creates a newDelegatingThemeDefinitionwith a default implementation that will forward all calls to theThemeDefinitionthat is passed in.- Parameters:
themeDefinition- Other theme definition to delegate all calls to
-
-
Method Detail
-
getNormal
public ThemeStyle getNormal()
Description copied from interface:ThemeDefinitionThe normal style of the definition, which can be considered the default to be used.- Specified by:
getNormalin interfaceThemeDefinition- Returns:
- ThemeStyle representation for the normal style
-
getPreLight
public ThemeStyle getPreLight()
Description copied from interface:ThemeDefinitionThe 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:
getPreLightin interfaceThemeDefinition- Returns:
- ThemeStyle representation for the pre-light style
-
getSelected
public ThemeStyle getSelected()
Description copied from interface:ThemeDefinitionThe "selected" style of this definition, which can used when a component has been actively selected in some way.- Specified by:
getSelectedin interfaceThemeDefinition- Returns:
- ThemeStyle representation for the selected style
-
getActive
public ThemeStyle getActive()
Description copied from interface:ThemeDefinitionThe "active" style of this definition, which can be used when a component is being directly interacted with- Specified by:
getActivein interfaceThemeDefinition- Returns:
- ThemeStyle representation for the active style
-
getInsensitive
public ThemeStyle getInsensitive()
Description copied from interface:ThemeDefinitionThe 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:
getInsensitivein interfaceThemeDefinition- Returns:
- ThemeStyle representation for the insensitive style
-
getCustom
public ThemeStyle getCustom(java.lang.String name)
Description copied from interface:ThemeDefinitionRetrieves 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:
getCustomin 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:ThemeDefinitionRetrieves 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:
getCustomin 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
ThemeStyleassociated with the name, ordefaultValueif there was no such style
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)Description copied from interface:ThemeDefinitionRetrieves 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:
getBooleanPropertyin 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
-
isCursorVisible
public boolean isCursorVisible()
Description copied from interface:ThemeDefinitionAsks 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:
isCursorVisiblein interfaceThemeDefinition- Returns:
- A hint to the renderer as to if this theme thinks the cursor should be visible (returns
true) or not (returnsfalse)
-
getCharacter
public char getCharacter(java.lang.String name, char fallback)Description copied from interface:ThemeDefinitionRetrieves a character from this theme definition by the specified name. This method cannot returnnullso you need to give a fallback in case the definition didn't have any character by this name.- Specified by:
getCharacterin 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
fallbackif the definition didn't have any character defined with this name
-
getRenderer
public <T extends Component> ComponentRenderer<T> getRenderer(java.lang.Class<T> type)
Description copied from interface:ThemeDefinitionReturns aComponentRendererattached 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:
getRendererin interfaceThemeDefinition- Type Parameters:
T- Type of component- Parameters:
type- Component class to get the theme's renderer for- Returns:
- Renderer to use for the
typecomponent ornullto use the default
-
-