Theme
public class SimpleTheme extends Object implements Theme
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.Modifier and Type | Class | Description |
---|---|---|
static class |
SimpleTheme.Definition |
Internal class inside
SimpleTheme used to allow basic editing of the default style and the optional
overrides. |
static interface |
SimpleTheme.RendererProvider<T extends Component> |
Constructor | Description |
---|---|
SimpleTheme(TextColor foreground,
TextColor background,
SGR... styles) |
Creates a new
SimpleTheme object that uses the supplied constructor arguments as the default style |
Modifier and Type | Method | Description |
---|---|---|
SimpleTheme.Definition |
addOverride(Class<?> clazz,
TextColor foreground,
TextColor background,
SGR... styles) |
Adds an override for a particular class, or overwrites a previously defined override.
|
SimpleTheme.Definition |
getDefaultDefinition() |
Returns what this theme considers to be the default definition
|
SimpleTheme.Definition |
getDefinition(Class<?> clazz) |
Returns the theme definition associated with this class.
|
WindowDecorationRenderer |
getWindowDecorationRenderer() |
Returns the
WindowDecorationRenderer to use for windows drawn in this theme. |
WindowPostRenderer |
getWindowPostRenderer() |
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.
|
SimpleTheme |
setWindowDecorationRenderer(WindowDecorationRenderer windowDecorationRenderer) |
Changes the
WindowDecorationRenderer this theme will return. |
SimpleTheme |
setWindowPostRenderer(WindowPostRenderer windowPostRenderer) |
Changes the
WindowPostRenderer this theme will return. |
public SimpleTheme(TextColor foreground, TextColor background, SGR... styles)
SimpleTheme
object that uses the supplied constructor arguments as the default styleforeground
- Color to use as the foreground unless overriddenbackground
- Color to use as the background unless overriddenstyles
- Extra SGR styles to apply unless overriddenpublic static SimpleTheme makeTheme(boolean activeIsBold, TextColor baseForeground, TextColor baseBackground, TextColor editableForeground, TextColor editableBackground, TextColor selectedForeground, TextColor selectedBackground, TextColor guiBackground)
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 the TextGUI
SimpleTheme
using the parameters from abovepublic SimpleTheme.Definition getDefaultDefinition()
Theme
getDefaultDefinition
in interface Theme
public SimpleTheme.Definition getDefinition(Class<?> clazz)
Theme
null
, it should always give back a valid value (falling back to the default is nothing
else can be used).getDefinition
in interface Theme
clazz
- Class to get the theme definition forpublic SimpleTheme.Definition addOverride(Class<?> clazz, TextColor foreground, TextColor background, SGR... styles)
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 overrideSimpleTheme.Definition
that corresponds to this override.public WindowPostRenderer getWindowPostRenderer()
Theme
null
, no post-renderer will be done (unless the GUI system or the windows
has a post-renderer).getWindowPostRenderer
in interface Theme
WindowPostRenderer
to invoke after drawing each window unless
overridden, or null
if nonepublic SimpleTheme setWindowPostRenderer(WindowPostRenderer windowPostRenderer)
WindowPostRenderer
this theme will return. If called with null
, the theme returns no
post renderer and the GUI system will use whatever is the default.windowPostRenderer
- Post-renderer to use along with this theme, or null
to removepublic WindowDecorationRenderer getWindowDecorationRenderer()
Theme
WindowDecorationRenderer
to use for windows drawn in this theme. If null
then
lanterna will fall back to use DefaultWindowDecorationRenderer
.getWindowDecorationRenderer
in interface Theme
null
to use system defaultpublic SimpleTheme setWindowDecorationRenderer(WindowDecorationRenderer windowDecorationRenderer)
WindowDecorationRenderer
this theme will return. If called with null
, the theme
returns no decoration renderer and the GUI system will use whatever is the default.windowDecorationRenderer
- Decoration renderer to use along with this theme, or null
to removeCopyright © 2020. All rights reserved.