Search in sources :

Example 1 with TimeLineEvent

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;
}
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 2 with TimeLineEvent

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));
}
Also used : ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) ArrayList(java.util.ArrayList) LongPoint(org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.LongPoint) DeferredLine(org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.DeferredLine) Point(org.eclipse.swt.graphics.Point) LongPoint(org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.LongPoint) TimeLineEvent(org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent) NonNull(org.eclipse.jdt.annotation.NonNull) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) StyleManager(org.eclipse.tracecompass.tmf.ui.model.StyleManager)

Aggregations

ArrayList (java.util.ArrayList)2 TimeLineEvent (org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.model.TimeLineEvent)2 ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Point (org.eclipse.swt.graphics.Point)1 DeferredLine (org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.DeferredLine)1 LongPoint (org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.LongPoint)1 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)1 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 StyleManager (org.eclipse.tracecompass.tmf.ui.model.StyleManager)1 NullTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent)1 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)1