aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-11-10 16:00:03 +0000
committerJeremias Maerki <jeremias@apache.org>2005-11-10 16:00:03 +0000
commit1c8b099ab71bda44223acaf39c0939c977f7d58b (patch)
tree0be73e274629f741c981e2f12ddec531f210d9b7 /src
parent13a3f8ffed7661ad52f61195fc8dc6f5fcf202ab (diff)
downloadxmlgraphics-fop-1c8b099ab71bda44223acaf39c0939c977f7d58b.tar.gz
xmlgraphics-fop-1c8b099ab71bda44223acaf39c0939c977f7d58b.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/apps/FOUserAgent.java26
1 files changed, 18 insertions, 8 deletions
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;
}
/**