List of usage examples for javafx.collections ObservableList stream
default Stream<E> stream()
From source file:org.sleuthkit.autopsy.timeline.ui.detailview.DetailViewPane.java
/** * Observe the list of events that should be highlighted in this view. * * * @param highlightedEvents the ObservableList of events that should be * highlighted in this view. *//*from w w w .ja va 2 s . c om*/ public void setHighLightedEvents(ObservableList<TimeLineEvent> highlightedEvents) { highlightedEvents.addListener((Observable observable) -> { /* * build a predicate that matches events with the same description * as any of the events in highlightedEvents or which are selected */ Predicate<EventNodeBase<?>> highlightPredicate = highlightedEvents.stream() // => events .map(TimeLineEvent::getDescription)// => event descriptions .map(new Function<String, Predicate<EventNodeBase<?>>>() { @Override public Predicate<EventNodeBase<?>> apply(String description) { return eventNode -> StringUtils.equalsIgnoreCase(eventNode.getDescription(), description); } })// => predicates that match strings agains the descriptions of the events in highlightedEvents .reduce(getSelectedNodes()::contains, Predicate::or); // => predicate that matches an of the descriptions or selected nodes getChart().setHighlightPredicate(highlightPredicate); //use this predicate to highlight nodes }); }