Module com.googlecode.lanterna
Package com.googlecode.lanterna.graphics
Class DefaultMutableThemeStyle
- java.lang.Object
-
- com.googlecode.lanterna.graphics.DefaultMutableThemeStyle
-
- All Implemented Interfaces:
ThemeStyle
public class DefaultMutableThemeStyle extends java.lang.Object implements ThemeStyle
This basic implementation of ThemeStyle keeps the styles in its internal state and allows you to mutate them. It can be used to more easily override an existing theme and make small changes programmatically to it, see Issue409 in the test section for an example of how to do this.- See Also:
DelegatingThemeDefinition,DelegatingTheme,Theme
-
-
Field Summary
Fields Modifier and Type Field Description private TextColorbackgroundprivate TextColorforegroundprivate java.util.EnumSet<SGR>sgrs
-
Constructor Summary
Constructors Modifier Constructor Description DefaultMutableThemeStyle(ThemeStyle themeStyleToCopy)Creates a newDefaultMutableThemeStylebased on an existingThemeStyle.DefaultMutableThemeStyle(TextColor foreground, TextColor background, SGR... sgrs)Creates a newDefaultMutableThemeStylewith a specified style (foreground, background and SGR state)privateDefaultMutableThemeStyle(TextColor foreground, TextColor background, java.util.EnumSet<SGR> sgrs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextColorgetBackground()Returns the background color associated with this styleTextColorgetForeground()Returns the foreground color associated with this stylejava.util.EnumSet<SGR>getSGRs()Returns the set of SGR flags associated with this style.DefaultMutableThemeStylesetBackground(TextColor background)Modifies the background color of thisDefaultMutableThemeStyleto the value passed inDefaultMutableThemeStylesetForeground(TextColor foreground)Modifies the foreground color of thisDefaultMutableThemeStyleto the value passed inDefaultMutableThemeStylesetSGRs(java.util.EnumSet<SGR> sgrs)Modifies the SGR modifiers of thisDefaultMutableThemeStyleto the values passed it.
-
-
-
Constructor Detail
-
DefaultMutableThemeStyle
public DefaultMutableThemeStyle(ThemeStyle themeStyleToCopy)
Creates a newDefaultMutableThemeStylebased on an existingThemeStyle. The values of this style that is passed in will be copied into the new object that is created.- Parameters:
themeStyleToCopy-ThemeStyleobject to copy the style parameters from
-
DefaultMutableThemeStyle
public DefaultMutableThemeStyle(TextColor foreground, TextColor background, SGR... sgrs)
Creates a newDefaultMutableThemeStylewith a specified style (foreground, background and SGR state)- Parameters:
foreground- Foreground color of the text with this stylebackground- Background color of the text with this stylesgrs- Modifiers to apply to the text with this style
-
-
Method Detail
-
getForeground
public TextColor getForeground()
Description copied from interface:ThemeStyleReturns the foreground color associated with this style- Specified by:
getForegroundin interfaceThemeStyle- Returns:
- foreground color associated with this style
-
getBackground
public TextColor getBackground()
Description copied from interface:ThemeStyleReturns the background color associated with this style- Specified by:
getBackgroundin interfaceThemeStyle- Returns:
- background color associated with this style
-
getSGRs
public java.util.EnumSet<SGR> getSGRs()
Description copied from interface:ThemeStyleReturns the set of SGR flags associated with this style. ThisEnumSetis either unmodifiable or a copy so altering it will not change the theme in any way.- Specified by:
getSGRsin interfaceThemeStyle- Returns:
- SGR flags associated with this style
-
setForeground
public DefaultMutableThemeStyle setForeground(TextColor foreground)
Modifies the foreground color of thisDefaultMutableThemeStyleto the value passed in- Parameters:
foreground- New foreground color for this theme style- Returns:
- Itself
-
setBackground
public DefaultMutableThemeStyle setBackground(TextColor background)
Modifies the background color of thisDefaultMutableThemeStyleto the value passed in- Parameters:
background- New background color for this theme style- Returns:
- Itself
-
setSGRs
public DefaultMutableThemeStyle setSGRs(java.util.EnumSet<SGR> sgrs)
Modifies the SGR modifiers of thisDefaultMutableThemeStyleto the values passed it.- Parameters:
sgrs- New SGR modifiers for this theme style, the values in this set will be copied into the internal state- Returns:
- Itself
-
-