Search in sources :

Example 1 with NullTimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent in project tracecompass by tracecompass.

the class AbstractTimeGraphView method fillWithNullEvents.

/**
 * Fill the gaps between non-excluded events with null time events
 *
 * @param entry
 *            The entry
 * @param eventList
 *            The entry event list
 */
private void fillWithNullEvents(TimeGraphEntry entry, List<ITimeEvent> eventList) {
    List<ITimeEvent> filtered = new ArrayList<>();
    ViewFilterDialog viewFilterDialog = getViewFilterDialog();
    if (!eventList.isEmpty() && viewFilterDialog != null && viewFilterDialog.hasActiveSavedFilters()) {
        eventList.forEach(te -> {
            // Keep only the events that do not have the 'exclude' property activated
            if (!te.isPropertyActive(CoreFilterProperty.EXCLUDE)) {
                filtered.add(te);
            }
        });
        long prevTime = eventList.get(0).getTime();
        long endTime = eventList.get(eventList.size() - 1).getTime() + eventList.get(eventList.size() - 1).getDuration();
        eventList.clear();
        // Replace unused events with null time events to fill gaps
        for (ITimeEvent event : filtered) {
            if (prevTime < event.getTime()) {
                NullTimeEvent nullTimeEvent = new NullTimeEvent(entry, prevTime, event.getTime() - prevTime);
                nullTimeEvent.setProperty(CoreFilterProperty.DIMMED, true);
                nullTimeEvent.setProperty(CoreFilterProperty.EXCLUDE, true);
                eventList.add(nullTimeEvent);
            }
            eventList.add(event);
            prevTime = event.getTime() + event.getDuration();
        }
        if (prevTime < endTime) {
            NullTimeEvent nullTimeEvent = new NullTimeEvent(entry, prevTime, endTime - prevTime);
            nullTimeEvent.setProperty(CoreFilterProperty.DIMMED, true);
            nullTimeEvent.setProperty(CoreFilterProperty.EXCLUDE, true);
            eventList.add(nullTimeEvent);
        }
    }
}
Also used : ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) ViewFilterDialog(org.eclipse.tracecompass.internal.provisional.tmf.ui.widgets.ViewFilterDialog) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList)

Example 2 with NullTimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent in project tracecompass by tracecompass.

the class FlameGraphPresentationProvider method getElementStyle.

@Override
@Nullable
public OutputElementStyle getElementStyle(ITimeEvent event) {
    if (event instanceof NullTimeEvent) {
        return null;
    }
    if (event instanceof FlamegraphEvent) {
        IOutputElement model = ((FlamegraphEvent) event).getModel();
        OutputElementStyle eventStyle = model.getStyle();
        if (eventStyle == null) {
            String name = event.getLabel();
            Object key = name == null ? model.getValue() : name;
            eventStyle = FlameDefaultPalette.getStyleFor(key);
        }
        return eventStyle;
    }
    return TRANSPARENT_STYLE;
}
Also used : NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) IOutputElement(org.eclipse.tracecompass.tmf.core.model.IOutputElement) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with NullTimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent in project tracecompass by tracecompass.

the class XmlPresentationProvider method getStateTableIndex.

@Override
public int getStateTableIndex(ITimeEvent event) {
    if (event instanceof NullTimeEvent) {
        return INVISIBLE;
    }
    if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) {
        TimeEvent tcEvent = (TimeEvent) event;
        TimeGraphEntry entry = (TimeGraphEntry) event.getEntry();
        int value = tcEvent.getValue();
        ITmfTreeDataModel model = entry.getEntryModel();
        if (model instanceof DataDrivenOutputEntryModel) {
            // Draw state only if state is already known
            Integer index = stateIndex.get(value);
            if (index != null) {
                return index;
            }
        }
    }
    return TRANSPARENT;
}
Also used : NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) DataDrivenOutputEntryModel(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntryModel)

Example 4 with NullTimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent in project tracecompass by tracecompass.

the class TimeGraphViewStub method getEventList.

@SuppressWarnings("restriction")
@Override
@Nullable
protected List<@NonNull ITimeEvent> getEventList(@NonNull TimeGraphEntry entry, long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) {
    ITmfTrace trace = getTrace();
    if (trace == null) {
        return Collections.emptyList();
    }
    List<@NonNull ITimeEvent> references = fEvents.get(entry.getName());
    List<@NonNull ITimeEvent> ret = new ArrayList<>();
    if (references != null) {
        for (ITimeEvent ref : references) {
            long start = ref.getTime() + trace.getStartTime().toNanos();
            long end = start + ref.getDuration();
            if (start <= endTime && end >= startTime) {
                if (ref instanceof NullTimeEvent) {
                    ret.add(new NullTimeEvent(ref.getEntry(), ref.getTime() + trace.getStartTime().toNanos(), ref.getDuration()));
                } else if (ref instanceof TimeLineEvent) {
                    ret.add(new TimeLineEvent(ref.getEntry(), ref.getTime() + trace.getStartTime().toNanos(), ((TimeLineEvent) ref).getValues()));
                } else if (ref instanceof TimeEvent) {
                    ret.add(new TimeEvent(ref.getEntry(), ref.getTime() + trace.getStartTime().toNanos(), ref.getDuration(), ((TimeEvent) ref).getValue()));
                }
            }
        }
    }
    entry.setEventList(ret);
    return ret;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) TimeLineEvent(org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent) ArrayList(java.util.ArrayList) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 5 with NullTimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent in project tracecompass by tracecompass.

the class TimeGraphEntryTest method testAddZoomedEventNulls.

/**
 * Test method addZoomedEvent with null events.
 */
@Test
public void testAddZoomedEventNulls() {
    TimeGraphEntry entry = new TimeGraphEntry(NAME, SWT.DEFAULT, SWT.DEFAULT);
    ITimeEvent event1 = new NullTimeEvent(entry, 0, 10);
    ITimeEvent event2 = new TimeEvent(entry, 10, 10, 2);
    ITimeEvent event3 = new NullTimeEvent(entry, 20, 10);
    // null events do not affect start and end time
    entry.addZoomedEvent(event1);
    entry.addZoomedEvent(event2);
    entry.addZoomedEvent(event3);
    assertEquals(10, entry.getStartTime());
    assertEquals(20, entry.getEndTime());
    assertIteratorsEqual(Iterators.forArray(event1, event2, event3), entry.getTimeEventsIterator());
}
Also used : ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) Test(org.junit.Test)

Aggregations

NullTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent)9 ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)7 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)5 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)5 Nullable (org.eclipse.jdt.annotation.Nullable)3 ArrayList (java.util.ArrayList)2 IOutputElement (org.eclipse.tracecompass.tmf.core.model.IOutputElement)2 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)2 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)2 Test (org.junit.Test)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Point (org.eclipse.swt.graphics.Point)1 ResourcesEntryModel (org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel)1 Type (org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel.Type)1 ViewFilterDialog (org.eclipse.tracecompass.internal.provisional.tmf.ui.widgets.ViewFilterDialog)1 DataDrivenOutputEntryModel (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntryModel)1 TimeLineEvent (org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent)1 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 Resolution (org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.Resolution)1