Search in sources :

Example 16 with TimeRange

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

the class TimeGraphDrawnEventLayer method trackEventProvider.

private void trackEventProvider(TimeGraphDrawnEventProvider provider) {
    Group newGroup = new Group();
    Group oldGroup = fEventProviders.put(provider, newGroup);
    if (oldGroup == null) {
        Platform.runLater(() -> {
            getParentGroup().getChildren().add(newGroup);
        });
    } else {
        /* Remove the old group in case there was already one. */
        Platform.runLater(() -> {
            getParentGroup().getChildren().remove(oldGroup);
            getParentGroup().getChildren().add(newGroup);
        });
    }
    /*
         * Add a listener to this provider's "enabled" property, so that when it
         * changes from enabled to disabled and vice versa, we update the view
         * accordingly.
         */
    provider.enabledProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            /* The provider was just enabled */
            TimeRange timeRange = getWidget().getViewContext().getVisibleTimeRange();
            TimeGraphTreeRender treeRender = getWidget().getLatestTreeRender();
            // FIXME Use a Task?
            paintEventsOfProvider(treeRender, timeRange, provider, null);
        } else {
            /* Provider was disabled. Clear the children of its group. */
            Group group = fEventProviders.get(provider);
            if (group == null) {
                return;
            }
            Platform.runLater(() -> group.getChildren().clear());
        }
    });
    getWidget().getTimelineWidgetUpdateTask().forceRedraw();
}
Also used : Group(javafx.scene.Group) TimeRange(com.efficios.jabberwocky.common.TimeRange) TimeGraphTreeRender(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender)

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