Package org.fxmisc.richtext.model
Interface SegmentOps<SEG,S>
-
- Type Parameters:
SEG- The segment typeS- The style type for the segment
- All Known Subinterfaces:
TextOps<SEG,S>
- All Known Implementing Classes:
NodeSegmentOpsBase,SegmentOpsBase,TextOpsBase
public interface SegmentOps<SEG,S>Defines the operations which are supported on a specific segment type.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description charcharAt(SEG seg, int index)SEGcreateEmptySeg()Creates an empty segment.static <LSeg,RSeg,Style>
SegmentOps<Either<LSeg,RSeg>,Style>either(SegmentOps<LSeg,Style> lOps, SegmentOps<RSeg,Style> rOps)Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue islOps' segment type and whoserightvalue isrOps' segment type.static <LSeg,RSeg,Style>
SegmentOps<Either<LSeg,RSeg>,Style>either(SegmentOps<LSeg,Style> lOps, SegmentOps<RSeg,Style> rOps, java.util.function.BiFunction<Style,Style,java.util.Optional<Style>> mergeStyle)Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue islOps' segment type and whoserightvalue isrOps' segment type.static <LSeg,LStyle,RSeg,RStyle>
SegmentOps<Either<LSeg,RSeg>,Either<LStyle,RStyle>>eitherStyles(SegmentOps<LSeg,LStyle> lOps, SegmentOps<RSeg,RStyle> rOps)java.lang.StringgetText(SEG seg)java.util.Optional<SEG>joinSeg(SEG currentSeg, SEG nextSeg)Joins two consecutive segments together into one orOptional.empty()if they cannot be joined.default java.util.Optional<S>joinStyle(S currentStyle, S nextStyle)Joins two consecutive styles together into one orOptional.empty()if they cannot be joined.intlength(SEG seg)default <R> SegmentOps<Either<SEG,R>,S>or(SegmentOps<R,S> rOps)Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue is this segment type and whoserightvalue isrOps' segment type.default <RSeg,RStyle>
SegmentOps<Either<SEG,RSeg>,Either<S,RStyle>>orStyled(SegmentOps<RSeg,RStyle> rOps)static <S> TextOps<java.lang.String,S>styledTextOps()Creates aTextOpsspecified for aStringsegment that never merges consecutive stylesstatic <S> TextOps<java.lang.String,S>styledTextOps(java.util.function.BiFunction<S,S,java.util.Optional<S>> mergeStyle)Creates aTextOpsspecified for aStringSEGsubSequence(SEG seg, int start)SEGsubSequence(SEG seg, int start, int end)
-
-
-
Method Detail
-
length
int length(SEG seg)
-
charAt
char charAt(SEG seg, int index)
-
getText
java.lang.String getText(SEG seg)
-
joinSeg
java.util.Optional<SEG> joinSeg(SEG currentSeg, SEG nextSeg)
Joins two consecutive segments together into one orOptional.empty()if they cannot be joined.
-
joinStyle
default java.util.Optional<S> joinStyle(S currentStyle, S nextStyle)
Joins two consecutive styles together into one orOptional.empty()if they cannot be joined. By default, returnsOptional.empty().
-
createEmptySeg
SEG createEmptySeg()
Creates an empty segment. This method should return the same object for better performance and memory usage.
-
styledTextOps
static <S> TextOps<java.lang.String,S> styledTextOps()
Creates aTextOpsspecified for aStringsegment that never merges consecutive styles
-
styledTextOps
static <S> TextOps<java.lang.String,S> styledTextOps(java.util.function.BiFunction<S,S,java.util.Optional<S>> mergeStyle)
Creates aTextOpsspecified for aString
-
or
default <R> SegmentOps<Either<SEG,R>,S> or(SegmentOps<R,S> rOps)
Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue is this segment type and whoserightvalue isrOps' segment type.
-
orStyled
default <RSeg,RStyle> SegmentOps<Either<SEG,RSeg>,Either<S,RStyle>> orStyled(SegmentOps<RSeg,RStyle> rOps)
-
eitherStyles
static <LSeg,LStyle,RSeg,RStyle> SegmentOps<Either<LSeg,RSeg>,Either<LStyle,RStyle>> eitherStyles(SegmentOps<LSeg,LStyle> lOps, SegmentOps<RSeg,RStyle> rOps)
Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue islOps' segment type and whoserightvalue isrOps' segment type, and that specifies its style type to beEitherwhoseleftvalue islOps' style type and whoserightvalue isrOps' style type. Note: consecutive styles will not be merged.
-
either
static <LSeg,RSeg,Style> SegmentOps<Either<LSeg,RSeg>,Style> either(SegmentOps<LSeg,Style> lOps, SegmentOps<RSeg,Style> rOps)
Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue islOps' segment type and whoserightvalue isrOps' segment type. Note: consecutive styles will not be merged.
-
either
static <LSeg,RSeg,Style> SegmentOps<Either<LSeg,RSeg>,Style> either(SegmentOps<LSeg,Style> lOps, SegmentOps<RSeg,Style> rOps, java.util.function.BiFunction<Style,Style,java.util.Optional<Style>> mergeStyle)
Returns aSegmentOpsthat specifies its segment type to be anEitherwhoseleftvalue islOps' segment type and whoserightvalue isrOps' segment type.
-
-