java.lang.Object
com.googlecode.lanterna.graphics.SimpleTheme
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Internal class insideSimpleTheme
used to allow basic editing of the default style and the optional overrides.static interface
SimpleTheme.RendererProvider<T extends Component>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SimpleTheme.Definition
private final Map
<Class<?>, SimpleTheme.Definition> private WindowDecorationRenderer
private WindowPostRenderer
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleTheme
(TextColor foreground, TextColor background, SGR... styles) Creates a newSimpleTheme
object that uses the supplied constructor arguments as the default style -
Method Summary
Modifier and TypeMethodDescriptionaddOverride
(Class<?> clazz, TextColor foreground, TextColor background, SGR... styles) Adds an override for a particular class, or overwrites a previously defined override.Returns what this theme considers to be the default definitiongetDefinition
(Class<?> clazz) Returns the theme definition associated with this class.Returns theWindowDecorationRenderer
to use for windows drawn in this theme.Returns a post-renderer to invoke after drawing each window, unless the GUI system or individual windows has their own renderers set.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.setWindowDecorationRenderer
(WindowDecorationRenderer windowDecorationRenderer) Changes theWindowDecorationRenderer
this theme will return.setWindowPostRenderer
(WindowPostRenderer windowPostRenderer) Changes theWindowPostRenderer
this theme will return.
-
Field Details
-
defaultDefinition
-
overrideDefinitions
-
windowPostRenderer
-
windowDecorationRenderer
-
-
Constructor Details
-
SimpleTheme
Creates a newSimpleTheme
object that uses the supplied constructor arguments as the default style- Parameters:
foreground
- Color to use as the foreground unless overriddenbackground
- Color to use as the background unless overriddenstyles
- Extra SGR styles to apply unless overridden
-
-
Method Details
-
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 themebaseBackground
- The base background color of the themeeditableForeground
- Foreground color for editable components, or editable areas of componentseditableBackground
- Background color for editable components, or editable areas of componentsselectedForeground
- Foreground color for the selection marker when a component has multiple selection statesselectedBackground
- Background color for the selection marker when a component has multiple selection statesguiBackground
- Background color of the GUI, if this theme is assigned to theTextGUI
- Returns:
- Assembled
SimpleTheme
using the parameters from above
-
getDefaultDefinition
Description copied from interface:Theme
Returns what this theme considers to be the default definition- Specified by:
getDefaultDefinition
in interfaceTheme
- Returns:
- The default theme definition
-
getDefinition
Description copied from interface:Theme
Returns the theme definition associated with this class. The implementation of Theme should ensure that this call never returnsnull
, it should always give back a valid value (falling back to the default is nothing else can be used).- Specified by:
getDefinition
in interfaceTheme
- Parameters:
clazz
- Class to get the theme definition for- Returns:
- The ThemeDefinition for the class passed in
-
addOverride
public SimpleTheme.Definition addOverride(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 forforeground
- Color to use as the foreground color for this override stylebackground
- Color to use as the background color for this override stylestyles
- SGR styles to apply for this override- Returns:
- The newly created
SimpleTheme.Definition
that corresponds to this override.
-
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. Ifnull
, no post-renderer will be done (unless the GUI system or the windows has a post-renderer).- Specified by:
getWindowPostRenderer
in interfaceTheme
- Returns:
- A
WindowPostRenderer
to invoke after drawing each window unless overridden, ornull
if none
-
setWindowPostRenderer
Changes theWindowPostRenderer
this theme will return. If called withnull
, 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, ornull
to remove- Returns:
- Itself
-
getWindowDecorationRenderer
Description copied from interface:Theme
Returns theWindowDecorationRenderer
to use for windows drawn in this theme. Ifnull
then lanterna will fall back to useDefaultWindowDecorationRenderer
.- Specified by:
getWindowDecorationRenderer
in interfaceTheme
- Returns:
- The decoration renderer to use for this theme, or
null
to use system default
-
setWindowDecorationRenderer
Changes theWindowDecorationRenderer
this theme will return. If called withnull
, 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, ornull
to remove- Returns:
- Itself
-