Minor improvements
This commit is contained in:
parent
d75a345f4e
commit
49cdbe5426
@ -362,6 +362,16 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified branch in the simulation has errors
|
||||||
|
*
|
||||||
|
* @param branch the branch to check for errors
|
||||||
|
*/
|
||||||
|
public boolean hasErrors(int branch) {
|
||||||
|
FlightData data = getSimulatedData();
|
||||||
|
return data.getBranch(branch).getFirstEvent(FlightEvent.Type.SIM_ABORT) != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the status indicates that the simulation data is up-to-date.
|
* Returns true if the status indicates that the simulation data is up-to-date.
|
||||||
* @param status status of the simulation to check for if its data is up-to-date
|
* @param status status of the simulation to check for if its data is up-to-date
|
||||||
|
@ -833,7 +833,7 @@ public class SimulationPlot {
|
|||||||
|
|
||||||
private XYTitleAnnotation createAnnotation(int branchNo) {
|
private XYTitleAnnotation createAnnotation(int branchNo) {
|
||||||
|
|
||||||
String abortString = "";
|
StringBuilder abortString = new StringBuilder();
|
||||||
|
|
||||||
for (int b = Math.max(0, branchNo);
|
for (int b = Math.max(0, branchNo);
|
||||||
b < ((branchNo < 0) ?
|
b < ((branchNo < 0) ?
|
||||||
@ -842,17 +842,18 @@ public class SimulationPlot {
|
|||||||
FlightDataBranch branch = simulation.getSimulatedData().getBranch(b);
|
FlightDataBranch branch = simulation.getSimulatedData().getBranch(b);
|
||||||
FlightEvent abortEvent = branch.getFirstEvent(FlightEvent.Type.SIM_ABORT);
|
FlightEvent abortEvent = branch.getFirstEvent(FlightEvent.Type.SIM_ABORT);
|
||||||
if (abortEvent != null) {
|
if (abortEvent != null) {
|
||||||
if (abortString == "") {
|
if (abortString.isEmpty()) {
|
||||||
abortString = trans.get("simulationplot.abort.title");
|
abortString = new StringBuilder(trans.get("simulationplot.abort.title"));
|
||||||
}
|
}
|
||||||
abortString += "\n" + trans.get("simulationplot.abort.stage") + ": " + branch.getBranchName() +
|
abortString.append("\n")
|
||||||
", " + trans.get("simulationplot.abort.time") + ": " + abortEvent.getTime() +
|
.append(trans.get("simulationplot.abort.stage")).append(": ").append(branch.getBranchName()).append("; ")
|
||||||
", " + trans.get("simulationplot.abort.cause") + ": " + ((SimulationAbort)abortEvent.getData()).getMessageDescription();
|
.append(trans.get("simulationplot.abort.time")).append(": ").append(abortEvent.getTime()).append(" s; ")
|
||||||
|
.append(trans.get("simulationplot.abort.cause")).append(": ").append(((SimulationAbort) abortEvent.getData()).getMessageDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abortString != "") {
|
if (!abortString.toString().isEmpty()) {
|
||||||
TextTitle abortsTitle = new TextTitle(abortString,
|
TextTitle abortsTitle = new TextTitle(abortString.toString(),
|
||||||
new Font(Font.SANS_SERIF, Font.BOLD, 14), Color.RED,
|
new Font(Font.SANS_SERIF, Font.BOLD, 14), Color.RED,
|
||||||
RectangleEdge.TOP,
|
RectangleEdge.TOP,
|
||||||
HorizontalAlignment.LEFT, VerticalAlignment.TOP,
|
HorizontalAlignment.LEFT, VerticalAlignment.TOP,
|
||||||
|
@ -46,6 +46,7 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
private static Color darkWarningColor;
|
private static Color darkWarningColor;
|
||||||
|
private final JCheckBox checkErrors;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
initColors();
|
initColors();
|
||||||
@ -61,7 +62,7 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
final SimulationPlot myPlot = new SimulationPlot(simulation, config, initialShowPoints);
|
final SimulationPlot myPlot = new SimulationPlot(simulation, config, initialShowPoints);
|
||||||
|
|
||||||
// Create the dialog
|
// Create the dialog
|
||||||
JPanel panel = new JPanel(new MigLayout("fill","[]","[grow][]"));
|
JPanel panel = new JPanel(new MigLayout("fill, hidemode 3","[]","[grow][]"));
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
|
|
||||||
final ChartPanel chartPanel = new SimulationChart(myPlot.getJFreeChart());
|
final ChartPanel chartPanel = new SimulationChart(myPlot.getJFreeChart());
|
||||||
@ -99,18 +100,17 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
panel.add(checkData, "split, left");
|
panel.add(checkData, "split, left");
|
||||||
|
|
||||||
//// Show errors if any
|
//// Show errors if any
|
||||||
//// ALWAYS show errors initially; make user turn it off for themselves
|
//// Always enable 'show errors' initially; make user turn it off for themselves
|
||||||
if (simulation.hasErrors()) {
|
checkErrors = new JCheckBox(trans.get("PlotDialog.CheckBox.ShowErrors"));
|
||||||
final JCheckBox checkErrors = new JCheckBox(trans.get("PlotDialog.CheckBox.ShowErrors"));
|
checkErrors.setSelected(true);
|
||||||
checkErrors.setSelected(true);
|
checkErrors.addActionListener(new ActionListener() {
|
||||||
checkErrors.addActionListener(new ActionListener() {
|
@Override
|
||||||
@Override
|
public void actionPerformed(ActionEvent e) {
|
||||||
public void actionPerformed(ActionEvent e) {
|
myPlot.setShowErrors(checkErrors.isSelected());
|
||||||
myPlot.setShowErrors(checkErrors.isSelected());
|
}
|
||||||
}
|
});
|
||||||
});
|
panel.add(checkErrors, "split, left");
|
||||||
panel.add(checkErrors, "split, left");
|
checkErrors.setVisible(simulation.hasErrors());
|
||||||
}
|
|
||||||
|
|
||||||
//// Add series selection box
|
//// Add series selection box
|
||||||
ArrayList<String> stages = new ArrayList<String>();
|
ArrayList<String> stages = new ArrayList<String>();
|
||||||
@ -123,6 +123,7 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void itemStateChanged(ItemEvent e) {
|
public void itemStateChanged(ItemEvent e) {
|
||||||
int selectedStage = stageSelection.getSelectedIndex() - 1;
|
int selectedStage = stageSelection.getSelectedIndex() - 1;
|
||||||
|
checkErrors.setVisible(selectedStage == -1 ? simulation.hasErrors() : simulation.hasErrors(selectedStage));
|
||||||
myPlot.setShowBranch(selectedStage);
|
myPlot.setShowBranch(selectedStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user