Package squidpony
Class ColoredStringList<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<IColoredString<T>>
,Collection<IColoredString<T>>
,List<IColoredString<T>>
,RandomAccess
public class ColoredStringList<T> extends ArrayList<IColoredString<T>>
An helper class for code that deals with lists of
IColoredString
s. It
does nothing smart, its only purpose is to save you some typing for frequent
calls. It is particularly useful when feeding large pieces of text to classes
like TextPanel in the display module.- Author:
- smelC
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ColoredStringList()
ColoredStringList(int expectedSize)
-
Method Summary
Modifier and Type Method Description void
addAllText(Collection<? extends IColoredString<T>> texts)
Contrary toCollection.addAll(Collection)
, this method appends text to the current text, without inserting new lines.void
addColoredText(String text, T c)
Appends colored text tothis
.void
addColoredTextOnNewLine(String text, T color)
Appends colored text tothis
.void
addEmptyLine()
Jumps a line.void
addOnNewLine(Collection<? extends IColoredString<T>> texts)
Addstexts
tothis
, starting a new line for the first one.void
addText(String text)
Appendstext
tothis
, without specifying its color.void
addText(IColoredString<T> text)
Appendstext
tothis
.void
addTextOnNewLine(String text)
Appends text tothis
, on a new line; without specifying its color.void
addTextOnNewLine(IColoredString<T> text)
static <T> ColoredStringList<T>
create()
static <T> ColoredStringList<T>
create(int expectedSize)
void
replaceColor(T old, T new_)
Changes a color in members ofthis
.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Constructor Details
-
Method Details
-
create
- Returns:
- A fresh empty instance.
-
create
- Parameters:
expectedSize
-- Returns:
- A fresh empty instance.
-
addText
Appendstext
tothis
, without specifying its color.- Parameters:
text
- the text to append
-
addText
Appendstext
tothis
.- Parameters:
text
- the text to append
-
addColoredText
Appends colored text tothis
.- Parameters:
text
- the text to append
-
addTextOnNewLine
Appends text tothis
, on a new line; without specifying its color.- Parameters:
text
- the text to append
-
addTextOnNewLine
-
addColoredTextOnNewLine
Appends colored text tothis
.- Parameters:
text
- the text to append
-
addOnNewLine
Addstexts
tothis
, starting a new line for the first one.- Parameters:
texts
- the Collection of objects extending IColoredString to append
-
addAllText
Contrary toCollection.addAll(Collection)
, this method appends text to the current text, without inserting new lines.- Parameters:
texts
- the Collection of objects extending IColoredString to append
-
addEmptyLine
Jumps a line. -
replaceColor
Changes a color in members ofthis
.- Parameters:
old
- The color to replace. Can benull
.
-