use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender 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 com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender in project lttng-scope by lttng.
the class TimeGraphWidget method paintArea.
/**
* Paint the specified view area.
*
* @param windowRange
* The horizontal position where the visible window currently is
* @param verticalPos
* The vertical position where the visible window currently is
* @param movedHorizontally
* If we have moved horizontally since the last redraw. May be
* used to skip some operations. If you are not sure say "true".
* @param movedVertically
* If we have moved vertically since the last redraw. May be used
* to skip some operations. If you are not sure say "true".
* @param taskSeqNb
* The sequence number of this task, used for logging only
*/
void paintArea(TimeRange windowRange, VerticalPosition verticalPos, boolean movedHorizontally, boolean movedVertically, long taskSeqNb) {
final TimeRange fullTimeGraphRange = getViewContext().getCurrentProjectFullRange();
/*
* Request the needed renders and prepare the corresponding UI objects.
* We may ask for some padding on each side, clamped by the trace's
* start and end.
*/
final long timeRangePadding = Math.round(windowRange.getDuration() * getDebugOptions().renderRangePadding.get());
final long renderingStartTime = Math.max(fullTimeGraphRange.getStartTime(), windowRange.getStartTime() - timeRangePadding);
final long renderingEndTime = Math.min(fullTimeGraphRange.getEndTime(), windowRange.getEndTime() + timeRangePadding);
final TimeRange renderingRange = TimeRange.of(renderingStartTime, renderingEndTime);
/*
* Start a new repaint, display the "loading" overlay. The next
* paint task to finish will put it back to non-visible.
*/
if (getDebugOptions().isLoadingOverlayEnabled.get()) {
fTimeGraphLoadingOverlay.fadeIn();
}
JabberwockyTask<Void> task = new JabberwockyTask<>("Updating Timegraph " + getName(), it -> {
// $NON-NLS-1$
LOGGER.finer(() -> "Starting paint task #" + taskSeqNb);
ITimeGraphModelProvider modelProvider = getControl().getRenderProvider();
TimeGraphTreeRender treeRender = modelProvider.getTreeRender();
if (it.isCancelled()) {
return null;
}
/* Prepare the tree part, if needed */
if (!treeRender.equals(fLatestTreeRender)) {
fLatestTreeRender = treeRender;
fTreeArea.updateTreeContents(treeRender);
}
if (it.isCancelled()) {
return null;
}
/* Paint the background. It's very quick so we can do it every time. */
fBackgroundLayer.drawContents(treeRender, renderingRange, verticalPos, it);
/*
* The state rectangles should be redrawn as soon as we move,
* either horizontally or vertically.
*/
fStateLayer.setWindowRange(windowRange);
fStateLayer.drawContents(treeRender, renderingRange, verticalPos, it);
if (it.isCancelled()) {
return null;
}
/*
* Arrows and drawn events are drawn for the full vertical
* range. Only refetch/repaint them if we moved horizontally.
*/
if (movedHorizontally) {
fArrowLayer.drawContents(treeRender, renderingRange, verticalPos, it);
fDrawnEventLayer.drawContents(treeRender, renderingRange, verticalPos, it);
}
if (it.isCancelled()) {
return null;
}
/* Painting is finished, turn off the loading overlay */
Platform.runLater(() -> {
// $NON-NLS-1$
LOGGER.finest(() -> "fading out overlay");
fTimeGraphLoadingOverlay.fadeOut();
if (fRepaintLatch != null) {
fRepaintLatch.countDown();
}
});
return null;
});
// $NON-NLS-1$
LOGGER.finer(() -> "Queueing task #" + taskSeqNb);
/*
* Attach a listener to the task to receive exceptions thrown within the
* task.
*/
task.exceptionProperty().addListener((obs, oldVal, newVal) -> {
if (newVal != null) {
newVal.printStackTrace();
}
});
fTaskExecutor.schedule(task);
}
use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender 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);
});
}
use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender in project lttng-scope by lttng.
the class TimeGraphDrawnEventLayer method trackEventProvider.
private void trackEventProvider(TimeGraphDrawnEventProvider provider) {
Group newGroup = new Group();
Group oldGroup = fEventProviders.put(provider, newGroup);
if (oldGroup == null) {
Platform.runLater(() -> {
getParentGroup().getChildren().add(newGroup);
});
} else {
/* Remove the old group in case there was already one. */
Platform.runLater(() -> {
getParentGroup().getChildren().remove(oldGroup);
getParentGroup().getChildren().add(newGroup);
});
}
/*
* Add a listener to this provider's "enabled" property, so that when it
* changes from enabled to disabled and vice versa, we update the view
* accordingly.
*/
provider.enabledProperty().addListener((obs, oldValue, newValue) -> {
if (newValue) {
/* The provider was just enabled */
TimeRange timeRange = getWidget().getViewContext().getVisibleTimeRange();
TimeGraphTreeRender treeRender = getWidget().getLatestTreeRender();
// FIXME Use a Task?
paintEventsOfProvider(treeRender, timeRange, provider, null);
} else {
/* Provider was disabled. Clear the children of its group. */
Group group = fEventProviders.get(provider);
if (group == null) {
return;
}
Platform.runLater(() -> group.getChildren().clear());
}
});
getWidget().getTimelineWidgetUpdateTask().forceRedraw();
}
Aggregations