Search in sources :

Example 11 with TimeRange

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

Example 12 with TimeRange

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

the class TimeGraphWidgetStatesTest method testStatesResolution.

/**
 * Test a very zoomed-in view, where all state system intervals should be
 * present in the rendered view.
 */
@Test
public void testStatesResolution() {
    repaint();
    /*
         * This width is the maximum number of nanoseconds the time range can
         * have to have a query resolution of 1.
         */
    double viewWidth = getTimeGraphWidth();
    long duration = (long) (viewWidth / 2.0) * fTargetResolution;
    long end = Math.min(START_TIME + duration, StubTrace.FULL_TRACE_END_TIME);
    TimeRange visibleRange = TimeRange.of(START_TIME, end);
    renderRange(visibleRange);
    Collection<StateRectangle> renderedStates = getWidget().getRenderedStateRectangles();
    /* Check the states for each of the first 10 tree entries. */
    for (int i = 1; i <= 10; i++) {
        int entryIndex = i;
        Collection<StateRectangle> entryStates = renderedStates.stream().filter(rect -> rect.getStateInterval().getTreeElement().getName().equals(StubModelProvider.ENTRY_NAME_PREFIX + entryIndex)).sorted(Comparator.comparingLong(rect -> rect.getStateInterval().getStartEvent().getTimestamp())).collect(Collectors.toList());
        /* There should be no duplicates */
        assertEquals(entryStates.stream().distinct().count(), entryStates.size());
        /*
             * Check the minimum number of states. There might be more than
             * expected due to prefetching on each side ...
             */
        int expectedSize = (int) (duration / (entryIndex * StubModelStateProvider.DURATION_FACTOR));
        assertThat("nb of states", entryStates.size(), greaterThanOrEqualTo(expectedSize));
        /* ... but never more than twice that number. */
        assertThat("nb of states", entryStates.size(), lessThanOrEqualTo(2 * expectedSize));
    }
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) Test(org.junit.Test)

Example 13 with TimeRange

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

the class TimeGraphWidgetTestBase method repaint.

/**
 * Repaint the current time range.
 */
protected void repaint() {
    TimeRange currentRange = getControl().getViewContext().getVisibleTimeRange();
    renderRange(currentRange);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange)

Example 14 with TimeRange

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

the class TimeGraphWidgetTestBase method verifyVisibleRange.

/**
 * Verify that both the control and viewer passed as parameters currently
 * report the expected visible time range.
 *
 * @param expectedRange
 *            Expected time range
 */
protected static void verifyVisibleRange(TimeRange expectedRange) {
    TimeGraphModelControl control = sfControl;
    TimeGraphWidget widget = sfWidget;
    assertNotNull(control);
    assertNotNull(widget);
    /* Check the control */
    assertEquals(expectedRange, control.getViewContext().getVisibleTimeRange());
    /* Check the view itself */
    TimeRange timeRange = widget.getTimeGraphEdgeTimestamps(null);
    long tsStart = timeRange.getStartTime();
    long tsEnd = timeRange.getEndTime();
    /* We will tolerate being off by a few pixels, due to rounding. */
    double delta = widget.getCurrentNanosPerPixel() * 2;
    assertEqualsWithin(expectedRange.getStartTime(), tsStart, delta);
    assertEqualsWithin(expectedRange.getEndTime(), tsEnd, delta);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) TimeGraphModelControl(com.efficios.jabberwocky.views.timegraph.control.TimeGraphModelControl)

Example 15 with TimeRange

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

the class TimeGraphWidgetZoomTest method testZoom.

private void testZoom(long initialRangeStart, long initialRangeEnd, long zoomPivot, boolean zoomIn, int nbSteps) {
    TimeRange initialRange = TimeRange.of(initialRangeStart, initialRangeEnd);
    TimeRange selectionRange = TimeRange.of(zoomPivot, zoomPivot);
    TimeGraphWidget widget = getWidget();
    seekVisibleRange(initialRange);
    widget.getViewContext().setSelectionTimeRange(selectionRange);
    double totalFactor = Math.pow((1.0 + widget.getDebugOptions().zoomStep.get()), nbSteps);
    if (!zoomIn) {
        totalFactor = 1 / totalFactor;
    }
    long initialRangeDuration = initialRange.getDuration();
    double newRangeDuration = initialRangeDuration * (1.0 / (totalFactor));
    double durationDelta = newRangeDuration - initialRangeDuration;
    double zoomPivotRatio = (double) (zoomPivot - initialRange.getStartTime()) / (double) (initialRange.getDuration());
    long newStart = initialRange.getStartTime() - Math.round(durationDelta * zoomPivotRatio);
    long newEnd = initialRange.getEndTime() + Math.round(durationDelta - (durationDelta * zoomPivotRatio));
    /* Apply zoom action(s) */
    for (int i = 0; i < nbSteps; i++) {
        widget.getZoomActions().zoom(zoomIn, false, null);
    }
    JfxTestUtils.updateUI();
    final long expectedStart = Math.max(newStart, StubTrace.FULL_TRACE_START_TIME);
    final long expectedEnd = Math.min(newEnd, StubTrace.FULL_TRACE_END_TIME);
    TimeRange expectedRange = TimeRange.of(expectedStart, expectedEnd);
    verifyVisibleRange(expectedRange);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange)

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