starting to plot warning events. Not done yet
This commit is contained in:
parent
47e7e017bb
commit
b6fafb995c
@ -9,6 +9,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import info.openrocket.core.logging.MessagePriority;
|
||||||
|
import info.openrocket.core.logging.Warning;
|
||||||
import info.openrocket.core.simulation.FlightEvent;
|
import info.openrocket.core.simulation.FlightEvent;
|
||||||
|
|
||||||
public class EventGraphics {
|
public class EventGraphics {
|
||||||
@ -20,9 +22,14 @@ public class EventGraphics {
|
|||||||
return DEFAULT_EVENT_COLOR;
|
return DEFAULT_EVENT_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Image getEventImage(FlightEvent.Type type ) {
|
static Image getEventImage(FlightEvent event) {
|
||||||
Image i = EVENT_IMAGES.get(type);
|
|
||||||
return i;
|
FlightEvent.Type type = event.getType();
|
||||||
|
if (type == FlightEvent.Type.SIM_WARN) {
|
||||||
|
return MESSAGE_IMAGES.get(((Warning) event.getData()).getPriority());
|
||||||
|
} else {
|
||||||
|
return EVENT_IMAGES.get(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Color DEFAULT_EVENT_COLOR = new Color(0, 0, 0);
|
private static final Color DEFAULT_EVENT_COLOR = new Color(0, 0, 0);
|
||||||
@ -46,24 +53,32 @@ public class EventGraphics {
|
|||||||
|
|
||||||
private static final Map<FlightEvent.Type, Image> EVENT_IMAGES = new HashMap<FlightEvent.Type, Image>();
|
private static final Map<FlightEvent.Type, Image> EVENT_IMAGES = new HashMap<FlightEvent.Type, Image>();
|
||||||
static {
|
static {
|
||||||
loadImage(FlightEvent.Type.LAUNCH, "pix/eventicons/event-launch.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.LAUNCH, "pix/eventicons/event-launch.png");
|
||||||
loadImage(FlightEvent.Type.LIFTOFF, "pix/eventicons/event-liftoff.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.LIFTOFF, "pix/eventicons/event-liftoff.png");
|
||||||
loadImage(FlightEvent.Type.LAUNCHROD, "pix/eventicons/event-launchrod.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.LAUNCHROD, "pix/eventicons/event-launchrod.png");
|
||||||
loadImage(FlightEvent.Type.IGNITION, "pix/eventicons/event-ignition.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.IGNITION, "pix/eventicons/event-ignition.png");
|
||||||
loadImage(FlightEvent.Type.BURNOUT, "pix/eventicons/event-burnout.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.BURNOUT, "pix/eventicons/event-burnout.png");
|
||||||
loadImage(FlightEvent.Type.EJECTION_CHARGE, "pix/eventicons/event-ejection-charge.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.EJECTION_CHARGE, "pix/eventicons/event-ejection-charge.png");
|
||||||
loadImage(FlightEvent.Type.STAGE_SEPARATION,
|
loadImage(EVENT_IMAGES, FlightEvent.Type.STAGE_SEPARATION,
|
||||||
"pix/eventicons/event-stage-separation.png");
|
"pix/eventicons/event-stage-separation.png");
|
||||||
loadImage(FlightEvent.Type.APOGEE, "pix/eventicons/event-apogee.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.APOGEE, "pix/eventicons/event-apogee.png");
|
||||||
loadImage(FlightEvent.Type.RECOVERY_DEVICE_DEPLOYMENT,
|
loadImage(EVENT_IMAGES, FlightEvent.Type.RECOVERY_DEVICE_DEPLOYMENT,
|
||||||
"pix/eventicons/event-recovery-device-deployment.png");
|
"pix/eventicons/event-recovery-device-deployment.png");
|
||||||
loadImage(FlightEvent.Type.GROUND_HIT, "pix/eventicons/event-ground-hit.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.GROUND_HIT, "pix/eventicons/event-ground-hit.png");
|
||||||
loadImage(FlightEvent.Type.SIMULATION_END, "pix/eventicons/event-simulation-end.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.SIMULATION_END, "pix/eventicons/event-simulation-end.png");
|
||||||
loadImage(FlightEvent.Type.EXCEPTION, "pix/eventicons/event-exception.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.EXCEPTION, "pix/eventicons/event-exception.png");
|
||||||
loadImage(FlightEvent.Type.SIM_ABORT, "pix/eventicons/event-exception.png");
|
loadImage(EVENT_IMAGES, FlightEvent.Type.SIM_ABORT, "pix/eventicons/event-exception.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Messages can happen at several priority levels, requiring different icons
|
||||||
|
private static final Map<MessagePriority, Image> MESSAGE_IMAGES = new HashMap<MessagePriority, Image>();
|
||||||
|
static {
|
||||||
|
loadImage(MESSAGE_IMAGES, MessagePriority.LOW, "pix/icons/warning_low.png");
|
||||||
|
loadImage(MESSAGE_IMAGES, MessagePriority.NORMAL, "pix/icons/warning_normal.png");
|
||||||
|
loadImage(MESSAGE_IMAGES, MessagePriority.HIGH, "pix/icons/warning_high.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadImage(FlightEvent.Type type, String file) {
|
private static <KeyType> void loadImage(Map<KeyType, Image> imageMap, KeyType type, String file) {
|
||||||
InputStream is;
|
InputStream is;
|
||||||
|
|
||||||
is = ClassLoader.getSystemResourceAsStream(file);
|
is = ClassLoader.getSystemResourceAsStream(file);
|
||||||
@ -74,10 +89,9 @@ public class EventGraphics {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Image image = ImageIO.read(is);
|
Image image = ImageIO.read(is);
|
||||||
EVENT_IMAGES.put(type, image);
|
imageMap.put(type, image);
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
ignore.printStackTrace();
|
ignore.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,6 @@ public class SimulationPlot {
|
|||||||
}
|
}
|
||||||
XYSeries ser = collection.getSeries(series);
|
XYSeries ser = collection.getSeries(series);
|
||||||
String name = ser.getDescription();
|
String name = ser.getDescription();
|
||||||
|
|
||||||
// Extract the unit from the last part of the series description, between parenthesis
|
// Extract the unit from the last part of the series description, between parenthesis
|
||||||
Matcher m = Pattern.compile(".*\\((.*?)\\)").matcher(name);
|
Matcher m = Pattern.compile(".*\\((.*?)\\)").matcher(name);
|
||||||
String unitY = "";
|
String unitY = "";
|
||||||
@ -409,7 +408,6 @@ public class SimulationPlot {
|
|||||||
private void drawDomainMarkers(int branch) {
|
private void drawDomainMarkers(int branch) {
|
||||||
XYPlot plot = chart.getXYPlot();
|
XYPlot plot = chart.getXYPlot();
|
||||||
FlightDataBranch dataBranch = simulation.getSimulatedData().getBranch(Math.max(branch, 0));
|
FlightDataBranch dataBranch = simulation.getSimulatedData().getBranch(Math.max(branch, 0));
|
||||||
|
|
||||||
// Clear existing domain markers and annotations
|
// Clear existing domain markers and annotations
|
||||||
plot.clearDomainMarkers();
|
plot.clearDomainMarkers();
|
||||||
plot.clearAnnotations();
|
plot.clearAnnotations();
|
||||||
@ -453,6 +451,7 @@ public class SimulationPlot {
|
|||||||
Color color = null;
|
Color color = null;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
int maxOrdinal = -1;
|
int maxOrdinal = -1;
|
||||||
|
|
||||||
for (EventDisplayInfo info : eventList) {
|
for (EventDisplayInfo info : eventList) {
|
||||||
if (branch >= 0 && branch != info.stage) {
|
if (branch >= 0 && branch != info.stage) {
|
||||||
continue;
|
continue;
|
||||||
@ -465,7 +464,7 @@ public class SimulationPlot {
|
|||||||
text = text + ", " + type.toString();
|
text = text + ", " + type.toString();
|
||||||
if (type.ordinal() > maxOrdinal) {
|
if (type.ordinal() > maxOrdinal) {
|
||||||
color = EventGraphics.getEventColor(type);
|
color = EventGraphics.getEventColor(type);
|
||||||
image = EventGraphics.getEventImage(type);
|
image = EventGraphics.getEventImage(info.event);
|
||||||
maxOrdinal = type.ordinal();
|
maxOrdinal = type.ordinal();
|
||||||
}
|
}
|
||||||
typeSet.add(type);
|
typeSet.add(type);
|
||||||
@ -481,7 +480,7 @@ public class SimulationPlot {
|
|||||||
prevTime = t;
|
prevTime = t;
|
||||||
text = type.toString();
|
text = type.toString();
|
||||||
color = EventGraphics.getEventColor(type);
|
color = EventGraphics.getEventColor(type);
|
||||||
image = EventGraphics.getEventImage(type);
|
image = EventGraphics.getEventImage(info.event);
|
||||||
typeSet.clear();
|
typeSet.clear();
|
||||||
typeSet.add(type);
|
typeSet.add(type);
|
||||||
maxOrdinal = type.ordinal();
|
maxOrdinal = type.ordinal();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user