Author: maxberger
Date: Thu Feb 14 03:57:05 2008
New Revision: 627719

URL: http://svn.apache.org/viewvc?rev=627719&view=rev
Log:
Created Constants for unit descriptions

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/NumericProperty.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/RasterFont.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/NumericProperty.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/NumericProperty.java?rev=627719&r1=627718&r2=627719&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/NumericProperty.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/NumericProperty.java 
Thu Feb 14 03:57:05 2008
@@ -25,6 +25,7 @@
 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 @@
     /** [EMAIL PROTECTED] */
     public String toString() {
         if (dim == 1) {
-            return (int) value + "mpt";
+            return (int) value + FixedLength.MPT;
         } else {
             return value + "^" + dim;
         }

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java?rev=627719&r1=627718&r2=627719&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java 
Thu Feb 14 03:57:05 2008
@@ -26,11 +26,29 @@
  */
 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 @@
      *          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 @@
             //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 @@
 
     /** [EMAIL PROTECTED] */
     public String toString() {
-        return millipoints + "mpt";
+        return millipoints + FixedLength.MPT;
     }
 
     /** [EMAIL PROTECTED] */

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/RasterFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/RasterFont.java?rev=627719&r1=627718&r2=627719&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/RasterFont.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/RasterFont.java 
Thu Feb 14 03:57:05 2008
@@ -25,6 +25,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fo.properties.FixedLength;
 import org.apache.fop.render.afp.exceptions.FontRuntimeException;
 
 /**
@@ -75,7 +76,7 @@
         String pointsize = String.valueOf(size / 1000);
         CharacterSet csm = (CharacterSet) charSets.get(pointsize);
         if (csm == null) {
-            csm = (CharacterSet) charSets.get(size + "mpt");
+            csm = (CharacterSet) charSets.get(size + FixedLength.MPT);
         }
         if (csm == null) {
             // Get char set with nearest font size
@@ -83,7 +84,7 @@
             for (Iterator it = charSets.entrySet().iterator(); it.hasNext();) {
                 Map.Entry me = (Map.Entry)it.next();
                 String key = (String)me.getKey();
-                if (!key.endsWith("mpt")) {
+                if (!key.endsWith(FixedLength.MPT)) {
                     int mpt = Integer.parseInt(key) * 1000;
                     if (Math.abs(size - mpt) < distance) {
                         distance = Math.abs(size - mpt);
@@ -93,7 +94,7 @@
                 }
             }
             if (csm != null) {
-                charSets.put(size + "mpt", csm);
+                charSets.put(size + FixedLength.MPT, csm);
                 String msg = "No " + (size / 1000) + "pt font " + getFontName()
                     + " found, substituted with " + pointsize + "pt font";
                 log.warn(msg);

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java?rev=627719&r1=627718&r2=627719&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java 
Thu Feb 14 03:57:05 2008
@@ -24,6 +24,7 @@
 
 //FOP
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.properties.FixedLength;
 
 
 /**  Converts XSL-FO units to RTF units
@@ -51,10 +52,10 @@
     /** conversion factors keyed by xsl:fo units names */
     private static final Map TWIP_FACTORS = new HashMap();
     static {
-        TWIP_FACTORS.put("mm", new Float(MM_TO_TWIPS));
-        TWIP_FACTORS.put("cm", new Float(CM_TO_TWIPS));
-        TWIP_FACTORS.put("pt", new Float(POINT_TO_TWIPS));
-        TWIP_FACTORS.put("in", new Float(IN_TO_TWIPS));
+        TWIP_FACTORS.put(FixedLength.MM, new Float(MM_TO_TWIPS));
+        TWIP_FACTORS.put(FixedLength.CM, new Float(CM_TO_TWIPS));
+        TWIP_FACTORS.put(FixedLength.POINT, new Float(POINT_TO_TWIPS));
+        TWIP_FACTORS.put(FixedLength.INCH, new Float(IN_TO_TWIPS));
     }
 
     /** singleton pattern */
@@ -125,7 +126,7 @@
     /** convert a font size given in points like "12pt" */
     int convertFontSize(String size) throws FOPException {
         size = size.trim();
-        final String sFONTSUFFIX = "pt";
+        final String sFONTSUFFIX = FixedLength.POINT;
         if (!size.endsWith(sFONTSUFFIX)) {
             throw new FOPException("Invalid font size '" + size + "', must end 
with '"
                                    + sFONTSUFFIX + "'");

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=627719&r1=627718&r2=627719&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java 
Thu Feb 14 03:57:05 2008
@@ -85,6 +85,7 @@
 import org.apache.fop.fo.pagination.SimplePageMaster;
 import org.apache.fop.fo.pagination.StaticContent;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.FixedLength;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.render.DefaultFontResolver;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
@@ -578,7 +579,7 @@
             Integer iWidth
                 = new Integer(tc.getColumnWidth().getValue(context) / 1000);
             
-            String strWidth = iWidth.toString() + "pt";
+            String strWidth = iWidth.toString() + FixedLength.POINT;
             Float width = new Float(
                     FoUnitsConverter.getInstance().convertToTwips(strWidth));
             builderContext.getTableContext().setNextColumnWidth(width);
@@ -1277,11 +1278,11 @@
         }
 
         //set width in rtf
-        //newGraphic.setWidth((long) (contentwidth / 1000f) + "pt");
+        //newGraphic.setWidth((long) (contentwidth / 1000f) + 
FixedLength.POINT);
         rtfGraphic.setWidth((long) (contentwidth / 50f) + "twips");
 
         //set height in rtf
-        //newGraphic.setHeight((long) (contentheight / 1000f) + "pt");
+        //newGraphic.setHeight((long) (contentheight / 1000f) + 
FixedLength.POINT);
         rtfGraphic.setHeight((long) (contentheight / 50f) + "twips");
 
         //TODO: make this configurable:

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java?rev=627719&r1=627718&r2=627719&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
 Thu Feb 14 03:57:05 2008
@@ -29,6 +29,7 @@
 import org.apache.fop.fo.flow.table.TableHeader;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.FixedLength;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
 
@@ -343,7 +344,7 @@
             LengthProperty lengthprop = (LengthProperty)p;
 
             Float f = new Float(lengthprop.getLength().getValue() / 1000f);
-            String sValue = f.toString() + "pt";
+            String sValue = f.toString() + FixedLength.POINT;
 
             attrib.set(BorderAttributesConverter.BORDER_WIDTH,
                        
(int)FoUnitsConverter.getInstance().convertToTwips(sValue));



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to