use of org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent 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.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent in project tracecompass by tracecompass.
the class TimeGraphControl method drawLineGraphEntry.
private void drawLineGraphEntry(long time0, @NonNull Rectangle rect, double pixelsPerNanoSec, Iterator<ITimeEvent> iterator) {
// clamp 0 - max positive
long max = Long.MIN_VALUE;
long min = 0;
List<@NonNull List<@NonNull LongPoint>> seriesModel = new ArrayList<>();
TimeLineEvent lastValid = null;
while (iterator.hasNext()) {
ITimeEvent event = iterator.next();
if (!(event instanceof TimeLineEvent)) {
continue;
}
int x = SaturatedArithmetic.add(rect.x, (int) ((event.getTime() - time0) * pixelsPerNanoSec));
if (x >= rect.x + rect.width) {
// event is out of bounds
continue;
}
TimeLineEvent timeEvent = (TimeLineEvent) event;
List<Long> values = timeEvent.getValues();
for (int i = 0; i < values.size(); i++) {
if (seriesModel.size() <= i) {
seriesModel.add(new ArrayList<>());
}
Long val = values.get(i);
if (val != null) {
// get max and min, this is a relative scale.
max = Math.max(Math.abs(val), max);
min = 0;
lastValid = timeEvent;
seriesModel.get(i).add(new LongPoint(x, val));
}
}
}
if (lastValid == null) {
return;
}
double scale = (max - min) == 0 ? 1.0 : (double) rect.height / (max - min);
StyleManager styleManager = getStyleManager();
OutputElementStyle elementStyle = getElementStyle(lastValid);
if (elementStyle == null) {
return;
}
RGBAColor rgba = styleManager.getColorStyle(elementStyle, StyleProperties.COLOR);
fLines.add(new DeferredLine(rect, min, seriesModel, rgba == null ? BLACK : rgba, scale));
}
Aggregations