diff options
author | Maximilian Berger <maxberger@apache.org> | 2008-02-14 11:57:05 +0000 |
---|---|---|
committer | Maximilian Berger <maxberger@apache.org> | 2008-02-14 11:57:05 +0000 |
commit | e397444e624314c9b1d4ea3bd9e2a958d129e9f4 (patch) | |
tree | 660a95515aed4b7cf97ed73410d0e80d17534fca /src/java/org/apache/fop/fo | |
parent | 5aab37b2dece063adf9e7809e38fe3100862f8ca (diff) | |
download | xmlgraphics-fop-e397444e624314c9b1d4ea3bd9e2a958d129e9f4.tar.gz xmlgraphics-fop-e397444e624314c9b1d4ea3bd9e2a958d129e9f4.zip |
Created Constants for unit descriptions
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@627719 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo')
-rw-r--r-- | src/java/org/apache/fop/fo/expr/NumericProperty.java | 3 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/properties/FixedLength.java | 36 |
2 files changed, 29 insertions, 10 deletions
diff --git a/src/java/org/apache/fop/fo/expr/NumericProperty.java b/src/java/org/apache/fop/fo/expr/NumericProperty.java index 9c0b9e2ba..54fe1f2f7 100644 --- a/src/java/org/apache/fop/fo/expr/NumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/NumericProperty.java @@ -25,6 +25,7 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; +import org.apache.fop.fo.properties.FixedLength; import org.apache.fop.fo.properties.Property; /** @@ -121,7 +122,7 @@ public class NumericProperty extends Property implements Numeric, Length { /** {@inheritDoc} */ public String toString() { if (dim == 1) { - return (int) value + "mpt"; + return (int) value + FixedLength.MPT; } else { return value + "^" + dim; } diff --git a/src/java/org/apache/fop/fo/properties/FixedLength.java b/src/java/org/apache/fop/fo/properties/FixedLength.java index 7c4344b53..6debdd145 100644 --- a/src/java/org/apache/fop/fo/properties/FixedLength.java +++ b/src/java/org/apache/fop/fo/properties/FixedLength.java @@ -26,11 +26,29 @@ import org.apache.fop.datatypes.PercentBaseContext; */ public final class FixedLength extends LengthProperty { + /** Describes the unit pica. */ + public static final String PICA = "pc"; + + /** Describes the unit point. */ + public static final String POINT = "pt"; + + /** Describes the unit millimeter. */ + public static final String MM = "mm"; + + /** Describes the unit centimeter. */ + public static final String CM = "cm"; + + /** Describes the unit inch. */ + public static final String INCH = "in"; + + /** Describes the unit millipoint. */ + public static final String MPT = "mpt"; + /** cache holding all canonical FixedLength instances */ private static final PropertyCache cache = new PropertyCache(); /** canonical zero-length instance */ - public static final FixedLength ZERO_FIXED_LENGTH = new FixedLength(0, "mpt", 1.0f); + public static final FixedLength ZERO_FIXED_LENGTH = new FixedLength(0, FixedLength.MPT, 1.0f); private int millipoints; @@ -96,7 +114,7 @@ public final class FixedLength extends LengthProperty { * to the given number of units and unit specifier */ public static FixedLength getInstance(double numUnits) { - return getInstance(numUnits, "mpt", 1.0f); + return getInstance(numUnits, FixedLength.MPT, 1.0f); } @@ -115,17 +133,17 @@ public final class FixedLength extends LengthProperty { //device-dependent units, take the resolution into account dvalue *= (res * 1000); } else { - if ("in".equals(unit)) { + if (FixedLength.INCH.equals(unit)) { dvalue *= 72000; - } else if ("cm".equals(unit)) { + } else if (FixedLength.CM.equals(unit)) { dvalue *= 28346.4567; - } else if ("mm".equals(unit)) { + } else if (FixedLength.MM.equals(unit)) { dvalue *= 2834.64567; - } else if ("pt".equals(unit)) { + } else if (FixedLength.POINT.equals(unit)) { dvalue *= 1000; - } else if ("pc".equals(unit)) { + } else if (FixedLength.PICA.equals(unit)) { dvalue *= 12000; - } else if (!"mpt".equals(unit)) { + } else if (!FixedLength.MPT.equals(unit)) { dvalue = 0; log.error("Unknown length unit '" + unit + "'"); } @@ -163,7 +181,7 @@ public final class FixedLength extends LengthProperty { /** {@inheritDoc} */ public String toString() { - return millipoints + "mpt"; + return millipoints + FixedLength.MPT; } /** {@inheritDoc} */ |