From eb4b02bda40d797ca89a2ebf03ff67225d25b061 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Tue, 2 Jan 2024 08:05:17 -0700 Subject: [PATCH] Assign priorities to event images and colors based on ordinal of event types (higher ordinal means higher priority) --- .../src/net/sf/openrocket/gui/plot/EventGraphics.java | 2 ++ .../src/net/sf/openrocket/gui/plot/SimulationPlot.java | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/plot/EventGraphics.java b/swing/src/net/sf/openrocket/gui/plot/EventGraphics.java index 2aa8fa0e5..5d3d79c3d 100644 --- a/swing/src/net/sf/openrocket/gui/plot/EventGraphics.java +++ b/swing/src/net/sf/openrocket/gui/plot/EventGraphics.java @@ -40,6 +40,8 @@ public class EventGraphics { EVENT_COLORS.put(FlightEvent.Type.GROUND_HIT, new Color(0, 0, 0)); EVENT_COLORS.put(FlightEvent.Type.SIMULATION_END, new Color(128, 0, 0)); EVENT_COLORS.put(FlightEvent.Type.TUMBLE, new Color(196, 0, 255)); + EVENT_COLORS.put(FlightEvent.Type.EXCEPTION, new Color(255, 0, 0)); + EVENT_COLORS.put(FlightEvent.Type.SIM_ABORT, new Color(255, 0, 0)); } private static final Map EVENT_IMAGES = new HashMap(); diff --git a/swing/src/net/sf/openrocket/gui/plot/SimulationPlot.java b/swing/src/net/sf/openrocket/gui/plot/SimulationPlot.java index 4525bf5bb..92ad8b4a4 100644 --- a/swing/src/net/sf/openrocket/gui/plot/SimulationPlot.java +++ b/swing/src/net/sf/openrocket/gui/plot/SimulationPlot.java @@ -444,6 +444,7 @@ public class SimulationPlot { String text = null; Color color = null; Image image = null; + int maxOrdinal = -1; for (EventDisplayInfo info : eventList) { if (branch >= 0 && branch != info.stage) { continue; @@ -451,12 +452,14 @@ public class SimulationPlot { double t = info.time; FlightEvent.Type type = info.event.getType(); - if (Math.abs(t - prevTime) <= 0.05) { if (!typeSet.contains(type)) { text = text + ", " + type.toString(); - color = EventGraphics.getEventColor(type); - image = EventGraphics.getEventImage(type); + if (type.ordinal() > maxOrdinal) { + color = EventGraphics.getEventColor(type); + image = EventGraphics.getEventImage(type); + maxOrdinal = type.ordinal(); + } typeSet.add(type); } @@ -473,6 +476,7 @@ public class SimulationPlot { image = EventGraphics.getEventImage(type); typeSet.clear(); typeSet.add(type); + maxOrdinal = type.ordinal(); } }