Search in sources :

Example 1 with TimeRange

use of com.efficios.jabberwocky.common.TimeRange in project lttng-scope by lttng.

the class TimeGraphWidget method redrawSelection.

private void redrawSelection() {
    TimeRange selectionRange = getViewContext().getSelectionTimeRange();
    drawSelection(selectionRange);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange)

Example 2 with TimeRange

use of com.efficios.jabberwocky.common.TimeRange in project lttng-scope by lttng.

the class TimeGraphStateLayer method prepareTimeGrahLabelsContents.

private Node prepareTimeGrahLabelsContents(Collection<StateRectangle> stateRectangles, TimeRange windowRange) {
    double minX = getWidget().timestampToPaneXPos(windowRange.getStartTime());
    final String ellipsisStr = DebugOptions.ELLIPSIS_STRING;
    final double ellipsisWidth = getWidget().getDebugOptions().getEllipsisWidth();
    final Font textFont = getWidget().getDebugOptions().stateLabelFont.get();
    final OverrunStyle overrunStyle = OverrunStyle.ELLIPSIS;
    final Color textColor = Color.WHITE;
    /* Requires a ~2 pixels adjustment to be centered on the states */
    final double yOffset = TimeGraphWidget.ENTRY_HEIGHT / 2.0 + 2.0;
    Collection<Node> texts = stateRectangles.stream().filter(stateRect -> stateRect.getWidth() > ellipsisWidth).filter(stateRect -> stateRect.getStateInterval().getLabel() != null).map(stateRect -> {
        String labelText = requireNonNull(stateRect.getStateInterval().getLabel());
        /* A small offset looks better here */
        double textX = Math.max(minX, stateRect.getX()) + 4.0;
        double textY = stateRect.getY() + yOffset;
        double rectEndX = stateRect.getX() + stateRect.getWidth();
        double minWidth = rectEndX - textX;
        String ellipsedText = JfxTextUtils.computeClippedText(textFont, labelText, minWidth, overrunStyle, ellipsisStr);
        if (ellipsedText.equals(ellipsisStr)) {
            return null;
        }
        Text text = new Text(textX, textY, ellipsedText);
        text.setFont(textFont);
        text.setFill(textColor);
        return text;
    }).filter(Objects::nonNull).collect(Collectors.toList());
    return new Group(texts);
}
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) OverrunStyle(javafx.scene.control.OverrunStyle) Group(javafx.scene.Group) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Text(javafx.scene.text.Text) Font(javafx.scene.text.Font)

Example 3 with TimeRange

use of com.efficios.jabberwocky.common.TimeRange 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 4 with TimeRange

use of com.efficios.jabberwocky.common.TimeRange 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 5 with TimeRange

use of com.efficios.jabberwocky.common.TimeRange in project lttng-scope by lttng.

the class TimeGraphWidgetInitTest method testInitialPosition.

/**
 * Test that the initial visible position of both the control and the view
 * are as expected by the trace's configuration.
 */
@Test
public void testInitialPosition() {
    repaint();
    TimeGraphWidget viewer = getWidget();
    final long expectedStart = StubTrace.FULL_TRACE_START_TIME;
    final long expectedEnd = StubTrace.FULL_TRACE_END_TIME;
    /* Check the control */
    TimeRange visibleRange = viewer.getControl().getViewContext().getVisibleTimeRange();
    assertEquals(expectedStart, visibleRange.getStartTime());
    assertEquals(expectedEnd, visibleRange.getEndTime());
    /* Check the view itself */
    TimeRange timeRange = viewer.getTimeGraphEdgeTimestamps(null);
    assertEquals(expectedStart, timeRange.getStartTime());
    /*
         * The timegraph may not show the whole range if the window is small.
         * In any case, its end time should never be greater than the trace's end time.
         */
    assertThat(timeRange.getEndTime(), lessThanOrEqualTo(expectedEnd));
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) Test(org.junit.Test)

Aggregations

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