Fix icon marker plotting for branch == -1
This commit is contained in:
parent
6cdc2d920e
commit
c374f616b9
@ -94,7 +94,6 @@ public class SimulationPlot {
|
||||
|
||||
void setShowBranch(int branch) {
|
||||
XYPlot plot = (XYPlot) chart.getPlot();
|
||||
plot.clearAnnotations();
|
||||
int datasetcount = plot.getDatasetCount();
|
||||
for (int i = 0; i < datasetcount; i++) {
|
||||
int seriescount = ((XYSeriesCollection) plot.getDataset(i)).getSeriesCount();
|
||||
@ -409,17 +408,44 @@ public class SimulationPlot {
|
||||
XYPlot plot = chart.getXYPlot();
|
||||
FlightDataBranch dataBranch = simulation.getSimulatedData().getBranch(Math.max(branch, 0));
|
||||
|
||||
// Clear existing domain markers
|
||||
// Clear existing domain markers and annotations
|
||||
plot.clearDomainMarkers();
|
||||
plot.clearAnnotations();
|
||||
|
||||
// Construct domain marker lists collapsing based on time.
|
||||
// Store flight event information
|
||||
List<Double> eventTimes = new ArrayList<>();
|
||||
List<String> eventLabels = new ArrayList<>();
|
||||
List<Color> eventColors = new ArrayList<>();
|
||||
List<Image> eventImages = new ArrayList<>();
|
||||
|
||||
List<Double> eventTimes = new ArrayList<Double>();
|
||||
List<String> eventLabels = new ArrayList<String>();
|
||||
List<Color> eventColors = new ArrayList<Color>();
|
||||
List<Image> eventImages = new ArrayList<Image>();
|
||||
{
|
||||
HashSet<FlightEvent.Type> typeSet = new HashSet<FlightEvent.Type>();
|
||||
// Plot the markers
|
||||
if (config.getDomainAxisType() == FlightDataType.TYPE_TIME && !preferences.getBoolean(Preferences.MARKER_STYLE_ICON, false)) {
|
||||
fillEventLists(branch, eventTimes, eventLabels, eventColors, eventImages);
|
||||
plotVerticalMarkers(plot, eventTimes, eventLabels, eventColors);
|
||||
|
||||
} else { // Other domains are plotted as image annotations
|
||||
if (branch == -1) {
|
||||
// For icon markers, we need to do the plotting separately, otherwise you can have icon markers from e.g.
|
||||
// branch 1 be plotted on branch 0
|
||||
for (int b = 0; b < simulation.getSimulatedData().getBranchCount(); b++) {
|
||||
fillEventLists(b, eventTimes, eventLabels, eventColors, eventImages);
|
||||
dataBranch = simulation.getSimulatedData().getBranch(b);
|
||||
plotIconMarkers(plot, dataBranch, eventTimes, eventLabels, eventImages);
|
||||
eventTimes.clear();
|
||||
eventLabels.clear();
|
||||
eventColors.clear();
|
||||
eventImages.clear();
|
||||
}
|
||||
} else {
|
||||
fillEventLists(branch, eventTimes, eventLabels, eventColors, eventImages);
|
||||
plotIconMarkers(plot, dataBranch, eventTimes, eventLabels, eventImages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillEventLists(int branch, List<Double> eventTimes, List<String> eventLabels,
|
||||
List<Color> eventColors, List<Image> eventImages) {
|
||||
HashSet<FlightEvent.Type> typeSet = new HashSet<>();
|
||||
double prevTime = -100;
|
||||
String text = null;
|
||||
Color color = null;
|
||||
@ -433,7 +459,6 @@ public class SimulationPlot {
|
||||
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);
|
||||
@ -442,7 +467,6 @@ public class SimulationPlot {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (text != null) {
|
||||
eventTimes.add(prevTime);
|
||||
eventLabels.add(text);
|
||||
@ -466,8 +490,7 @@ public class SimulationPlot {
|
||||
}
|
||||
}
|
||||
|
||||
// Plot the markers
|
||||
if (config.getDomainAxisType() == FlightDataType.TYPE_TIME && !preferences.getBoolean(Preferences.MARKER_STYLE_ICON, false)) {
|
||||
private static void plotVerticalMarkers(XYPlot plot, List<Double> eventTimes, List<String> eventLabels, List<Color> eventColors) {
|
||||
double markerWidth = 0.01 * plot.getDomainAxis().getUpperBound();
|
||||
|
||||
// Domain time is plotted as vertical markers
|
||||
@ -488,8 +511,10 @@ public class SimulationPlot {
|
||||
plot.setDomainAxis(new PresetNumberAxis(plot.getDomainAxis().getLowerBound(), t + markerWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else { // Other domains are plotted as image annotations
|
||||
private void plotIconMarkers(XYPlot plot, FlightDataBranch dataBranch, List<Double> eventTimes,
|
||||
List<String> eventLabels, List<Image> eventImages) {
|
||||
List<Double> time = dataBranch.get(FlightDataType.TYPE_TIME);
|
||||
List<Double> domain = dataBranch.get(config.getDomainAxisType());
|
||||
|
||||
@ -499,8 +524,9 @@ public class SimulationPlot {
|
||||
double t = eventTimes.get(i);
|
||||
Image image = eventImages.get(i);
|
||||
|
||||
if (image == null)
|
||||
if (image == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double xcoord = domainInterpolator.getValue(t);
|
||||
|
||||
@ -537,7 +563,6 @@ public class SimulationPlot {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<EventDisplayInfo> buildEventInfo() {
|
||||
ArrayList<EventDisplayInfo> eventList = new ArrayList<EventDisplayInfo>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user