]> git.gag.com Git - debian/openrocket/commitdiff
DGP - change to design figure offset to prevent the image from creeping off the top...
authorrodinia814 <rodinia814@180e2498-e6e9-4542-8430-84ac67f01cd8>
Mon, 19 Mar 2012 05:23:54 +0000 (05:23 +0000)
committerrodinia814 <rodinia814@180e2498-e6e9-4542-8430-84ac67f01cd8>
Mon, 19 Mar 2012 05:23:54 +0000 (05:23 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@475 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/gui/print/DesignReport.java
core/src/net/sf/openrocket/gui/print/PrintFigure.java
core/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java

index e6290c3e906e6aee23db04d3ac7ad828c916457e..1af2b13a3280ca8ffbe8b88bcd67acab25c26182 100644 (file)
@@ -80,8 +80,9 @@ public class DesignReport {
         * The logger.
         */
        private static final LogHelper log = Application.getLogger();
-       
-       /**
+    public static final double SCALE_FUDGE_FACTOR = 0.4d;
+
+    /**
         * The OR Document.
         */
        private OpenRocketDocument rocketDocument;
@@ -264,20 +265,25 @@ public class DesignReport {
                
                double scale =
                                (thePageImageableWidth * 2.2) / theFigure.getFigureWidth();
-               
                theFigure.setScale(scale);
                /*
                 * page dimensions are in points-per-inch, which, in Java2D, are the same as pixels-per-inch; thus we don't need any conversion
                 */
                theFigure.setSize(thePageImageableWidth, thePageImageableHeight);
                theFigure.updateFigure();
-               
 
                final DefaultFontMapper mapper = new DefaultFontMapper();
                Graphics2D g2d = theCanvas.createGraphics(thePageImageableWidth, thePageImageableHeight * 2, mapper);
-               g2d.translate(20, 120);
-               
-               g2d.scale(0.4d, 0.4d);
+        final double halfFigureHeight = SCALE_FUDGE_FACTOR * theFigure.getFigureHeightPx()/2;
+        int y = PrintUnit.POINTS_PER_INCH;
+        //If the y dimension is negative, then it will potentially be drawn off the top of the page.  Move the origin
+        //to allow for this.
+        if (theFigure.getDimensions().getY() < 0.0d) {
+            y += (int)halfFigureHeight;
+        }
+        g2d.translate(20, y);
+
+               g2d.scale(SCALE_FUDGE_FACTOR, SCALE_FUDGE_FACTOR);
                theFigure.paint(g2d);
                g2d.dispose();
                return scale;
index 3f4655c6a1871a2b245f12fc94ccb62a8a2bedf3..648e7231ba58e1d669db7f4269a7843547431824 100644 (file)
@@ -31,4 +31,8 @@ public class PrintFigure extends RocketFigure {
                this.scale = theScale; //dpi/0.0254*scaling;
                updateFigure();
        }
+
+    public double getFigureHeightPx() {
+        return this.figureHeightPx;
+    }
 }
index 854eb17a1b4ad1555b0d01345ff1f782bb3ef3ef..bd63d8ba1c01500178f0481fb275752d1131df6e 100644 (file)
@@ -77,7 +77,7 @@ public class RocketFigure extends AbstractScaleFigure {
        private double minX = 0, maxX = 0, maxR = 0;
        // Figure width and height in SI-units and pixels
        private double figureWidth = 0, figureHeight = 0;
-       private int figureWidthPx = 0, figureHeightPx = 0;
+       protected int figureWidthPx = 0, figureHeightPx = 0;
        
        private AffineTransform g2transformation = null;