use of org.lttng.scope.views.timeline.widgets.timegraph.VerticalPosition in project lttng-scope by lttng.
the class TimeGraphStateLayer method drawContents.
@Override
public void drawContents(TimeGraphTreeRender treeRender, TimeRange timeRange, VerticalPosition vPos, @Nullable FutureTask<?> task) {
final long resolution = Math.max(1, Math.round(getWidget().getCurrentNanosPerPixel()));
final List<TimeGraphTreeElement> allTreeElements = treeRender.getAllTreeElements();
final int nbElements = allTreeElements.size();
final int entriesToPrefetch = getWidget().getDebugOptions().entryPadding.get();
final int topEntry = Math.max(0, TimeGraphWidget.paneYPosToEntryListIndex(vPos.fTopPos, TimeGraphWidget.ENTRY_HEIGHT) - entriesToPrefetch);
final int bottomEntry = Math.min(nbElements, TimeGraphWidget.paneYPosToEntryListIndex(vPos.fBottomPos, TimeGraphWidget.ENTRY_HEIGHT) + entriesToPrefetch);
LOGGER.finest(() -> "topEntry=" + topEntry + ", bottomEntry=" + bottomEntry);
List<TimeGraphStateRender> stateRenders = allTreeElements.subList(topEntry, bottomEntry).stream().map(treeElem -> fStateProvider.getStateRender(treeElem, timeRange, resolution, task)).collect(Collectors.toList());
if (task != null && task.isCancelled()) {
return;
}
Collection<StateRectangle> stateRectangles = prepareStateRectangles(stateRenders, topEntry);
Node statesLayerContents = prepareTimeGraphStatesContents(stateRectangles);
Node labelsLayerContents = prepareTimeGrahLabelsContents(stateRectangles, fWindowRange);
/*
* Go over all state rectangles, and bring the "multi-state"
* ones to the front, to be sure they show on top of the others.
* Note we cannot do the forEach() as part of the stream, that
* would throw a ConcurrentModificationException.
*/
((Group) statesLayerContents).getChildren().stream().map(node -> (StateRectangle) node).filter(rect -> (rect.getStateInterval().isMultiState())).collect(Collectors.toList()).forEach(Node::toFront);
Platform.runLater(() -> {
getParentGroup().getChildren().clear();
getLabelGroup().getChildren().clear();
getParentGroup().getChildren().add(statesLayerContents);
getLabelGroup().getChildren().add(labelsLayerContents);
});
}
use of org.lttng.scope.views.timeline.widgets.timegraph.VerticalPosition in project lttng-scope by lttng.
the class TimeGraphBackgroundLayer method drawContents.
@Override
public void drawContents(TimeGraphTreeRender treeRender, TimeRange timeRange, VerticalPosition vPos, @Nullable FutureTask<?> task) {
final double entryHeight = TimeGraphWidget.ENTRY_HEIGHT;
final int entriesToPrefetch = getWidget().getDebugOptions().entryPadding.get();
int totalNbEntries = treeRender.getAllTreeElements().size();
final double timeGraphWidth = getWidget().getTimeGraphPane().getWidth();
final double paintTopPos = Math.max(0.0, vPos.fTopPos - entriesToPrefetch * entryHeight);
final double paintBottomPos = Math.min(vPos.fBottomPos + entriesToPrefetch * entryHeight, /*
* If there are less tree elements than can fill the window,
* stop at the end of the real tree elements.
*/
totalNbEntries * entryHeight);
LinkedList<Line> lines = new LinkedList<>();
DoubleStream.iterate((entryHeight / 2), y -> y + entryHeight).filter(y -> y > paintTopPos).peek(y -> {
Line line = new Line(0, y, timeGraphWidth, y);
line.setStroke(TimeGraphWidget.BACKGROUD_LINES_COLOR);
line.setStrokeWidth(1.0);
lines.add(line);
}).allMatch(y -> y < paintBottomPos);
// we don't want it.
if (!lines.isEmpty()) {
lines.removeLast();
}
Platform.runLater(() -> {
getParentGroup().getChildren().clear();
getParentGroup().getChildren().addAll(lines);
});
}
Aggregations