Package squidpony.panel
Interface IMarkup<T>
- All Known Implementing Classes:
IMarkup.StringMarkup
public interface IMarkup<T>
An interface that lets non-display code request some special rendering for a
T
value, and an implementation
can handle this appropriately in display code. Much of the time, IMarkup will not be directly used in games, and it
may have much of its value in library code that can use it to declare that some value should be shown in larger text,
or in a certain color, without specifying the exact details of what shade of what color or precisely how much larger
the text should be. However, there may be good uses for highly-specific custom implementations of IMarkup for types
present only in one game, where T
may be Creature
or some other class specific to a game, and the
IMarkup can be used to get a special String to describe or display that Creature with any color/size markup or even
a String that changes over time. The getMarkup(Object)
method yields the appropriate text or markup to
describe its parameter, and the closeMarkup()
method yields text that ends any block of markup that is
ongoing. For the example of an IMarkup for colors, getMarkup would be given a color parameter and would color any
text in that color or a variant on it until the markup is closed with closeMarkup, or possibly until the color is
specified again via getMarkup. For the example of IMarkup for Creatures, getMarkup would produce a String that
describes the Creature it is given as a parameter (if it uses colors/sizes as well, it should close itself to be
self-contained), and closeMarkup would produce the empty String.
Created by Tommy Ettinger on 1/23/2016.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IMarkup.StringMarkup
Probably not that useful on its own, but may be good as an example. -
Method Summary
Modifier and Type Method Description String
closeMarkup()
Implementations should use this method to get a String that ends any section of markup currently ongoing.String
getMarkup(T value)
Implementations should use this method to get a String that describes the given value, or begins some section of markup that uses a quality specified by value, such as a color or text size.
-
Method Details
-
getMarkup
Implementations should use this method to get a String that describes the given value, or begins some section of markup that uses a quality specified by value, such as a color or text size.- Parameters:
value
- an object of type T that can be described by this IMarkup implementation- Returns:
- a String either describing the value or starting a section of markup using the value.
-
closeMarkup
Implementations should use this method to get a String that ends any section of markup currently ongoing. This may be the empty String in many cases.- Returns:
- the requisite String to end any ongoing sections of markup
-