- java.lang.Object
-
- com.googlecode.lanterna.graphics.SimpleTheme
-
- All Implemented Interfaces:
Theme
public class SimpleTheme extends java.lang.Object implements Theme
Very basic implementation ofThemethat 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 Classes Modifier and Type Class Description static classSimpleTheme.DefinitionInternal class insideSimpleThemeused to allow basic editing of the default style and the optional overrides.static interfaceSimpleTheme.RendererProvider<T extends Component>
-
Field Summary
Fields Modifier and Type Field Description private SimpleTheme.DefinitiondefaultDefinitionprivate java.util.Map<java.lang.Class<?>,SimpleTheme.Definition>overrideDefinitionsprivate WindowDecorationRendererwindowDecorationRendererprivate WindowPostRendererwindowPostRenderer
-
Constructor Summary
Constructors Constructor Description SimpleTheme(TextColor foreground, TextColor background, SGR... styles)Creates a newSimpleThemeobject that uses the supplied constructor arguments as the default style
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleTheme.DefinitionaddOverride(java.lang.Class<?> clazz, TextColor foreground, TextColor background, SGR... styles)Adds an override for a particular class, or overwrites a previously defined override.SimpleTheme.DefinitiongetDefaultDefinition()Returns what this theme considers to be the default definitionSimpleTheme.DefinitiongetDefinition(java.lang.Class<?> clazz)Returns the theme definition associated with this class.WindowDecorationRenderergetWindowDecorationRenderer()Returns theWindowDecorationRendererto use for windows drawn in this theme.WindowPostRenderergetWindowPostRenderer()Returns a post-renderer to invoke after drawing each window, unless the GUI system or individual windows has their own renderers set.static SimpleThememakeTheme(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.SimpleThemesetWindowDecorationRenderer(WindowDecorationRenderer windowDecorationRenderer)Changes theWindowDecorationRendererthis theme will return.SimpleThemesetWindowPostRenderer(WindowPostRenderer windowPostRenderer)Changes theWindowPostRendererthis theme will return.
-
-
-
Field Detail
-
defaultDefinition
private final SimpleTheme.Definition defaultDefinition
-
overrideDefinitions
private final java.util.Map<java.lang.Class<?>,SimpleTheme.Definition> overrideDefinitions
-
windowPostRenderer
private WindowPostRenderer windowPostRenderer
-
windowDecorationRenderer
private WindowDecorationRenderer windowDecorationRenderer
-
-
Constructor Detail
-
SimpleTheme
public SimpleTheme(TextColor foreground, TextColor background, SGR... styles)
Creates a newSimpleThemeobject 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 Detail
-
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
SimpleThemeusing the parameters from above
-
getDefaultDefinition
public SimpleTheme.Definition getDefaultDefinition()
Description copied from interface:ThemeReturns what this theme considers to be the default definition- Specified by:
getDefaultDefinitionin interfaceTheme- Returns:
- The default theme definition
-
getDefinition
public SimpleTheme.Definition getDefinition(java.lang.Class<?> clazz)
Description copied from interface:ThemeReturns 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:
getDefinitionin interfaceTheme- Parameters:
clazz- Class to get the theme definition for- Returns:
- The ThemeDefinition for the class passed in
-
addOverride
public SimpleTheme.Definition addOverride(java.lang.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.Definitionthat corresponds to this override.
-
getWindowPostRenderer
public WindowPostRenderer getWindowPostRenderer()
Description copied from interface:ThemeReturns 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:
getWindowPostRendererin interfaceTheme- Returns:
- A
WindowPostRendererto invoke after drawing each window unless overridden, ornullif none
-
setWindowPostRenderer
public SimpleTheme setWindowPostRenderer(WindowPostRenderer windowPostRenderer)
Changes theWindowPostRendererthis 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, ornullto remove- Returns:
- Itself
-
getWindowDecorationRenderer
public WindowDecorationRenderer getWindowDecorationRenderer()
Description copied from interface:ThemeReturns theWindowDecorationRendererto use for windows drawn in this theme. Ifnullthen lanterna will fall back to useDefaultWindowDecorationRenderer.- Specified by:
getWindowDecorationRendererin interfaceTheme- Returns:
- The decoration renderer to use for this theme, or
nullto use system default
-
setWindowDecorationRenderer
public SimpleTheme setWindowDecorationRenderer(WindowDecorationRenderer windowDecorationRenderer)
Changes theWindowDecorationRendererthis 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, ornullto remove- Returns:
- Itself
-
-