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);
}
}
}
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;
}
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;
}
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;
}
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());
}
Aggregations