Check for NaN values and don't try to plot icons for them
This commit is contained in:
parent
723a4262a4
commit
026d5cc259
@ -548,24 +548,25 @@ public class SimulationPlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double ycoord = rangeInterpolator.getValue(t);
|
double ycoord = rangeInterpolator.getValue(t);
|
||||||
|
if (!Double.isNaN(ycoord)) {
|
||||||
|
// Convert units
|
||||||
|
xcoord = config.getDomainAxisUnit().toUnit(xcoord);
|
||||||
|
ycoord = config.getUnit(index).toUnit(ycoord);
|
||||||
|
|
||||||
// Convert units
|
// Get the sample index of the flight event. Because this can be an interpolation between two samples,
|
||||||
xcoord = config.getDomainAxisUnit().toUnit(xcoord);
|
// take the closest sample.
|
||||||
ycoord = config.getUnit(index).toUnit(ycoord);
|
final int sampleIdx;
|
||||||
|
Optional<Double> closestSample = time.stream()
|
||||||
// Get the sample index of the flight event. Because this can be an interpolation between two samples,
|
|
||||||
// take the closest sample.
|
|
||||||
final int sampleIdx;
|
|
||||||
Optional<Double> closestSample = time.stream()
|
|
||||||
.min(Comparator.comparingDouble(sample -> Math.abs(sample - t)));
|
.min(Comparator.comparingDouble(sample -> Math.abs(sample - t)));
|
||||||
sampleIdx = closestSample.map(time::indexOf).orElse(-1);
|
sampleIdx = closestSample.map(time::indexOf).orElse(-1);
|
||||||
|
|
||||||
String tooltipText = formatSampleTooltip(eventLabels.get(i), xcoord, config.getDomainAxisUnit().getUnit(), sampleIdx) ;
|
String tooltipText = formatSampleTooltip(eventLabels.get(i), xcoord, config.getDomainAxisUnit().getUnit(), sampleIdx) ;
|
||||||
|
|
||||||
XYImageAnnotation annotation =
|
XYImageAnnotation annotation =
|
||||||
new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
|
new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
|
||||||
annotation.setToolTipText(tooltipText);
|
annotation.setToolTipText(tooltipText);
|
||||||
plot.addAnnotation(annotation);
|
plot.addAnnotation(annotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user