+2012-03-25 Doug Pedrick
+
+ * Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
+ figure was clipped in the page margin.
+
2012-03-18 Jason Blood
* Updated importing images to freeform fin sets to work with color images with improved description
public static final String ROCK_SIM_DOCUMENT = "RockSimDocument";
public static final String FILE_VERSION = "FileVersion";
public static final String DESIGN_INFORMATION = "DesignInformation";
+ public static final String TUBE_FIN_SET = "TubeFinSet";
+ public static final String RING_TAIL = "RingTail";
+ public static final String EXTERNAL_POD = "ExternalPod";
+
/**
* Length conversion. Rocksim is in millimeters, OpenRocket in meters.
*/
* Radius conversion. Rocksim is always in diameters, OpenRocket mostly in radius.
*/
public static final int ROCKSIM_TO_OPENROCKET_RADIUS = 2 * ROCKSIM_TO_OPENROCKET_LENGTH;
- public static final String TUBE_FIN_SET = "TubeFinSet";
- public static final String RING_TAIL = "RingTail";
- public static final String EXTERNAL_POD = "ExternalPod";
}
private JButton previewButton;
private JButton saveAsPDF;
private JButton cancel;
-
+
+ private double rotation = 0d;
private final static SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
/**
* Constructor.
*
+ * @param parent the parent awt component
* @param orDocument the OR rocket container
+ * @param theRotation the angle of rocket figure rotation
*/
- public PrintDialog(Window parent, OpenRocketDocument orDocument) {
+ public PrintDialog(Window parent, OpenRocketDocument orDocument, double theRotation) {
super(parent, trans.get("title"), ModalityType.APPLICATION_MODAL);
JPanel panel = new JPanel(new MigLayout("fill, gap rel unrel"));
this.add(panel);
-
+ rotation = theRotation;
// before any Desktop APIs are used, first check whether the API is
// supported by this particular VM on this particular host
/**
* Generate a report using a temporary file. The file will be deleted upon JVM exit.
*
- * @param paper the name of the paper size
+ * @param settings the container of different print settings
*
* @return a file, populated with the "printed" output (the rocket info)
*
* Generate a report to a specified file.
*
* @param f the file to which rocket data will be written
- * @param paper the name of the paper size
+ * @param settings the container of different print settings
*
* @return a file, populated with the "printed" output (the rocket info)
*
*/
private File generateReport(File f, PrintSettings settings) throws IOException {
Iterator<PrintableContext> toBePrinted = currentTree.getToBePrinted();
- new PrintController().print(document, toBePrinted, new FileOutputStream(f), settings);
+ new PrintController().print(document, toBePrinted, new FileOutputStream(f), settings, rotation);
return f;
}
*
*/
public void printAction() {
- new PrintDialog(this, document).setVisible(true);
+ Double rotation = rocketpanel.getFigure().getRotation();
+ if (rotation == null) {
+ rotation = 0d;
+ }
+ new PrintDialog(this, document, rotation).setVisible(true);
}
/**
* The iText document.
*/
protected Document document;
-
+
+ /**
+ * The figure rotation.
+ */
+ private double rotation = 0d;
+
/** The displayed strings. */
private static final String STAGES = "Stages: ";
private static final String MASS_WITH_MOTORS = "Mass (with motors): ";
*
* @param theRocDoc the OR document
* @param theIDoc the iText document
+ * @param figureRotation the angle the figure is rotated on the screen; printed report will mimic
*/
- public DesignReport(OpenRocketDocument theRocDoc, Document theIDoc) {
+ public DesignReport(OpenRocketDocument theRocDoc, Document theIDoc, Double figureRotation) {
document = theIDoc;
rocketDocument = theRocDoc;
panel = new RocketPanel(rocketDocument);
+ rotation = figureRotation;
}
/**
PdfContentByte canvas = writer.getDirectContent();
final PrintFigure figure = new PrintFigure(configuration);
+ figure.setRotation(rotation);
FigureElement cp = panel.getExtraCP();
FigureElement cg = panel.getExtraCG();
* @param toBePrinted the user chosen items to print
* @param outputFile the file being written to
* @param settings the print settings
+ * @param rotation the angle the rocket figure is rotated
*/
public void print(OpenRocketDocument doc, Iterator<PrintableContext> toBePrinted, OutputStream outputFile,
- PrintSettings settings) {
+ PrintSettings settings, double rotation) {
Document idoc = new Document(getSize(settings));
PdfWriter writer = null;
switch (printableContext.getPrintable()) {
case DESIGN_REPORT:
- DesignReport dp = new DesignReport(doc, idoc);
+ DesignReport dp = new DesignReport(doc, idoc, rotation);
dp.writeToDocument(writer);
idoc.newPage();
break;
case FIN_TEMPLATE:
- final FinSetPrintStrategy finWriter = new FinSetPrintStrategy(idoc,
- writer,
- stages);
- finWriter.writeToDocument(doc.getRocket());
- break;
- case PARTS_DETAIL:
- final PartsDetailVisitorStrategy detailVisitor = new PartsDetailVisitorStrategy(idoc,
- writer,
- stages);
- detailVisitor.writeToDocument(doc.getRocket());
- detailVisitor.close();
- idoc.newPage();
+ final FinSetPrintStrategy finWriter = new FinSetPrintStrategy(idoc, writer, stages);
+ finWriter.writeToDocument(doc.getRocket());
+ break;
+ case PARTS_DETAIL:
+ final PartsDetailVisitorStrategy detailVisitor = new PartsDetailVisitorStrategy(idoc, writer, stages);
+ detailVisitor.writeToDocument(doc.getRocket());
+ detailVisitor.close();
+ idoc.newPage();
break;
case TRANSITION_TEMPLATE:
final TransitionStrategy tranWriter = new TransitionStrategy(idoc, writer, stages);