]> git.gag.com Git - debian/openrocket/commitdiff
DGP - design report figure honors rotation angle of main figure; added rocksim consta...
authorrodinia814 <rodinia814@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 25 Mar 2012 15:56:12 +0000 (15:56 +0000)
committerrodinia814 <rodinia814@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 25 Mar 2012 15:56:12 +0000 (15:56 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@487 180e2498-e6e9-4542-8430-84ac67f01cd8

core/ChangeLog
core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java
core/src/net/sf/openrocket/gui/dialogs/PrintDialog.java
core/src/net/sf/openrocket/gui/main/BasicFrame.java
core/src/net/sf/openrocket/gui/print/DesignReport.java
core/src/net/sf/openrocket/gui/print/PrintController.java

index fc746f5d817a0b0feb9d545c8722e3bc7f2fb410..ab5e9e15220b94bd3fd901b5d45f6b9ac70810b5 100644 (file)
@@ -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
index 9686b9794a481f5f08dadcc331274509f93a5dad..431db2650dd2cde09d0ad207e33250769252d28e 100644 (file)
@@ -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";
 }
index 729586d3455e70e69423fbbc5200ab2942051360..bf2249ced76e5e22aeb491e1ec5af0d631720b8e 100644 (file)
@@ -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<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;
        }
        
index c05c1ba34dd82b9a39ded5737a5d2a9336445bb3..b6bb3933091441fbe081fe1fe3b8cad1fc8a59f2 100644 (file)
@@ -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);
        }
        
        /**
index 1af2b13a3280ca8ffbe8b88bcd67acab25c26182..2a0edd7e49ad559dfd9828793c3b379e00838c1e 100644 (file)
@@ -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();
index 69e4df057b2e1d392be51a167c2d4524009bebe7..f6e6dba71d22b05d6b9eef511a35cd5493e5ca20 100644 (file)
@@ -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<PrintableContext> 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);