use of org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.LongPoint 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