DGP - fix to honor launch conditions in printed simulations
This commit is contained in:
parent
bf0e3d978a
commit
acf3505cec
@ -6,13 +6,13 @@ package net.sf.openrocket.gui.print;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
import net.sf.openrocket.gui.figureelements.FigureElement;
|
import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||||
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
||||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.logging.LogHelper;
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
||||||
import net.sf.openrocket.masscalc.MassCalculator;
|
import net.sf.openrocket.masscalc.MassCalculator;
|
||||||
@ -75,7 +75,7 @@ import com.itextpdf.text.pdf.PdfWriter;
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class DesignReport {
|
public class DesignReport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger.
|
* The logger.
|
||||||
*/
|
*/
|
||||||
@ -86,12 +86,12 @@ public class DesignReport {
|
|||||||
* The OR Document.
|
* The OR Document.
|
||||||
*/
|
*/
|
||||||
private OpenRocketDocument rocketDocument;
|
private OpenRocketDocument rocketDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel used for rendering of the design diagram.
|
* A panel used for rendering of the design diagram.
|
||||||
*/
|
*/
|
||||||
final RocketPanel panel;
|
final RocketPanel panel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The iText document.
|
* The iText document.
|
||||||
*/
|
*/
|
||||||
@ -127,7 +127,7 @@ public class DesignReport {
|
|||||||
private static final String LANDING_VELOCITY = "Landing Velocity";
|
private static final String LANDING_VELOCITY = "Landing Velocity";
|
||||||
private static final String ROCKET_DESIGN = "Rocket Design";
|
private static final String ROCKET_DESIGN = "Rocket Design";
|
||||||
private static final double GRAVITY_CONSTANT = 9.80665d;
|
private static final double GRAVITY_CONSTANT = 9.80665d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -141,7 +141,7 @@ public class DesignReport {
|
|||||||
panel = new RocketPanel(rocketDocument);
|
panel = new RocketPanel(rocketDocument);
|
||||||
rotation = figureRotation;
|
rotation = figureRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point. Prints the rocket drawing and design data.
|
* Main entry point. Prints the rocket drawing and design data.
|
||||||
*
|
*
|
||||||
@ -154,23 +154,23 @@ public class DesignReport {
|
|||||||
com.itextpdf.text.Rectangle pageSize = document.getPageSize();
|
com.itextpdf.text.Rectangle pageSize = document.getPageSize();
|
||||||
int pageImageableWidth = (int) pageSize.getWidth() - (int) pageSize.getBorderWidth() * 2;
|
int pageImageableWidth = (int) pageSize.getWidth() - (int) pageSize.getBorderWidth() * 2;
|
||||||
int pageImageableHeight = (int) pageSize.getHeight() / 2 - (int) pageSize.getBorderWidthTop();
|
int pageImageableHeight = (int) pageSize.getHeight() / 2 - (int) pageSize.getBorderWidthTop();
|
||||||
|
|
||||||
PrintUtilities.addText(document, PrintUtilities.BIG_BOLD, ROCKET_DESIGN);
|
PrintUtilities.addText(document, PrintUtilities.BIG_BOLD, ROCKET_DESIGN);
|
||||||
|
|
||||||
Rocket rocket = rocketDocument.getRocket();
|
Rocket rocket = rocketDocument.getRocket();
|
||||||
final Configuration configuration = rocket.getDefaultConfiguration().clone();
|
final Configuration configuration = rocket.getDefaultConfiguration().clone();
|
||||||
configuration.setAllStages();
|
configuration.setAllStages();
|
||||||
PdfContentByte canvas = writer.getDirectContent();
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
final PrintFigure figure = new PrintFigure(configuration);
|
final PrintFigure figure = new PrintFigure(configuration);
|
||||||
figure.setRotation(rotation);
|
figure.setRotation(rotation);
|
||||||
|
|
||||||
FigureElement cp = panel.getExtraCP();
|
FigureElement cp = panel.getExtraCP();
|
||||||
FigureElement cg = panel.getExtraCG();
|
FigureElement cg = panel.getExtraCG();
|
||||||
RocketInfo text = panel.getExtraText();
|
RocketInfo text = panel.getExtraText();
|
||||||
|
|
||||||
double scale = paintRocketDiagram(pageImageableWidth, pageImageableHeight, canvas, figure, cp, cg);
|
double scale = paintRocketDiagram(pageImageableWidth, pageImageableHeight, canvas, figure, cp, cg);
|
||||||
|
|
||||||
canvas.beginText();
|
canvas.beginText();
|
||||||
try {
|
try {
|
||||||
canvas.setFontAndSize(BaseFont.createFont(PrintUtilities.NORMAL.getFamilyname(), BaseFont.CP1252,
|
canvas.setFontAndSize(BaseFont.createFont(PrintUtilities.NORMAL.getFamilyname(), BaseFont.CP1252,
|
||||||
@ -185,14 +185,14 @@ public class DesignReport {
|
|||||||
final int diagramHeight = pageImageableHeight * 2 - 70 - (figHeightPts);
|
final int diagramHeight = pageImageableHeight * 2 - 70 - (figHeightPts);
|
||||||
canvas.moveText(document.leftMargin() + pageSize.getBorderWidthLeft(), diagramHeight);
|
canvas.moveText(document.leftMargin() + pageSize.getBorderWidthLeft(), diagramHeight);
|
||||||
canvas.moveTextWithLeading(0, -16);
|
canvas.moveTextWithLeading(0, -16);
|
||||||
|
|
||||||
float initialY = canvas.getYTLM();
|
float initialY = canvas.getYTLM();
|
||||||
|
|
||||||
canvas.showText(rocketDocument.getRocket().getName());
|
canvas.showText(rocketDocument.getRocket().getName());
|
||||||
|
|
||||||
canvas.newlineShowText(STAGES);
|
canvas.newlineShowText(STAGES);
|
||||||
canvas.showText("" + rocket.getStageCount());
|
canvas.showText("" + rocket.getStageCount());
|
||||||
|
|
||||||
|
|
||||||
if (configuration.hasMotors()) {
|
if (configuration.hasMotors()) {
|
||||||
if (configuration.getStageCount() > 1) {
|
if (configuration.getStageCount() > 1) {
|
||||||
@ -204,28 +204,29 @@ public class DesignReport {
|
|||||||
canvas.newlineShowText(MASS_EMPTY);
|
canvas.newlineShowText(MASS_EMPTY);
|
||||||
}
|
}
|
||||||
canvas.showText(text.getMass(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
canvas.showText(text.getMass(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
||||||
|
|
||||||
canvas.newlineShowText(STABILITY);
|
canvas.newlineShowText(STABILITY);
|
||||||
canvas.showText(text.getStability());
|
canvas.showText(text.getStability());
|
||||||
|
|
||||||
canvas.newlineShowText(CG);
|
canvas.newlineShowText(CG);
|
||||||
canvas.showText(text.getCg());
|
canvas.showText(text.getCg());
|
||||||
|
|
||||||
canvas.newlineShowText(CP);
|
canvas.newlineShowText(CP);
|
||||||
canvas.showText(text.getCp());
|
canvas.showText(text.getCp());
|
||||||
canvas.endText();
|
canvas.endText();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Move the internal pointer of the document below that of what was just written using the direct byte buffer.
|
//Move the internal pointer of the document below that of what was just written using the direct byte buffer.
|
||||||
Paragraph paragraph = new Paragraph();
|
Paragraph paragraph = new Paragraph();
|
||||||
float finalY = canvas.getYTLM();
|
float finalY = canvas.getYTLM();
|
||||||
int heightOfDiagramAndText = (int) (pageSize.getHeight() - (finalY - initialY + diagramHeight));
|
int heightOfDiagramAndText = (int) (pageSize.getHeight() - (finalY - initialY + diagramHeight));
|
||||||
|
|
||||||
paragraph.setSpacingAfter(heightOfDiagramAndText);
|
paragraph.setSpacingAfter(heightOfDiagramAndText);
|
||||||
document.add(paragraph);
|
document.add(paragraph);
|
||||||
|
|
||||||
String[] motorIds = rocket.getMotorConfigurationIDs();
|
String[] motorIds = rocket.getMotorConfigurationIDs();
|
||||||
|
List<Simulation> simulations = rocketDocument.getSimulations();
|
||||||
|
|
||||||
for (int j = 0; j < motorIds.length; j++) {
|
for (int j = 0; j < motorIds.length; j++) {
|
||||||
String motorId = motorIds[j];
|
String motorId = motorIds[j];
|
||||||
if (motorId != null) {
|
if (motorId != null) {
|
||||||
@ -239,7 +240,8 @@ public class DesignReport {
|
|||||||
if (j > 1) {
|
if (j > 1) {
|
||||||
leading = 25;
|
leading = 25;
|
||||||
}
|
}
|
||||||
addFlightData(rocket, motorId, parent, leading);
|
FlightData flight = findSimulation(motorId, simulations);
|
||||||
|
addFlightData(flight, rocket, motorId, parent, leading);
|
||||||
addMotorData(rocket, motorId, parent);
|
addMotorData(rocket, motorId, parent);
|
||||||
document.add(parent);
|
document.add(parent);
|
||||||
}
|
}
|
||||||
@ -248,8 +250,8 @@ public class DesignReport {
|
|||||||
log.error("Could not modify document.", e);
|
log.error("Could not modify document.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint a diagram of the rocket into the PDF document.
|
* Paint a diagram of the rocket into the PDF document.
|
||||||
*
|
*
|
||||||
@ -270,7 +272,7 @@ public class DesignReport {
|
|||||||
theFigure.addRelativeExtra(theCp);
|
theFigure.addRelativeExtra(theCp);
|
||||||
theFigure.addRelativeExtra(theCg);
|
theFigure.addRelativeExtra(theCg);
|
||||||
theFigure.updateFigure();
|
theFigure.updateFigure();
|
||||||
|
|
||||||
double scale =
|
double scale =
|
||||||
(thePageImageableWidth * 2.2) / theFigure.getFigureWidth();
|
(thePageImageableWidth * 2.2) / theFigure.getFigureWidth();
|
||||||
theFigure.setScale(scale);
|
theFigure.setScale(scale);
|
||||||
@ -296,7 +298,7 @@ public class DesignReport {
|
|||||||
g2d.dispose();
|
g2d.dispose();
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the motor data for a motor configuration to the table.
|
* Add the motor data for a motor configuration to the table.
|
||||||
*
|
*
|
||||||
@ -305,11 +307,11 @@ public class DesignReport {
|
|||||||
* @param parent the parent to which the motor data will be added
|
* @param parent the parent to which the motor data will be added
|
||||||
*/
|
*/
|
||||||
private void addMotorData(Rocket rocket, String motorId, final PdfPTable parent) {
|
private void addMotorData(Rocket rocket, String motorId, final PdfPTable parent) {
|
||||||
|
|
||||||
PdfPTable motorTable = new PdfPTable(8);
|
PdfPTable motorTable = new PdfPTable(8);
|
||||||
motorTable.setWidthPercentage(68);
|
motorTable.setWidthPercentage(68);
|
||||||
motorTable.setHorizontalAlignment(Element.ALIGN_LEFT);
|
motorTable.setHorizontalAlignment(Element.ALIGN_LEFT);
|
||||||
|
|
||||||
final PdfPCell motorCell = ITextHelper.createCell(MOTOR, PdfPCell.BOTTOM);
|
final PdfPCell motorCell = ITextHelper.createCell(MOTOR, PdfPCell.BOTTOM);
|
||||||
final int mPad = 10;
|
final int mPad = 10;
|
||||||
motorCell.setPaddingLeft(mPad);
|
motorCell.setPaddingLeft(mPad);
|
||||||
@ -321,25 +323,25 @@ public class DesignReport {
|
|||||||
motorTable.addCell(ITextHelper.createCell(THRUST_TO_WT, PdfPCell.BOTTOM));
|
motorTable.addCell(ITextHelper.createCell(THRUST_TO_WT, PdfPCell.BOTTOM));
|
||||||
motorTable.addCell(ITextHelper.createCell(PROPELLANT_WT, PdfPCell.BOTTOM));
|
motorTable.addCell(ITextHelper.createCell(PROPELLANT_WT, PdfPCell.BOTTOM));
|
||||||
motorTable.addCell(ITextHelper.createCell(SIZE, PdfPCell.BOTTOM));
|
motorTable.addCell(ITextHelper.createCell(SIZE, PdfPCell.BOTTOM));
|
||||||
|
|
||||||
DecimalFormat ttwFormat = new DecimalFormat("0.00");
|
DecimalFormat ttwFormat = new DecimalFormat("0.00");
|
||||||
|
|
||||||
MassCalculator massCalc = new BasicMassCalculator();
|
MassCalculator massCalc = new BasicMassCalculator();
|
||||||
|
|
||||||
Configuration config = new Configuration(rocket);
|
Configuration config = new Configuration(rocket);
|
||||||
config.setMotorConfigurationID(motorId);
|
config.setMotorConfigurationID(motorId);
|
||||||
|
|
||||||
int totalMotorCount = 0;
|
int totalMotorCount = 0;
|
||||||
double totalPropMass = 0;
|
double totalPropMass = 0;
|
||||||
double totalImpulse = 0;
|
double totalImpulse = 0;
|
||||||
double totalTTW = 0;
|
double totalTTW = 0;
|
||||||
|
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
double stageMass = 0;
|
double stageMass = 0;
|
||||||
|
|
||||||
boolean topBorder = false;
|
boolean topBorder = false;
|
||||||
for (RocketComponent c : rocket) {
|
for (RocketComponent c : rocket) {
|
||||||
|
|
||||||
if (c instanceof Stage) {
|
if (c instanceof Stage) {
|
||||||
config.setToStage(stage);
|
config.setToStage(stage);
|
||||||
stage++;
|
stage++;
|
||||||
@ -348,26 +350,26 @@ public class DesignReport {
|
|||||||
totalTTW = 0;
|
totalTTW = 0;
|
||||||
topBorder = true;
|
topBorder = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
|
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
|
||||||
MotorMount mount = (MotorMount) c;
|
MotorMount mount = (MotorMount) c;
|
||||||
|
|
||||||
if (mount.isMotorMount() && mount.getMotor(motorId) != null) {
|
if (mount.isMotorMount() && mount.getMotor(motorId) != null) {
|
||||||
Motor motor = mount.getMotor(motorId);
|
Motor motor = mount.getMotor(motorId);
|
||||||
int motorCount = c.toAbsolute(Coordinate.NUL).length;
|
int motorCount = c.toAbsolute(Coordinate.NUL).length;
|
||||||
|
|
||||||
|
|
||||||
int border = Rectangle.NO_BORDER;
|
int border = Rectangle.NO_BORDER;
|
||||||
if (topBorder) {
|
if (topBorder) {
|
||||||
border = Rectangle.TOP;
|
border = Rectangle.TOP;
|
||||||
topBorder = false;
|
topBorder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = motor.getDesignation();
|
String name = motor.getDesignation();
|
||||||
if (motorCount > 1) {
|
if (motorCount > 1) {
|
||||||
name += " (" + Chars.TIMES + motorCount + ")";
|
name += " (" + Chars.TIMES + motorCount + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
final PdfPCell motorVCell = ITextHelper.createCell(name, border);
|
final PdfPCell motorVCell = ITextHelper.createCell(name, border);
|
||||||
motorVCell.setPaddingLeft(mPad);
|
motorVCell.setPaddingLeft(mPad);
|
||||||
motorTable.addCell(motorVCell);
|
motorTable.addCell(motorVCell);
|
||||||
@ -379,21 +381,21 @@ public class DesignReport {
|
|||||||
UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(motor.getMaxThrustEstimate()), border));
|
UnitGroup.UNITS_FORCE.getDefaultUnit().toStringUnit(motor.getMaxThrustEstimate()), border));
|
||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
UnitGroup.UNITS_IMPULSE.getDefaultUnit().toStringUnit(motor.getTotalImpulseEstimate()), border));
|
UnitGroup.UNITS_IMPULSE.getDefaultUnit().toStringUnit(motor.getTotalImpulseEstimate()), border));
|
||||||
|
|
||||||
double ttw = motor.getAverageThrustEstimate() / (stageMass * GRAVITY_CONSTANT);
|
double ttw = motor.getAverageThrustEstimate() / (stageMass * GRAVITY_CONSTANT);
|
||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
ttwFormat.format(ttw) + ":1", border));
|
ttwFormat.format(ttw) + ":1", border));
|
||||||
|
|
||||||
double propMass = (motor.getLaunchCG().weight - motor.getEmptyCG().weight);
|
double propMass = (motor.getLaunchCG().weight - motor.getEmptyCG().weight);
|
||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(propMass), border));
|
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(propMass), border));
|
||||||
|
|
||||||
final Unit motorUnit = UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit();
|
final Unit motorUnit = UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit();
|
||||||
motorTable.addCell(ITextHelper.createCell(motorUnit.toString(motor.getDiameter()) +
|
motorTable.addCell(ITextHelper.createCell(motorUnit.toString(motor.getDiameter()) +
|
||||||
"/" +
|
"/" +
|
||||||
motorUnit.toString(motor.getLength()) + " " +
|
motorUnit.toString(motor.getLength()) + " " +
|
||||||
motorUnit.toString(), border));
|
motorUnit.toString(), border));
|
||||||
|
|
||||||
// Sum up total count
|
// Sum up total count
|
||||||
totalMotorCount += motorCount;
|
totalMotorCount += motorCount;
|
||||||
totalPropMass += propMass * motorCount;
|
totalPropMass += propMass * motorCount;
|
||||||
@ -402,7 +404,7 @@ public class DesignReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalMotorCount > 1) {
|
if (totalMotorCount > 1) {
|
||||||
int border = Rectangle.TOP;
|
int border = Rectangle.TOP;
|
||||||
final PdfPCell motorVCell = ITextHelper.createCell("Total:", border);
|
final PdfPCell motorVCell = ITextHelper.createCell("Total:", border);
|
||||||
@ -418,78 +420,67 @@ public class DesignReport {
|
|||||||
motorTable.addCell(ITextHelper.createCell(
|
motorTable.addCell(ITextHelper.createCell(
|
||||||
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(totalPropMass), border));
|
UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(totalPropMass), border));
|
||||||
motorTable.addCell(ITextHelper.createCell("", border));
|
motorTable.addCell(ITextHelper.createCell("", border));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfPCell c = new PdfPCell(motorTable);
|
PdfPCell c = new PdfPCell(motorTable);
|
||||||
c.setBorder(PdfPCell.LEFT);
|
c.setBorder(PdfPCell.LEFT);
|
||||||
c.setBorderWidthTop(0f);
|
c.setBorderWidthTop(0f);
|
||||||
parent.addCell(c);
|
parent.addCell(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the motor data for a motor configuration to the table.
|
* Add the flight data for a simulation configuration to the table.
|
||||||
*
|
*
|
||||||
|
* @param flight the flight data for a single simulation
|
||||||
* @param theRocket the rocket
|
* @param theRocket the rocket
|
||||||
* @param motorId a motor configuration id
|
* @param motorId a motor configuration id
|
||||||
* @param parent the parent to which the motor data will be added
|
* @param parent the parent to which the simulation flight data will be added
|
||||||
* @param leading the number of points for the leading
|
* @param leading the number of points for the leading
|
||||||
*/
|
*/
|
||||||
private void addFlightData(final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
private void addFlightData(final FlightData flight, final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
||||||
|
|
||||||
// Perform flight simulation
|
// Output the flight data
|
||||||
Rocket duplicate = theRocket.copyWithOriginalID();
|
|
||||||
FlightData flight = null;
|
|
||||||
try {
|
|
||||||
Simulation simulation = ((SwingPreferences)Application.getPreferences()).getBackgroundSimulation(duplicate);
|
|
||||||
simulation.getOptions().setMotorConfigurationID(motorId);
|
|
||||||
simulation.simulate();
|
|
||||||
flight = simulation.getSimulatedData();
|
|
||||||
} catch (SimulationException e1) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output the flight data
|
|
||||||
if (flight != null) {
|
if (flight != null) {
|
||||||
try {
|
try {
|
||||||
final Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
final Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
||||||
final Unit velocityUnit = UnitGroup.UNITS_VELOCITY.getDefaultUnit();
|
final Unit velocityUnit = UnitGroup.UNITS_VELOCITY.getDefaultUnit();
|
||||||
final Unit flightTimeUnit = UnitGroup.UNITS_FLIGHT_TIME.getDefaultUnit();
|
final Unit flightTimeUnit = UnitGroup.UNITS_FLIGHT_TIME.getDefaultUnit();
|
||||||
|
|
||||||
PdfPTable labelTable = new PdfPTable(2);
|
PdfPTable labelTable = new PdfPTable(2);
|
||||||
labelTable.setWidths(new int[] { 3, 2 });
|
labelTable.setWidths(new int[] { 3, 2 });
|
||||||
final Paragraph chunk = ITextHelper.createParagraph(stripBrackets(
|
final Paragraph chunk = ITextHelper.createParagraph(stripBrackets(
|
||||||
theRocket.getMotorConfigurationNameOrDescription(motorId)), PrintUtilities.BOLD);
|
theRocket.getMotorConfigurationNameOrDescription(motorId)), PrintUtilities.BOLD);
|
||||||
chunk.setLeading(leading);
|
chunk.setLeading(leading);
|
||||||
chunk.setSpacingAfter(3f);
|
chunk.setSpacingAfter(3f);
|
||||||
|
|
||||||
document.add(chunk);
|
document.add(chunk);
|
||||||
|
|
||||||
final PdfPCell cell = ITextHelper.createCell(ALTITUDE, 2, 2);
|
final PdfPCell cell = ITextHelper.createCell(ALTITUDE, 2, 2);
|
||||||
cell.setUseBorderPadding(false);
|
cell.setUseBorderPadding(false);
|
||||||
cell.setBorderWidthTop(0f);
|
cell.setBorderWidthTop(0f);
|
||||||
labelTable.addCell(cell);
|
labelTable.addCell(cell);
|
||||||
labelTable.addCell(ITextHelper.createCell(distanceUnit.toStringUnit(flight.getMaxAltitude()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(distanceUnit.toStringUnit(flight.getMaxAltitude()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(FLIGHT_TIME, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(FLIGHT_TIME, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getFlightTime()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getFlightTime()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(TIME_TO_APOGEE, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(TIME_TO_APOGEE, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getTimeToApogee()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(flightTimeUnit.toStringUnit(flight.getTimeToApogee()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(VELOCITY_OFF_PAD, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(VELOCITY_OFF_PAD, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getLaunchRodVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getLaunchRodVelocity()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(MAX_VELOCITY, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(MAX_VELOCITY, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getMaxVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getMaxVelocity()), 2, 2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(DEPLOYMENT_VELOCITY, 2,2));
|
labelTable.addCell(ITextHelper.createCell(DEPLOYMENT_VELOCITY, 2,2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getDeploymentVelocity()),2,2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getDeploymentVelocity()),2,2));
|
||||||
|
|
||||||
labelTable.addCell(ITextHelper.createCell(LANDING_VELOCITY, 2, 2));
|
labelTable.addCell(ITextHelper.createCell(LANDING_VELOCITY, 2, 2));
|
||||||
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getGroundHitVelocity()), 2, 2));
|
labelTable.addCell(ITextHelper.createCell(velocityUnit.toStringUnit(flight.getGroundHitVelocity()), 2, 2));
|
||||||
|
|
||||||
//Add the table to the parent; have to wrap it in a cell
|
//Add the table to the parent; have to wrap it in a cell
|
||||||
PdfPCell c = new PdfPCell(labelTable);
|
PdfPCell c = new PdfPCell(labelTable);
|
||||||
c.setBorder(PdfPCell.RIGHT);
|
c.setBorder(PdfPCell.RIGHT);
|
||||||
@ -501,8 +492,36 @@ public class DesignReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Locate the simulation based on the motor id. Copy the simulation and execute it, then return the resulting
|
||||||
|
* flight data.
|
||||||
|
*
|
||||||
|
* @param motorId the motor id corresponding to the simulation to find
|
||||||
|
* @param simulations the list of simulations currently associated with the rocket
|
||||||
|
*
|
||||||
|
* @return the flight data from the simulation for the specified motor id, or null if not found
|
||||||
|
*/
|
||||||
|
private FlightData findSimulation(final String motorId, List<Simulation> simulations) {
|
||||||
|
// Perform flight simulation
|
||||||
|
FlightData flight = null;
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < simulations.size(); i++) {
|
||||||
|
Simulation simulation = simulations.get(i);
|
||||||
|
if (simulation.getOptions().getMotorConfigurationID().equals(motorId)) {
|
||||||
|
simulation = simulation.copy();
|
||||||
|
simulation.simulate();
|
||||||
|
flight = simulation.getSimulatedData();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SimulationException e1) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
return flight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Strip [] brackets from a string.
|
* Strip [] brackets from a string.
|
||||||
*
|
*
|
||||||
* @param target the original string
|
* @param target the original string
|
||||||
@ -512,7 +531,7 @@ public class DesignReport {
|
|||||||
private String stripBrackets(String target) {
|
private String stripBrackets(String target) {
|
||||||
return stripLeftBracket(stripRightBracket(target));
|
return stripLeftBracket(stripRightBracket(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip [ from a string.
|
* Strip [ from a string.
|
||||||
*
|
*
|
||||||
@ -523,7 +542,7 @@ public class DesignReport {
|
|||||||
private String stripLeftBracket(String target) {
|
private String stripLeftBracket(String target) {
|
||||||
return target.replace("[", "");
|
return target.replace("[", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip ] from a string.
|
* Strip ] from a string.
|
||||||
*
|
*
|
||||||
@ -534,5 +553,5 @@ public class DesignReport {
|
|||||||
private String stripRightBracket(String target) {
|
private String stripRightBracket(String target) {
|
||||||
return target.replace("]", "");
|
return target.replace("]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user