From d16037c326496a0446719295517b9b1f38fbe605 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Thu, 29 Jun 2017 13:43:49 -0400 Subject: [PATCH] Fix time graph widget initialization Change-Id: I7ee0c71e68d9735ff0305b958d54e5b95b72b1e2 Signed-off-by: Alexandre Montplaisir --- .../ui/timeline/widgets/timegraph/TimeGraphWidget.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tmf/org.lttng.scope.tmf2.views.ui/src/org/lttng/scope/tmf2/views/ui/timeline/widgets/timegraph/TimeGraphWidget.java b/tmf/org.lttng.scope.tmf2.views.ui/src/org/lttng/scope/tmf2/views/ui/timeline/widgets/timegraph/TimeGraphWidget.java index 068d17a27d..ed8f6fe13b 100644 --- a/tmf/org.lttng.scope.tmf2.views.ui/src/org/lttng/scope/tmf2/views/ui/timeline/widgets/timegraph/TimeGraphWidget.java +++ b/tmf/org.lttng.scope.tmf2.views.ui/src/org/lttng/scope/tmf2/views/ui/timeline/widgets/timegraph/TimeGraphWidget.java @@ -351,8 +351,14 @@ public class TimeGraphWidget extends TimeGraphModelView implements ITimelineWidg /* Update the zoom level */ long windowTimeRange = newVisibleRange.getDuration(); double timeGraphVisibleWidth = fTimeGraphScrollPane.getViewportBounds().getWidth(); - /* Clamp the width to 1 px (0 is reported if the view is not visible) */ - timeGraphVisibleWidth = Math.max(1, timeGraphVisibleWidth); + if (timeGraphVisibleWidth < 100) { + /* + * The view's width is reported as 0 if the widget is not yet part of the + * scenegraph. Instead target a larger width so that we obtain a value of + * nanos-per-pixel that makes sense. + */ + timeGraphVisibleWidth = 2000; + } fNanosPerPixel.set(windowTimeRange / timeGraphVisibleWidth); double oldTotalWidth = fTimeGraphPane.getLayoutBounds().getWidth(); -- 2.34.1