Fix time graph widget initialization time-graph-model-3
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Thu, 29 Jun 2017 17:43:49 +0000 (13:43 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Thu, 29 Jun 2017 17:43:49 +0000 (13:43 -0400)
Change-Id: I7ee0c71e68d9735ff0305b958d54e5b95b72b1e2
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
tmf/org.lttng.scope.tmf2.views.ui/src/org/lttng/scope/tmf2/views/ui/timeline/widgets/timegraph/TimeGraphWidget.java

index 068d17a27d3391f067b6fa44f4eca0285463cebf..ed8f6fe13bb78543381824cf7c5f793f95be00b1 100644 (file)
@@ -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();
This page took 0.028442 seconds and 5 git commands to generate.