Search in sources :

Example 1 with TimeGraphTreeElement

use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement in project lttng-scope by lttng.

the class TimeGraphArrowLayer method prepareArrows.

private Collection<Arrow> prepareArrows(TimeGraphTreeRender treeRender, TimeGraphArrowRender arrowRender, Paint arrowStroke) {
    final double entryHeight = TimeGraphWidget.ENTRY_HEIGHT;
    Collection<Arrow> arrows = arrowRender.getArrows().stream().map(timeGraphArrow -> {
        TimeGraphTreeElement startTreeElem = timeGraphArrow.getStartEvent().getTreeElement();
        TimeGraphTreeElement endTreeElem = timeGraphArrow.getEndEvent().getTreeElement();
        long startTimestamp = timeGraphArrow.getStartEvent().getTimestamp();
        long endTimestamp = timeGraphArrow.getEndEvent().getTimestamp();
        // FIXME Build and use a hashmap instead for indexes
        int startIndex = treeRender.getAllTreeElements().indexOf(startTreeElem);
        int endIndex = treeRender.getAllTreeElements().indexOf(endTreeElem);
        if (startIndex == -1 || endIndex == -1) {
            /* We shouldn't have received this... */
            return null;
        }
        double startX = getWidget().timestampToPaneXPos(startTimestamp);
        double endX = getWidget().timestampToPaneXPos(endTimestamp);
        double startY = startIndex * entryHeight + entryHeight / 2;
        double endY = endIndex * entryHeight + entryHeight / 2;
        Arrow arrow = new Arrow(startX, startY, endX, endY);
        arrow.setStroke(arrowStroke);
        return arrow;
    }).filter(Objects::nonNull).collect(Collectors.toList());
    return arrows;
}
Also used : Arrow(org.lttng.scope.common.jfx.Arrow) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) Paint(javafx.scene.paint.Paint)

Example 2 with TimeGraphTreeElement

use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement 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 3 with TimeGraphTreeElement

use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement in project lttng-scope by lttng.

the class StubModelStateProvider method getStateRender.

@Override
public TimeGraphStateRender getStateRender(TimeGraphTreeElement treeElement, TimeRange timeRange, long resolution, @Nullable FutureTask<?> task) {
    if (treeElement == StubModelProvider.ROOT_ELEMENT) {
        return TimeGraphStateRender.EMPTY_RENDER;
    }
    int entryIndex = Integer.valueOf(treeElement.getName().substring(StubModelProvider.ENTRY_NAME_PREFIX.length()));
    long stateLength = entryIndex * DURATION_FACTOR;
    List<TimeGraphStateInterval> intervals = LongStream.iterate(timeRange.getStartTime(), i -> i + stateLength).limit((timeRange.getDuration() / stateLength) + 1).mapToObj(startTime -> {
        long endTime = startTime + stateLength - 1;
        StateDefinition stateDef = getNextStateDef();
        return new BasicTimeGraphStateInterval(startTime, endTime, treeElement, stateDef, stateDef.getName(), Collections.emptyMap());
    }).collect(Collectors.toList());
    return new TimeGraphStateRender(timeRange, treeElement, intervals);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) LongStream(java.util.stream.LongStream) Iterator(java.util.Iterator) TimeGraphStateInterval(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateInterval) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) FutureTask(java.util.concurrent.FutureTask) ColorDefinition(com.efficios.jabberwocky.views.common.ColorDefinition) Collectors(java.util.stream.Collectors) Iterators(com.google.common.collect.Iterators) TimeGraphModelStateProvider(com.efficios.jabberwocky.views.timegraph.model.provider.states.TimeGraphModelStateProvider) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) StateDefinition(com.efficios.jabberwocky.views.timegraph.model.render.StateDefinition) ImmutableList(com.google.common.collect.ImmutableList) LineThickness(com.efficios.jabberwocky.views.timegraph.model.render.LineThickness) TimeGraphStateRender(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender) BasicTimeGraphStateInterval(com.efficios.jabberwocky.views.timegraph.model.render.states.BasicTimeGraphStateInterval) Collections(java.util.Collections) StateDefinition(com.efficios.jabberwocky.views.timegraph.model.render.StateDefinition) TimeGraphStateInterval(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateInterval) BasicTimeGraphStateInterval(com.efficios.jabberwocky.views.timegraph.model.render.states.BasicTimeGraphStateInterval) BasicTimeGraphStateInterval(com.efficios.jabberwocky.views.timegraph.model.render.states.BasicTimeGraphStateInterval) TimeGraphStateRender(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender)

Example 4 with TimeGraphTreeElement

use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement in project lttng-scope by lttng.

the class StubModelArrowProvider1 method getArrowRender.

@Override
public TimeGraphArrowRender getArrowRender(TimeGraphTreeRender treeRender, TimeRange timeRange, @Nullable FutureTask<?> task) {
    TimeGraphArrowSeries series = getArrowSeries();
    List<TimeGraphTreeElement> treeElems = treeRender.getAllTreeElements();
    /* Draw 3 arrows total */
    TimeGraphEvent startEvent = new TimeGraphEvent(ts(timeRange, 0.1), treeElems.get(0));
    TimeGraphEvent endEvent = new TimeGraphEvent(ts(timeRange, 0.3), treeElems.get(5));
    TimeGraphArrow arrow1 = new TimeGraphArrow(startEvent, endEvent, series);
    startEvent = new TimeGraphEvent(ts(timeRange, 0.2), treeElems.get(3));
    endEvent = new TimeGraphEvent(ts(timeRange, 0.5), treeElems.get(12));
    TimeGraphArrow arrow2 = new TimeGraphArrow(startEvent, endEvent, series);
    startEvent = new TimeGraphEvent(ts(timeRange, 0.6), treeElems.get(15));
    endEvent = new TimeGraphEvent(ts(timeRange, 0.8), treeElems.get(2));
    TimeGraphArrow arrow3 = new TimeGraphArrow(startEvent, endEvent, series);
    List<TimeGraphArrow> arrows = ImmutableList.of(arrow1, arrow2, arrow3);
    return new TimeGraphArrowRender(timeRange, arrows);
}
Also used : TimeGraphArrowSeries(com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrowSeries) TimeGraphEvent(com.efficios.jabberwocky.views.timegraph.model.render.TimeGraphEvent) TimeGraphArrowRender(com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrowRender) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) TimeGraphArrow(com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrow)

Example 5 with TimeGraphTreeElement

use of com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement in project lttng-scope by lttng.

the class StubModelArrowProvider2 method getArrowRender.

@Override
public TimeGraphArrowRender getArrowRender(TimeGraphTreeRender treeRender, TimeRange timeRange, @Nullable FutureTask<?> task) {
    TimeGraphArrowSeries series = getArrowSeries();
    List<TimeGraphTreeElement> treeElems = treeRender.getAllTreeElements();
    /* Draw 2 arrows total */
    TimeGraphEvent startEvent = new TimeGraphEvent(ts(timeRange, 0.3), treeElems.get(6));
    TimeGraphEvent endEvent = new TimeGraphEvent(ts(timeRange, 0.8), treeElems.get(4));
    TimeGraphArrow arrow1 = new TimeGraphArrow(startEvent, endEvent, series);
    startEvent = new TimeGraphEvent(ts(timeRange, 0.5), treeElems.get(10));
    endEvent = new TimeGraphEvent(ts(timeRange, 0.6), treeElems.get(7));
    TimeGraphArrow arrow2 = new TimeGraphArrow(startEvent, endEvent, series);
    List<TimeGraphArrow> arrows = ImmutableList.of(arrow1, arrow2);
    return new TimeGraphArrowRender(timeRange, arrows);
}
Also used : TimeGraphArrowSeries(com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrowSeries) TimeGraphEvent(com.efficios.jabberwocky.views.timegraph.model.render.TimeGraphEvent) TimeGraphArrowRender(com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrowRender) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) TimeGraphArrow(com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrow)

Aggregations

TimeGraphTreeElement (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement)6 TimeRange (com.efficios.jabberwocky.common.TimeRange)2 TimeGraphModelStateProvider (com.efficios.jabberwocky.views.timegraph.model.provider.states.TimeGraphModelStateProvider)2 TimeGraphEvent (com.efficios.jabberwocky.views.timegraph.model.render.TimeGraphEvent)2 TimeGraphArrow (com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrow)2 TimeGraphArrowRender (com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrowRender)2 TimeGraphArrowSeries (com.efficios.jabberwocky.views.timegraph.model.render.arrows.TimeGraphArrowSeries)2 TimeGraphStateRender (com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender)2 Collections (java.util.Collections)2 List (java.util.List)2 FutureTask (java.util.concurrent.FutureTask)2 Collectors (java.util.stream.Collectors)2 Nullable (org.jetbrains.annotations.Nullable)2 ColorDefinition (com.efficios.jabberwocky.views.common.ColorDefinition)1 LineThickness (com.efficios.jabberwocky.views.timegraph.model.render.LineThickness)1 StateDefinition (com.efficios.jabberwocky.views.timegraph.model.render.StateDefinition)1 BasicTimeGraphStateInterval (com.efficios.jabberwocky.views.timegraph.model.render.states.BasicTimeGraphStateInterval)1 TimeGraphStateInterval (com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateInterval)1 TimeGraphTreeRender (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender)1 ImmutableList (com.google.common.collect.ImmutableList)1