diff options
author | Andreas L. Delmelle <adelmelle@apache.org> | 2008-02-02 22:18:30 +0000 |
---|---|---|
committer | Andreas L. Delmelle <adelmelle@apache.org> | 2008-02-02 22:18:30 +0000 |
commit | 8e49549a9f59b5ee87a1c060fa9801916adf153d (patch) | |
tree | 122f195dc47b26192d1dd93aeac6a8d667ef7966 /src | |
parent | 9ed3838a87bc617a7119df4eee47ea6f6f27bc19 (diff) | |
download | xmlgraphics-fop-8e49549a9f59b5ee87a1c060fa9801916adf153d.tar.gz xmlgraphics-fop-8e49549a9f59b5ee87a1c060fa9801916adf153d.zip |
Slight correction for pixel-values: pass the ratio of pixels-per-point into FixedLength.getInstance()
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@617909 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/fo/expr/PropertyParser.java | 31 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/properties/LengthProperty.java | 24 |
2 files changed, 27 insertions, 28 deletions
diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index 6dcbb0b0a..d8f45790e 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.java @@ -19,7 +19,6 @@ package org.apache.fop.fo.expr; -import org.apache.fop.apps.FOUserAgent; import org.apache.fop.datatypes.Numeric; import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.properties.ColorProperty; @@ -266,8 +265,8 @@ public final class PropertyParser extends PropertyTokenizer { * Get the length base value object from the Maker. If null, then * this property can't have % values. Treat it as a real number. */ - double pcval = new Double(currentTokenValue.substring(0, - currentTokenValue.length() - 1)).doubleValue() / 100.0; + double pcval = Double.parseDouble( + currentTokenValue.substring(0, currentTokenValue.length() - 1)) / 100.0; PercentBase pcBase = this.propInfo.getPercentBase(); if (pcBase != null) { if (pcBase.getDimension() == 0) { @@ -287,22 +286,30 @@ public final class PropertyParser extends PropertyTokenizer { // A number plus a valid unit name. int numLen = currentTokenValue.length() - currentUnitLength; String unitPart = currentTokenValue.substring(numLen); - Double numPart = new Double(currentTokenValue.substring(0, - numLen)); - if (unitPart.equals(RELUNIT)) { + double numPart = Double.parseDouble(currentTokenValue.substring(0, numLen)); + if (RELUNIT.equals(unitPart)) { prop = (Property) NumericOp.multiply( - NumberProperty.getInstance(numPart.doubleValue()), + NumberProperty.getInstance(numPart), propInfo.currentFontSize()); } else { - prop = FixedLength.getInstance(numPart.doubleValue(), unitPart); + if ("px".equals(unitPart)) { + //pass the ratio between source-resolution and + //the default resolution of 72dpi + prop = FixedLength.getInstance( + numPart, unitPart, + propInfo.getPropertyList().getFObj() + .getUserAgent().getSourceResolution() / 72.0f); + } else { + //use default resolution of 72dpi + prop = FixedLength.getInstance(numPart, unitPart); + } } break; case TOK_COLORSPEC: - FOUserAgent ua = (propInfo == null) - ? null - : (propInfo.getFO() == null ? null : propInfo.getFO().getUserAgent()); - prop = ColorProperty.getInstance(ua, currentTokenValue); + prop = ColorProperty.getInstance( + propInfo.getPropertyList().getFObj().getUserAgent(), + currentTokenValue); break; case TOK_FUNCTION_LPAR: diff --git a/src/java/org/apache/fop/fo/properties/LengthProperty.java b/src/java/org/apache/fop/fo/properties/LengthProperty.java index 7e7b37e06..495e8d8ea 100644 --- a/src/java/org/apache/fop/fo/properties/LengthProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthProperty.java @@ -45,9 +45,7 @@ public abstract class LengthProperty extends Property super(propId); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { @@ -59,7 +57,9 @@ public abstract class LengthProperty extends Property } if (p instanceof NumberProperty) { //Assume pixels (like in HTML) when there's no unit - return FixedLength.getInstance(p.getNumeric().getNumericValue(), "px"); + return FixedLength.getInstance( + p.getNumeric().getNumericValue(), "px", + propertyList.getFObj().getUserAgent().getSourceResolution() / 72.0f); } Length val = p.getLength(); if (val != null) { @@ -87,30 +87,22 @@ public abstract class LengthProperty extends Property return 0.0; } - /** - * @return the numeric dimension. Length always a dimension of 1. - */ + /** @return the numeric dimension. Length always a dimension of 1 */ public int getDimension() { return 1; } - /** - * @return this.length cast as a Numeric - */ + /** @return this.length cast as a Numeric */ public Numeric getNumeric() { return this; } - /** - * @return this.length - */ + /** @return this.length */ public Length getLength() { return this; } - /** - * @return this.length cast as an Object - */ + /** @return this.length cast as an Object */ public Object getObject() { return this; } |