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);
});
}
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));
}
}
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);
}
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);
}
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);
}
Aggregations