use of org.eclipse.tracecompass.internal.tmf.chart.ui.consumer.ScatterStringConsumer in project tracecompass by tracecompass.
the class SwtScatterChart method configureSeries.
@Override
protected void configureSeries(Map<@NonNull ISeries, Object[]> mapper) {
XYChartConsumer chartConsumer = getChartConsumer();
/* Obtain the X ranges if possible */
NumericalConsumerAggregator xAggregator = (NumericalConsumerAggregator) chartConsumer.getXAggregator();
if (xAggregator != null) {
if (getModel().isXLogscale()) {
fXRanges = clampInputDataRange(xAggregator.getChartRanges());
} else {
fXRanges = xAggregator.getChartRanges();
}
}
/* Obtain the Y ranges if possible */
NumericalConsumerAggregator yAggregator = (NumericalConsumerAggregator) chartConsumer.getYAggregator();
if (yAggregator != null) {
if (getModel().isYLogscale()) {
fYRanges = clampInputDataRange(yAggregator.getChartRanges());
} else {
fYRanges = yAggregator.getChartRanges();
}
}
/* Generate data for each SWT series */
for (XYSeriesConsumer seriesConsumer : chartConsumer.getSeries()) {
double[] xData;
double[] yData;
Object[] object = seriesConsumer.getConsumedElements().toArray();
/* Generate data for the X axis */
if (getXDescriptorsInfo().areNumerical()) {
NumericalConsumer consumer = (NumericalConsumer) seriesConsumer.getXConsumer();
List<Number> data = consumer.getData();
int size = data.size();
xData = new double[size];
for (int i = 0; i < size; i++) {
Number number = checkNotNull(data.get(i));
xData[i] = fXRanges.getInternalValue(number).doubleValue();
}
} else {
ScatterStringConsumer consumer = (ScatterStringConsumer) seriesConsumer.getXConsumer();
List<String> list = consumer.getList();
xData = new double[list.size()];
for (int i = 0; i < xData.length; i++) {
String str = list.get(i);
xData[i] = checkNotNull(fXStringMap.get(str));
}
}
/* Generate data for the Y axis */
if (getYDescriptorsInfo().areNumerical()) {
NumericalConsumer consumer = (NumericalConsumer) seriesConsumer.getYConsumer();
List<Number> data = consumer.getData();
yData = new double[data.size()];
for (int i = 0; i < yData.length; i++) {
Number number = checkNotNull(data.get(i));
yData[i] = fYRanges.getInternalValue(number).doubleValue();
}
} else {
ScatterStringConsumer consumer = (ScatterStringConsumer) seriesConsumer.getYConsumer();
List<String> list = consumer.getList();
yData = new double[list.size()];
for (int i = 0; i < yData.length; i++) {
String str = list.get(i);
yData[i] = checkNotNull(fYStringMap.get(str));
}
}
/* Set the data for the SWT series */
ISeries<Integer> series = checkNotNull(getSeriesMap().get(seriesConsumer.getSeries()));
series.setDataModel(new DoubleArraySeriesModel(xData, yData));
/* Create a series mapper */
mapper.put(series, checkNotNull(object));
}
}
Aggregations