T
- The type of colorspublic static class IColoredString.Impl<T> extends Object implements IColoredString<T>
IColoredString
.IColoredString.Bucket<T>, IColoredString.Impl<T>
Modifier and Type | Field and Description |
---|---|
protected LinkedList<IColoredString.Bucket<T>> |
fragments |
Constructor and Description |
---|
Impl()
An empty instance.
|
Impl(String text,
T color)
An instance initially containing
text (with color ). |
Modifier and Type | Method and Description |
---|---|
void |
append(char c,
T color)
Mutates
this by appending c to it. |
void |
append(IColoredString.Bucket<T> bucket) |
void |
append(IColoredString<T> other)
Mutates
this by appending other to it. |
void |
append(String text,
T color)
Mutates
this by appending text to it. |
void |
appendFloat(float f,
T color)
Mutates
this by appending f to it. |
void |
appendInt(int i,
T color)
Mutates
this by appending i to it. |
void |
clear()
Empties
this . |
T |
colorAt(int index) |
static <T> IColoredString.Impl<T> |
create()
A static constructor, to avoid having to write
<T> in the
caller. |
static <T> IColoredString.Impl<T> |
create(String s)
A convenience method, equivalent to
create(s, null) . |
static <T> IColoredString.Impl<T> |
create(String s,
T t)
A static constructor, to avoid having to write
<T> in the
caller. |
protected static boolean |
equals(Object o1,
Object o2) |
boolean |
isEmpty() |
Iterator<IColoredString.Bucket<T>> |
iterator() |
IColoredString<T> |
justify(int width)
This method does NOT guarantee that the result's length is
width . |
T |
lastColor()
This method is typically more efficient than
IColoredString.colorAt(int) . |
int |
length() |
String |
present() |
String |
presentWithMarkup(IMarkup<T> markup)
Given some way of converting from a T value to an in-line markup tag, returns a string representation of
this IColoredString with in-line markup representing colors.
|
void |
setLength(int len)
Deletes all content after index
len (if any). |
String |
toString() |
List<IColoredString<T>> |
wrap(int width) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected final LinkedList<IColoredString.Bucket<T>> fragments
public Impl()
public static <T> IColoredString.Impl<T> create()
<T>
in the
caller.new Impl(s, t)
.public static <T> IColoredString.Impl<T> create(String s)
create(s, null)
.s
- create(s, null)
public static <T> IColoredString.Impl<T> create(String s, T t)
<T>
in the
caller.new Impl(s, t)
.public void append(char c, T color)
IColoredString
this
by appending c
to it.append
in interface IColoredString<T>
c
- The text to append.color
- text
's color. Or null
to let the panel decide.public void append(String text, T color)
IColoredString
this
by appending text
to it. Does nothing if
text
is null
.append
in interface IColoredString<T>
text
- The text to append.color
- text
's color. Or null
to let the panel decide.public void appendInt(int i, T color)
IColoredString
this
by appending i
to it.appendInt
in interface IColoredString<T>
i
- The int to append.color
- text
's color. Or null
to let the panel decide.public void appendFloat(float f, T color)
IColoredString
this
by appending f
to it.appendFloat
in interface IColoredString<T>
f
- The float to append.color
- text
's color. Or null
to let the panel decide.public void append(IColoredString<T> other)
IColoredString
this
by appending other
to it.append
in interface IColoredString<T>
public void append(IColoredString.Bucket<T> bucket)
public void setLength(int len)
IColoredString
len
(if any).setLength
in interface IColoredString<T>
public List<IColoredString<T>> wrap(int width)
wrap
in interface IColoredString<T>
width
- A positive integerthis
split in pieces that would fit in a display with
width
columns (if all words in this
are smaller
or equal in length to width
, otherwise wrapping will fail
for these words).public IColoredString<T> justify(int width)
IColoredString
width
.
It is impossible to do correct justifying if this
's length is
greater than width
or if this
has no space character.justify
in interface IColoredString<T>
this
where spaces have been introduced
in-between words, so that this
's length is as close as
possible to width
. Or this
itself if unaffected.public void clear()
IColoredString
this
.clear
in interface IColoredString<T>
public int length()
length
in interface IColoredString<T>
public boolean isEmpty()
isEmpty
in interface IColoredString<T>
true
if IColoredString.present()
is ""
.public T lastColor()
IColoredString
IColoredString.colorAt(int)
.lastColor
in interface IColoredString<T>
public T colorAt(int index)
colorAt
in interface IColoredString<T>
index
, if any.public String present()
present
in interface IColoredString<T>
this
represents.public String presentWithMarkup(IMarkup<T> markup)
presentWithMarkup
in interface IColoredString<T>
markup
- an IMarkup implementationpublic Iterator<IColoredString.Bucket<T>> iterator()
iterator
in interface Iterable<IColoredString.Bucket<T>>
Copyright © 2012–2016. All rights reserved.