From c5fc251c02e44105925579fd8bb4fd4394d9531c Mon Sep 17 00:00:00 2001
From: JoePfeiffer <joseph@pfeifferfamily.net>
Date: Tue, 24 Sep 2024 12:08:21 -0600
Subject: [PATCH] don't try to add event icons if x or y is NaN

noticed a bug that's been around since 23.09 -- if trying to plot using an x axis that includes NaN's when there is a flight event, we get an exception trying to position the icon. This checks for NaN's and doesn't plot in that case.
---
 .../openrocket/swing/gui/plot/SimulationPlot.java     | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java
index e157bd9e0..86a7a880f 100644
--- a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java
+++ b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java
@@ -327,10 +327,13 @@ public class SimulationPlot extends Plot<FlightDataType, FlightDataBranch, Simul
 																yName, ycoord, unitY,
 																sampleIdx) ;					
 						double yloc = slope * ycoord + intercept;
-						XYImageAnnotation annotation =
-							new XYImageAnnotation(xcoord, yloc, image, RectangleAnchor.CENTER);
-						annotation.setToolTipText(tooltipText);
-						plot.addAnnotation(annotation);
+						
+						if (!Double.isNaN(xcoord) && !Double.isNaN(ycoord)) {
+							XYImageAnnotation annotation =
+								new XYImageAnnotation(xcoord, yloc, image, RectangleAnchor.CENTER);
+							annotation.setToolTipText(tooltipText);
+							plot.addAnnotation(annotation);
+						}
 					}
 				}
 			}