Search in sources :

Example 1 with VerticalPosition

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);
    });
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) IntStream(java.util.stream.IntStream) JfxTextUtils(org.lttng.scope.common.jfx.JfxTextUtils) StateRectangle(org.lttng.scope.views.timeline.widgets.timegraph.StateRectangle) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) OverrunStyle(javafx.scene.control.OverrunStyle) FutureTask(java.util.concurrent.FutureTask) Function(java.util.function.Function) TimeGraphModelStateProvider(com.efficios.jabberwocky.views.timegraph.model.provider.states.TimeGraphModelStateProvider) Objects.requireNonNull(java.util.Objects.requireNonNull) TimeGraphTreeRender(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender) TimeGraphWidget(org.lttng.scope.views.timeline.widgets.timegraph.TimeGraphWidget) Color(javafx.scene.paint.Color) VerticalPosition(org.lttng.scope.views.timeline.widgets.timegraph.VerticalPosition) Node(javafx.scene.Node) Collection(java.util.Collection) Font(javafx.scene.text.Font) Group(javafx.scene.Group) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Stream(java.util.stream.Stream) JfxUtils(org.lttng.scope.common.jfx.JfxUtils) TimeGraphStateRender(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender) Collections(java.util.Collections) DebugOptions(org.lttng.scope.views.timeline.DebugOptions) StateRectangle(org.lttng.scope.views.timeline.widgets.timegraph.StateRectangle) Node(javafx.scene.Node) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) TimeGraphStateRender(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender)

Example 2 with VerticalPosition

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);
    });
}
Also used : Line(javafx.scene.shape.Line) TimeRange(com.efficios.jabberwocky.common.TimeRange) Platform(javafx.application.Platform) Line(javafx.scene.shape.Line) Nullable(org.jetbrains.annotations.Nullable) JfxUtils(org.lttng.scope.common.jfx.JfxUtils) VerticalPosition(org.lttng.scope.views.timeline.widgets.timegraph.VerticalPosition) FutureTask(java.util.concurrent.FutureTask) TimeGraphTreeRender(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender) Group(javafx.scene.Group) LinkedList(java.util.LinkedList) TimeGraphWidget(org.lttng.scope.views.timeline.widgets.timegraph.TimeGraphWidget) DoubleStream(java.util.stream.DoubleStream) LinkedList(java.util.LinkedList)

Aggregations

TimeRange (com.efficios.jabberwocky.common.TimeRange)2 TimeGraphTreeRender (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender)2 FutureTask (java.util.concurrent.FutureTask)2 Platform (javafx.application.Platform)2 Group (javafx.scene.Group)2 Nullable (org.jetbrains.annotations.Nullable)2 JfxUtils (org.lttng.scope.common.jfx.JfxUtils)2 TimeGraphWidget (org.lttng.scope.views.timeline.widgets.timegraph.TimeGraphWidget)2 VerticalPosition (org.lttng.scope.views.timeline.widgets.timegraph.VerticalPosition)2 TimeGraphModelStateProvider (com.efficios.jabberwocky.views.timegraph.model.provider.states.TimeGraphModelStateProvider)1 TimeGraphStateRender (com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender)1 TimeGraphTreeElement (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Objects (java.util.Objects)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Function (java.util.function.Function)1 Logger (java.util.logging.Logger)1