DGP - change to design figure offset to prevent the image from creeping off the top of the page

This commit is contained in:
Doug Pedrick 2012-03-19 05:23:54 +00:00
parent 9cfea90a52
commit 212442d9f0
3 changed files with 18 additions and 8 deletions

View File

@ -80,6 +80,7 @@ public class DesignReport {
* The logger. * The logger.
*/ */
private static final LogHelper log = Application.getLogger(); private static final LogHelper log = Application.getLogger();
public static final double SCALE_FUDGE_FACTOR = 0.4d;
/** /**
* The OR Document. * The OR Document.
@ -264,7 +265,6 @@ public class DesignReport {
double scale = double scale =
(thePageImageableWidth * 2.2) / theFigure.getFigureWidth(); (thePageImageableWidth * 2.2) / theFigure.getFigureWidth();
theFigure.setScale(scale); 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 * page dimensions are in points-per-inch, which, in Java2D, are the same as pixels-per-inch; thus we don't need any conversion
@ -272,12 +272,18 @@ public class DesignReport {
theFigure.setSize(thePageImageableWidth, thePageImageableHeight); theFigure.setSize(thePageImageableWidth, thePageImageableHeight);
theFigure.updateFigure(); theFigure.updateFigure();
final DefaultFontMapper mapper = new DefaultFontMapper(); final DefaultFontMapper mapper = new DefaultFontMapper();
Graphics2D g2d = theCanvas.createGraphics(thePageImageableWidth, thePageImageableHeight * 2, mapper); Graphics2D g2d = theCanvas.createGraphics(thePageImageableWidth, thePageImageableHeight * 2, mapper);
g2d.translate(20, 120); 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(0.4d, 0.4d); g2d.scale(SCALE_FUDGE_FACTOR, SCALE_FUDGE_FACTOR);
theFigure.paint(g2d); theFigure.paint(g2d);
g2d.dispose(); g2d.dispose();
return scale; return scale;

View File

@ -31,4 +31,8 @@ public class PrintFigure extends RocketFigure {
this.scale = theScale; //dpi/0.0254*scaling; this.scale = theScale; //dpi/0.0254*scaling;
updateFigure(); updateFigure();
} }
public double getFigureHeightPx() {
return this.figureHeightPx;
}
} }

View File

@ -77,7 +77,7 @@ public class RocketFigure extends AbstractScaleFigure {
private double minX = 0, maxX = 0, maxR = 0; private double minX = 0, maxX = 0, maxR = 0;
// Figure width and height in SI-units and pixels // Figure width and height in SI-units and pixels
private double figureWidth = 0, figureHeight = 0; private double figureWidth = 0, figureHeight = 0;
private int figureWidthPx = 0, figureHeightPx = 0; protected int figureWidthPx = 0, figureHeightPx = 0;
private AffineTransform g2transformation = null; private AffineTransform g2transformation = null;