From df62f231deea5fa147886c7c904c656dd8a0b852 Mon Sep 17 00:00:00 2001 From: rodinia814 Date: Sun, 25 Mar 2012 15:56:12 +0000 Subject: [PATCH] DGP - design report figure honors rotation angle of main figure; added rocksim constants for future use git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@487 180e2498-e6e9-4542-8430-84ac67f01cd8 --- core/ChangeLog | 5 ++++ .../file/rocksim/RocksimCommonConstants.java | 7 +++--- .../openrocket/gui/dialogs/PrintDialog.java | 15 ++++++----- .../sf/openrocket/gui/main/BasicFrame.java | 6 ++++- .../sf/openrocket/gui/print/DesignReport.java | 12 +++++++-- .../openrocket/gui/print/PrintController.java | 25 ++++++++----------- 6 files changed, 44 insertions(+), 26 deletions(-) diff --git a/core/ChangeLog b/core/ChangeLog index fc746f5d..ab5e9e15 100644 --- a/core/ChangeLog +++ b/core/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java b/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java index 9686b979..431db265 100644 --- a/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java +++ b/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java @@ -79,6 +79,10 @@ public class RocksimCommonConstants { 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. */ @@ -103,7 +107,4 @@ public class RocksimCommonConstants { * 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"; } diff --git a/core/src/net/sf/openrocket/gui/dialogs/PrintDialog.java b/core/src/net/sf/openrocket/gui/dialogs/PrintDialog.java index 729586d3..bf2249ce 100644 --- a/core/src/net/sf/openrocket/gui/dialogs/PrintDialog.java +++ b/core/src/net/sf/openrocket/gui/dialogs/PrintDialog.java @@ -61,22 +61,25 @@ public class PrintDialog extends JDialog implements TreeSelectionListener { 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 @@ -257,7 +260,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener { /** * 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) * @@ -273,7 +276,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener { * 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) * @@ -281,7 +284,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener { */ private File generateReport(File f, PrintSettings settings) throws IOException { Iterator toBePrinted = currentTree.getToBePrinted(); - new PrintController().print(document, toBePrinted, new FileOutputStream(f), settings); + new PrintController().print(document, toBePrinted, new FileOutputStream(f), settings, rotation); return f; } diff --git a/core/src/net/sf/openrocket/gui/main/BasicFrame.java b/core/src/net/sf/openrocket/gui/main/BasicFrame.java index c05c1ba3..b6bb3933 100644 --- a/core/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/core/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -1442,7 +1442,11 @@ public class BasicFrame extends JFrame { * */ 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); } /** diff --git a/core/src/net/sf/openrocket/gui/print/DesignReport.java b/core/src/net/sf/openrocket/gui/print/DesignReport.java index 1af2b13a..2a0edd7e 100644 --- a/core/src/net/sf/openrocket/gui/print/DesignReport.java +++ b/core/src/net/sf/openrocket/gui/print/DesignReport.java @@ -96,7 +96,12 @@ public class DesignReport { * 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): "; @@ -128,11 +133,13 @@ public class DesignReport { * * @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; } /** @@ -156,6 +163,7 @@ public class DesignReport { PdfContentByte canvas = writer.getDirectContent(); final PrintFigure figure = new PrintFigure(configuration); + figure.setRotation(rotation); FigureElement cp = panel.getExtraCP(); FigureElement cg = panel.getExtraCG(); diff --git a/core/src/net/sf/openrocket/gui/print/PrintController.java b/core/src/net/sf/openrocket/gui/print/PrintController.java index 69e4df05..f6e6dba7 100644 --- a/core/src/net/sf/openrocket/gui/print/PrintController.java +++ b/core/src/net/sf/openrocket/gui/print/PrintController.java @@ -35,9 +35,10 @@ public class PrintController { * @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 toBePrinted, OutputStream outputFile, - PrintSettings settings) { + PrintSettings settings, double rotation) { Document idoc = new Document(getSize(settings)); PdfWriter writer = null; @@ -59,23 +60,19 @@ public class PrintController { 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); -- 2.47.2