]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Minor cleanup/improvement:
authorAndreas L. Delmelle <adelmelle@apache.org>
Sat, 2 Feb 2008 00:06:29 +0000 (00:06 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sat, 2 Feb 2008 00:06:29 +0000 (00:06 +0000)
- FontSizePropertyMaker: remove redundant casts (FixedLength already casts the doubles internally)
- FixedLength: reduce visibility of 'fishy' convert() method (not used anywhere else)

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@617716 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/properties/FixedLength.java
src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java

index 2c497094f98875226e90f9048cb8c2445a2910ae..28206a12ab46c5eb6270cfaa2a492154d8ebf85a 100644 (file)
@@ -69,7 +69,7 @@ public final class FixedLength extends LengthProperty {
      * @param dvalue quantity of input units
      * @param unit input unit specifier (in, cm, etc.)
      */
-    protected void convert(double dvalue, String unit) {
+    private void convert(double dvalue, String unit) {
         // TODO: the whole routine smells fishy.
 
         int assumedResolution = 1;    // points/pixel = 72dpi
@@ -107,30 +107,22 @@ public final class FixedLength extends LengthProperty {
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int getValue() {
         return millipoints;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int getValue(PercentBaseContext context) {
         return millipoints;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public double getNumericValue() {
         return millipoints;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public double getNumericValue(PercentBaseContext context) {
         return millipoints;
     }
@@ -143,16 +135,12 @@ public final class FixedLength extends LengthProperty {
         return true;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String toString() {
         return millipoints + "mpt";
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean equals(Object obj) {
         if (obj instanceof FixedLength) {
             return (((FixedLength)obj).millipoints == this.millipoints);
@@ -161,9 +149,7 @@ public final class FixedLength extends LengthProperty {
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int hashCode() {
         return millipoints;
     }
index c7124cc5fefadcc39c4c5f4317f31f5c053f4406..acc02dc136951634782ec9651d68e68dcd7d3346 100644 (file)
@@ -44,7 +44,12 @@ public class FontSizePropertyMaker
     }
     
     
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     * Contrary to basic lengths, percentages for font-size can be resolved
+     * here already: if the property evaluates to a {@link PercentLength}, 
+     * it is immediately replaced by the resolved {@link FixedLength}.
+     */
     public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException {
         Property p = super.make(propertyList, value, fo);
         if (p instanceof PercentLength) {
@@ -68,9 +73,11 @@ public class FontSizePropertyMaker
             Property pp = propertyList.getFromParent(this.propId);
             int baseFontSize = computeClosestAbsoluteFontSize(pp.getLength().getValue());
             if (p.getEnum() == EN_LARGER) {
-                return FixedLength.getInstance((int)Math.round((baseFontSize * FONT_SIZE_GROWTH_FACTOR)), "mpt");
+                return FixedLength.getInstance(
+                        Math.round(baseFontSize * FONT_SIZE_GROWTH_FACTOR), "mpt");
             } else {
-                return FixedLength.getInstance((int)Math.round((baseFontSize / FONT_SIZE_GROWTH_FACTOR)), "mpt");
+                return FixedLength.getInstance(
+                        Math.round(baseFontSize / FONT_SIZE_GROWTH_FACTOR), "mpt");
             }
         }
         return super.convertProperty(p, propertyList, fo);