Search in sources :

Example 1 with ITimeGraphModelProvider

use of com.efficios.jabberwocky.views.timegraph.model.provider.ITimeGraphModelProvider in project lttng-scope by lttng.

the class TimeGraphWidget method paintArea.

/**
 * Paint the specified view area.
 *
 * @param windowRange
 *            The horizontal position where the visible window currently is
 * @param verticalPos
 *            The vertical position where the visible window currently is
 * @param movedHorizontally
 *            If we have moved horizontally since the last redraw. May be
 *            used to skip some operations. If you are not sure say "true".
 * @param movedVertically
 *            If we have moved vertically since the last redraw. May be used
 *            to skip some operations. If you are not sure say "true".
 * @param taskSeqNb
 *            The sequence number of this task, used for logging only
 */
void paintArea(TimeRange windowRange, VerticalPosition verticalPos, boolean movedHorizontally, boolean movedVertically, long taskSeqNb) {
    final TimeRange fullTimeGraphRange = getViewContext().getCurrentProjectFullRange();
    /*
         * Request the needed renders and prepare the corresponding UI objects.
         * We may ask for some padding on each side, clamped by the trace's
         * start and end.
         */
    final long timeRangePadding = Math.round(windowRange.getDuration() * getDebugOptions().renderRangePadding.get());
    final long renderingStartTime = Math.max(fullTimeGraphRange.getStartTime(), windowRange.getStartTime() - timeRangePadding);
    final long renderingEndTime = Math.min(fullTimeGraphRange.getEndTime(), windowRange.getEndTime() + timeRangePadding);
    final TimeRange renderingRange = TimeRange.of(renderingStartTime, renderingEndTime);
    /*
         * Start a new repaint, display the "loading" overlay. The next
         * paint task to finish will put it back to non-visible.
         */
    if (getDebugOptions().isLoadingOverlayEnabled.get()) {
        fTimeGraphLoadingOverlay.fadeIn();
    }
    JabberwockyTask<Void> task = new JabberwockyTask<>("Updating Timegraph " + getName(), it -> {
        // $NON-NLS-1$
        LOGGER.finer(() -> "Starting paint task #" + taskSeqNb);
        ITimeGraphModelProvider modelProvider = getControl().getRenderProvider();
        TimeGraphTreeRender treeRender = modelProvider.getTreeRender();
        if (it.isCancelled()) {
            return null;
        }
        /* Prepare the tree part, if needed */
        if (!treeRender.equals(fLatestTreeRender)) {
            fLatestTreeRender = treeRender;
            fTreeArea.updateTreeContents(treeRender);
        }
        if (it.isCancelled()) {
            return null;
        }
        /* Paint the background. It's very quick so we can do it every time. */
        fBackgroundLayer.drawContents(treeRender, renderingRange, verticalPos, it);
        /*
             * The state rectangles should be redrawn as soon as we move,
             * either horizontally or vertically.
             */
        fStateLayer.setWindowRange(windowRange);
        fStateLayer.drawContents(treeRender, renderingRange, verticalPos, it);
        if (it.isCancelled()) {
            return null;
        }
        /*
             * Arrows and drawn events are drawn for the full vertical
             * range. Only refetch/repaint them if we moved horizontally.
             */
        if (movedHorizontally) {
            fArrowLayer.drawContents(treeRender, renderingRange, verticalPos, it);
            fDrawnEventLayer.drawContents(treeRender, renderingRange, verticalPos, it);
        }
        if (it.isCancelled()) {
            return null;
        }
        /* Painting is finished, turn off the loading overlay */
        Platform.runLater(() -> {
            // $NON-NLS-1$
            LOGGER.finest(() -> "fading out overlay");
            fTimeGraphLoadingOverlay.fadeOut();
            if (fRepaintLatch != null) {
                fRepaintLatch.countDown();
            }
        });
        return null;
    });
    // $NON-NLS-1$
    LOGGER.finer(() -> "Queueing task #" + taskSeqNb);
    /*
         * Attach a listener to the task to receive exceptions thrown within the
         * task.
         */
    task.exceptionProperty().addListener((obs, oldVal, newVal) -> {
        if (newVal != null) {
            newVal.printStackTrace();
        }
    });
    fTaskExecutor.schedule(task);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) TimeGraphTreeRender(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender) ITimeGraphModelProvider(com.efficios.jabberwocky.views.timegraph.model.provider.ITimeGraphModelProvider) JabberwockyTask(com.efficios.jabberwocky.task.JabberwockyTask)

Aggregations

TimeRange (com.efficios.jabberwocky.common.TimeRange)1 JabberwockyTask (com.efficios.jabberwocky.task.JabberwockyTask)1 ITimeGraphModelProvider (com.efficios.jabberwocky.views.timegraph.model.provider.ITimeGraphModelProvider)1 TimeGraphTreeRender (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender)1