Clean up some code in DesignReport
Clean up some of the code in DesignReport, including some refactoring TODOs in the addMotorData method. Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
parent
ca64e9e82a
commit
d5598d7380
@ -29,6 +29,7 @@ import net.sf.openrocket.gui.figureelements.RocketInfo;
|
||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||
import net.sf.openrocket.masscalc.MassCalculator;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
@ -162,7 +163,7 @@ public class DesignReport {
|
||||
PrintUtilities.addText(document, PrintUtilities.BIG_BOLD, ROCKET_DESIGN);
|
||||
|
||||
Rocket rocket = rocketDocument.getRocket();
|
||||
final FlightConfiguration configuration = rocket.getSelectedConfiguration();//.clone();
|
||||
final FlightConfiguration configuration = rocket.getSelectedConfiguration();
|
||||
configuration.setAllStages();
|
||||
PdfContentByte canvas = writer.getDirectContent();
|
||||
|
||||
@ -190,7 +191,6 @@ public class DesignReport {
|
||||
canvas.newlineShowText(STAGES);
|
||||
canvas.showText("" + rocket.getStageCount());
|
||||
|
||||
|
||||
if (configuration.hasMotors()) {
|
||||
if (configuration.getStageCount() > 1) {
|
||||
canvas.newlineShowText(MASS_WITH_MOTORS);
|
||||
@ -361,11 +361,19 @@ public class DesignReport {
|
||||
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
|
||||
MotorMount mount = (MotorMount) c;
|
||||
|
||||
// TODO: refactor this... it's redundant with containing if, and could probably be simplified
|
||||
if (mount.isMotorMount() && (mount.getMotorConfig(motorId) != null) &&(null != mount.getMotorConfig(motorId).getMotor())) {
|
||||
Motor motor = mount.getMotorConfig(motorId).getMotor();
|
||||
int motorCount = mount.getMotorCount();
|
||||
MotorConfiguration motorConfig = mount.getMotorConfig(motorId);
|
||||
if (null == motorConfig) {
|
||||
log.warn("Unable to find motorConfig for motorId {}", motorId);
|
||||
continue;
|
||||
}
|
||||
|
||||
Motor motor = motorConfig.getMotor();
|
||||
if (null == motor) {
|
||||
log.warn("Motor instance is null for motorId {}", motorId);
|
||||
continue;
|
||||
}
|
||||
|
||||
int motorCount = mount.getMotorCount();
|
||||
|
||||
int border = Rectangle.NO_BORDER;
|
||||
if (topBorder) {
|
||||
@ -411,7 +419,6 @@ public class DesignReport {
|
||||
totalTTW += ttw * motorCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalMotorCount > 1) {
|
||||
int border = Rectangle.TOP;
|
||||
|
Loading…
x
Reference in New Issue
Block a user