All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fxmisc.richtext.model.NodeSegmentOpsBase Maven / Gradle / Ivy

The newest version!
package org.fxmisc.richtext.model;

import java.util.Optional;

/**
 * Properly implements {@link SegmentOps} when implementing a non-text custom object, such as a shape or image,
 * and reduces boilerplate. Developers may want to override {@link #joinSeg(Object, Object)} and
 * {@link #joinStyle(Object, Object)}.
 *
 * @param  type of segment
 * @param  type of style
 */
public abstract class NodeSegmentOpsBase extends SegmentOpsBase {

    public NodeSegmentOpsBase(SEG empty) {
        super(empty);
    }

    @Override
    public char realCharAt(SEG seg, int index) {
        return '\ufffc';
    }

    @Override
    public String realGetText(SEG seg) {
        return "\ufffc";
    }

    @Override
    public SEG realSubSequence(SEG seg, int start, int end) {
        return seg;
    }

    @Override
    public SEG realSubSequence(SEG seg, int start) {
        return seg;
    }

    @Override
    public Optional joinSeg(SEG currentSeg, SEG nextSeg) {
        return Optional.empty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy