Package org.fxmisc.richtext.model
Interface StyleSpans<S>
-
- Type Parameters:
S
- the style type
- All Superinterfaces:
java.lang.Iterable<StyleSpan<S>>
,TwoDimensional
public interface StyleSpans<S> extends java.lang.Iterable<StyleSpan<S>>, TwoDimensional
Essentially, a list ofStyleSpan
objects.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.model.TwoDimensional
TwoDimensional.Bias, TwoDimensional.Position
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default StyleSpans<S>
append(StyleSpan<S> span)
Appends the given style to the end of the list ofStyleSpan
.default StyleSpans<S>
append(S style, int length)
Appends the given style to the end of the list ofStyleSpan
.default StyleSpans<S>
concat(StyleSpans<S> that)
boolean
equals(java.lang.Object other)
TwoStyleSpans
objects are considered equal if they contain equal number ofStyleSpan
s and theStyleSpan
s are pairwise equal.int
getSpanCount()
StyleSpan<S>
getStyleSpan(int index)
default java.util.Iterator<StyleSpan<S>>
iterator()
int
length()
default StyleSpans<S>
mapStyles(java.util.function.UnaryOperator<S> mapper)
Returns a newStyleSpans
object that has the same total length as this StyleSpans and style of every span is mapped by the given function.default StyleSpans<S>
overlay(StyleSpans<S> that, java.util.function.BiFunction<? super S,? super S,? extends S> f)
Applies the given bifunctionf
to this object'sStyleSpan
objects andthat
StyleSpan
objects and stores the result in the returnedStyleSpans
object.default StyleSpans<S>
prepend(StyleSpan<S> span)
Prepends the given style to the start of the list ofStyleSpan
.default StyleSpans<S>
prepend(S style, int length)
Prepends the given style to the start of the list ofStyleSpan
.static <S> StyleSpans<S>
singleton(StyleSpan<S> span)
Creates aStyleSpans
object that only contains oneStyleSpan
object.static <S> StyleSpans<S>
singleton(S style, int length)
Creates aStyleSpans
object that only contains oneStyleSpan
object.default java.util.stream.Stream<StyleSpan<S>>
stream()
Returns a stream of this list'StyleSpan
objects.default java.util.stream.Stream<S>
styleStream()
Returns a stream of just this list ofStyleSpan
's styles.default StyleSpans<S>
subView(int from, int to)
Same asList.subList(int, int)
default StyleSpans<S>
subView(TwoDimensional.Position from, TwoDimensional.Position to)
Same asList.subList(int, int)
, except that the arguments are two dimensional.-
Methods inherited from interface org.fxmisc.richtext.model.TwoDimensional
offsetToPosition, position
-
-
-
-
Method Detail
-
singleton
static <S> StyleSpans<S> singleton(S style, int length)
Creates aStyleSpans
object that only contains oneStyleSpan
object.
-
singleton
static <S> StyleSpans<S> singleton(StyleSpan<S> span)
Creates aStyleSpans
object that only contains oneStyleSpan
object.
-
length
int length()
-
getSpanCount
int getSpanCount()
-
equals
boolean equals(java.lang.Object other)
TwoStyleSpans
objects are considered equal if they contain equal number ofStyleSpan
s and theStyleSpan
s are pairwise equal.- Overrides:
equals
in classjava.lang.Object
-
iterator
default java.util.Iterator<StyleSpan<S>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<S>
-
append
default StyleSpans<S> append(S style, int length)
Appends the given style to the end of the list ofStyleSpan
.
-
append
default StyleSpans<S> append(StyleSpan<S> span)
Appends the given style to the end of the list ofStyleSpan
.
-
prepend
default StyleSpans<S> prepend(S style, int length)
Prepends the given style to the start of the list ofStyleSpan
.
-
prepend
default StyleSpans<S> prepend(StyleSpan<S> span)
Prepends the given style to the start of the list ofStyleSpan
.
-
subView
default StyleSpans<S> subView(int from, int to)
Same asList.subList(int, int)
-
subView
default StyleSpans<S> subView(TwoDimensional.Position from, TwoDimensional.Position to)
Same asList.subList(int, int)
, except that the arguments are two dimensional.
-
concat
default StyleSpans<S> concat(StyleSpans<S> that)
-
mapStyles
default StyleSpans<S> mapStyles(java.util.function.UnaryOperator<S> mapper)
Returns a newStyleSpans
object that has the same total length as this StyleSpans and style of every span is mapped by the given function. Adjacent style spans whose style mapped to the same value are merged into one. As a consequence, the returned StyleSpans might have fewer style spans than this StyleSpans.- Parameters:
mapper
- function to calculate new style- Returns:
- StyleSpans with replaced styles.
-
overlay
default StyleSpans<S> overlay(StyleSpans<S> that, java.util.function.BiFunction<? super S,? super S,? extends S> f)
Applies the given bifunctionf
to this object'sStyleSpan
objects andthat
StyleSpan
objects and stores the result in the returnedStyleSpans
object.
-
styleStream
default java.util.stream.Stream<S> styleStream()
Returns a stream of just this list ofStyleSpan
's styles.
-
-