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);
}
Aggregations