Clean up code...
This commit is contained in:
parent
587babb566
commit
651ba88a47
@ -151,255 +151,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
//////// The simulation table
|
//////// The simulation table
|
||||||
|
simulationTableModel = new SimulationTableModel();
|
||||||
simulationTableModel = new ColumnTableModel(
|
|
||||||
|
|
||||||
//// Status and warning column
|
|
||||||
new Column("") {
|
|
||||||
private JLabel label = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// Initialize the label
|
|
||||||
if (label == null) {
|
|
||||||
label = new StyledLabel(2f);
|
|
||||||
label.setIconTextGap(1);
|
|
||||||
// label.setFont(label.getFont().deriveFont(Font.BOLD));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set simulation status icon
|
|
||||||
Simulation.Status status = document.getSimulation(row).getStatus();
|
|
||||||
label.setIcon(Icons.SIMULATION_STATUS_ICON_MAP.get(status));
|
|
||||||
|
|
||||||
|
|
||||||
// Set warning marker
|
|
||||||
if (status == Simulation.Status.NOT_SIMULATED ||
|
|
||||||
status == Simulation.Status.EXTERNAL) {
|
|
||||||
|
|
||||||
label.setText("");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
WarningSet w = document.getSimulation(row).getSimulatedWarnings();
|
|
||||||
if (w == null) {
|
|
||||||
label.setText("");
|
|
||||||
} else if (w.isEmpty()) {
|
|
||||||
label.setForeground(OK_COLOR);
|
|
||||||
label.setText(OK_TEXT);
|
|
||||||
} else {
|
|
||||||
label.setForeground(WARNING_COLOR);
|
|
||||||
label.setText(WARNING_TEXT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getExactWidth() {
|
|
||||||
return 36;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<?> getColumnClass() {
|
|
||||||
return JLabel.class;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Simulation name
|
|
||||||
//// Name
|
|
||||||
new Column(trans.get("simpanel.col.Name")) {
|
|
||||||
@Override
|
|
||||||
public Object getValueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
return document.getSimulation(row).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDefaultWidth() {
|
|
||||||
return 125;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<String> getComparator() {
|
|
||||||
return new AlphanumComparator();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Simulation configuration
|
|
||||||
new Column(trans.get("simpanel.col.Configuration")) {
|
|
||||||
@Override
|
|
||||||
public Object getValueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount()){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rocket rkt = document.getRocket();
|
|
||||||
FlightConfigurationId fcid = document.getSimulation(row).getId();
|
|
||||||
return descriptor.format( rkt, fcid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDefaultWidth() {
|
|
||||||
return 125;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Launch rod velocity
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Velocityoffrod"), UnitGroup.UNITS_VELOCITY) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getLaunchRodVelocity();
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Apogee
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Apogee"), UnitGroup.UNITS_DISTANCE) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getMaxAltitude();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Velocity at deployment
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Velocityatdeploy"), UnitGroup.UNITS_VELOCITY) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getDeploymentVelocity();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Deployment Time from Apogee
|
|
||||||
new ValueColumn(trans.get("simpanel.col.OptimumCoastTime"),
|
|
||||||
trans.get("simpanel.col.OptimumCoastTime.ttip"),
|
|
||||||
UnitGroup.UNITS_SHORT_TIME) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null || data.getBranchCount() == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
double val = data.getBranch(0).getOptimumDelay();
|
|
||||||
if ( Double.isNaN(val) ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Maximum velocity
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Maxvelocity"), UnitGroup.UNITS_VELOCITY) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getMaxVelocity();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Maximum acceleration
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Maxacceleration"), UnitGroup.UNITS_ACCELERATION) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getMaxAcceleration();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Time to apogee
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Timetoapogee"), UnitGroup.UNITS_FLIGHT_TIME) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getTimeToApogee();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Flight time
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Flighttime"), UnitGroup.UNITS_FLIGHT_TIME) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getFlightTime();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//// Ground hit velocity
|
|
||||||
new ValueColumn(trans.get("simpanel.col.Groundhitvelocity"), UnitGroup.UNITS_VELOCITY) {
|
|
||||||
@Override
|
|
||||||
public Double valueAt(int row) {
|
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
FlightData data = document.getSimulation(row).getSimulatedData();
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return data.getGroundHitVelocity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
) {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 8686456963492628476L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRowCount() {
|
|
||||||
return document.getSimulationCount();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Override processKeyBinding so that the JTable does not catch
|
// Override processKeyBinding so that the JTable does not catch
|
||||||
// key bindings used in menu accelerators
|
// key bindings used in menu accelerators
|
||||||
@ -971,6 +723,254 @@ public class SimulationPanel extends JPanel {
|
|||||||
|
|
||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SimulationTableModel extends ColumnTableModel {
|
||||||
|
private static final long serialVersionUID = 8686456963492628476L;
|
||||||
|
|
||||||
|
public SimulationTableModel() {
|
||||||
|
super(
|
||||||
|
//// Status and warning column
|
||||||
|
new Column("") {
|
||||||
|
private JLabel label = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Initialize the label
|
||||||
|
if (label == null) {
|
||||||
|
label = new StyledLabel(2f);
|
||||||
|
label.setIconTextGap(1);
|
||||||
|
// label.setFont(label.getFont().deriveFont(Font.BOLD));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set simulation status icon
|
||||||
|
Simulation.Status status = document.getSimulation(row).getStatus();
|
||||||
|
label.setIcon(Icons.SIMULATION_STATUS_ICON_MAP.get(status));
|
||||||
|
|
||||||
|
|
||||||
|
// Set warning marker
|
||||||
|
if (status == Simulation.Status.NOT_SIMULATED ||
|
||||||
|
status == Simulation.Status.EXTERNAL) {
|
||||||
|
|
||||||
|
label.setText("");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
WarningSet w = document.getSimulation(row).getSimulatedWarnings();
|
||||||
|
if (w == null) {
|
||||||
|
label.setText("");
|
||||||
|
} else if (w.isEmpty()) {
|
||||||
|
label.setForeground(OK_COLOR);
|
||||||
|
label.setText(OK_TEXT);
|
||||||
|
} else {
|
||||||
|
label.setForeground(WARNING_COLOR);
|
||||||
|
label.setText(WARNING_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getExactWidth() {
|
||||||
|
return 36;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getColumnClass() {
|
||||||
|
return JLabel.class;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Simulation name
|
||||||
|
//// Name
|
||||||
|
new Column(trans.get("simpanel.col.Name")) {
|
||||||
|
@Override
|
||||||
|
public Object getValueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
return document.getSimulation(row).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDefaultWidth() {
|
||||||
|
return 125;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Comparator<String> getComparator() {
|
||||||
|
return new AlphanumComparator();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Simulation configuration
|
||||||
|
new Column(trans.get("simpanel.col.Configuration")) {
|
||||||
|
@Override
|
||||||
|
public Object getValueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rocket rkt = document.getRocket();
|
||||||
|
FlightConfigurationId fcid = document.getSimulation(row).getId();
|
||||||
|
return descriptor.format(rkt, fcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDefaultWidth() {
|
||||||
|
return 125;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Launch rod velocity
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Velocityoffrod"), UnitGroup.UNITS_VELOCITY) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getLaunchRodVelocity();
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Apogee
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Apogee"), UnitGroup.UNITS_DISTANCE) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getMaxAltitude();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Velocity at deployment
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Velocityatdeploy"), UnitGroup.UNITS_VELOCITY) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getDeploymentVelocity();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Deployment Time from Apogee
|
||||||
|
new ValueColumn(trans.get("simpanel.col.OptimumCoastTime"),
|
||||||
|
trans.get("simpanel.col.OptimumCoastTime.ttip"), UnitGroup.UNITS_SHORT_TIME) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null || data.getBranchCount() == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
double val = data.getBranch(0).getOptimumDelay();
|
||||||
|
if (Double.isNaN(val)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Maximum velocity
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Maxvelocity"), UnitGroup.UNITS_VELOCITY) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getMaxVelocity();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Maximum acceleration
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Maxacceleration"), UnitGroup.UNITS_ACCELERATION) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getMaxAcceleration();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Time to apogee
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Timetoapogee"), UnitGroup.UNITS_FLIGHT_TIME) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getTimeToApogee();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Flight time
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Flighttime"), UnitGroup.UNITS_FLIGHT_TIME) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getFlightTime();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//// Ground hit velocity
|
||||||
|
new ValueColumn(trans.get("simpanel.col.Groundhitvelocity"), UnitGroup.UNITS_VELOCITY) {
|
||||||
|
@Override
|
||||||
|
public Double valueAt(int row) {
|
||||||
|
if (row < 0 || row >= document.getSimulationCount())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FlightData data = document.getSimulation(row).getSimulatedData();
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return data.getGroundHitVelocity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowCount() {
|
||||||
|
return document.getSimulationCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user