Search in sources :

Example 1 with Tuple2

use of org.reactfx.util.Tuple2 in project RichTextFX by FXMisc.

the class ParagraphBox method stationaryIndices.

public EventStream<Either<Tuple2<Point2D, Integer>, Object>> stationaryIndices(Duration delay) {
    EventStream<Either<Point2D, Void>> stationaryEvents = new MouseStationaryHelper(this).events(delay);
    EventStream<Tuple2<Point2D, Integer>> hits = stationaryEvents.filterMap(Either::asLeft).filterMap(p -> {
        OptionalInt charIdx = hit(p).getCharacterIndex();
        if (charIdx.isPresent()) {
            return Optional.of(t(p, charIdx.getAsInt()));
        } else {
            return Optional.empty();
        }
    });
    EventStream<?> stops = stationaryEvents.filter(Either::isRight).map(Either::getRight);
    return hits.or(stops);
}
Also used : MouseStationaryHelper(org.fxmisc.richtext.event.MouseStationaryHelper) Tuple2(org.reactfx.util.Tuple2) Either(org.reactfx.util.Either) OptionalInt(java.util.OptionalInt)

Aggregations

OptionalInt (java.util.OptionalInt)1 MouseStationaryHelper (org.fxmisc.richtext.event.MouseStationaryHelper)1 Either (org.reactfx.util.Either)1 Tuple2 (org.reactfx.util.Tuple2)1