From: Jeremias Maerki Date: Thu, 10 Nov 2005 16:00:03 +0000 (+0000) Subject: Get rid of annoying source of calculation inaccuracies. X-Git-Tag: fop-0_90-alpha1~63 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1c8b099ab71bda44223acaf39c0939c977f7d58b;p=xmlgraphics-fop.git Get rid of annoying source of calculation inaccuracies. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@332315 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index bdb92eb35..71a645c63 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -69,7 +69,9 @@ import org.apache.fop.render.XMLHandlerRegistry; public class FOUserAgent { /** Defines the default resolution (72dpi) for FOP */ - public static final float DEFAULT_PX2MM = (25.4f / 72); //dpi (=25.4/dpi) + public static final float DEFAULT_RESOLUTION = 72.0f; //dpi + /** Defines the default resolution (72dpi) for FOP */ + public static final float DEFAULT_PX2MM = (25.4f / DEFAULT_RESOLUTION); //dpi (=25.4/dpi) /** Defines the default page-height */ public static final String DEFAULT_PAGE_HEIGHT = "11in"; /** Defines the default page-width */ @@ -86,7 +88,7 @@ public class FOUserAgent { private URIResolver foURIResolver = new FOURIResolver(); private PDFEncryptionParams pdfEncryptionParams; - private float px2mm = DEFAULT_PX2MM; + private float resolution = DEFAULT_RESOLUTION; private String pageHeight = DEFAULT_PAGE_HEIGHT; private String pageWidth = DEFAULT_PAGE_WIDTH; private Map rendererOptions = new java.util.HashMap(); @@ -377,12 +379,15 @@ public class FOUserAgent { log.info("Base URL set to: " + baseURL); } if (userConfig.getChild("pixelToMillimeter", false) != null) { - this.px2mm = userConfig.getChild("pixelToMillimeter") + this.resolution = 25.4f / userConfig.getChild("pixelToMillimeter") .getAttributeAsFloat("value", DEFAULT_PX2MM); - log.info("pixelToMillimeter set to: " + px2mm + " (" + (25.4f / px2mm) + "dpi)"); + log.info("resolution set to: " + resolution + + "dpi (px2mm=" + getPixelUnitToMillimeter() + ")"); } else if (userConfig.getChild("resolution", false) != null) { - this.px2mm = 25.4f / userConfig.getChild("resolution").getValueAsFloat(DEFAULT_PX2MM); - log.info("pixelToMillimeter set to: " + px2mm + " (" + (25.4f / px2mm) + "dpi)"); + this.resolution + = 25.4f / userConfig.getChild("resolution").getValueAsFloat(DEFAULT_RESOLUTION); + log.info("resolution set to: " + resolution + + "dpi (px2mm=" + getPixelUnitToMillimeter() + ")"); } Configuration pageConfig = userConfig.getChild("default-page-settings"); if (pageConfig.getAttribute("height", null) != null) { @@ -527,7 +532,12 @@ public class FOUserAgent { * @return float conversion factor */ public float getPixelUnitToMillimeter() { - return this.px2mm; + return 25.4f / this.resolution; + } + + /** @return the resolution for resolution-dependant output */ + public float getResolution() { + return this.resolution; } /** @@ -535,7 +545,7 @@ public class FOUserAgent { * @param dpi resolution in dpi */ public void setResolution(int dpi) { - this.px2mm = (float)(25.4 / dpi); + this.resolution = dpi; } /**