You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by dv...@apache.org on 2006/11/29 10:02:21 UTC

svn commit: r480490 - in /xmlgraphics/batik/trunk/sources/org/apache/batik: css/engine/value/LengthManager.java ext/awt/MultipleGradientPaintContext.java parser/UnitProcessor.java

Author: dvholten
Date: Wed Nov 29 01:02:20 2006
New Revision: 480490

URL: http://svn.apache.org/viewvc?view=rev&rev=480490
Log:
1.) few - in fact, very few - numbers are less intesting than a rounded 2.6
2.) the compiler doesnt evaluate expressions like Math.sqrt(2), it delegates this to the runtime. replaced by named constant

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/LengthManager.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/parser/UnitProcessor.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/LengthManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/LengthManager.java?view=diff&rev=480490&r1=480489&r2=480490
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/LengthManager.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/LengthManager.java Wed Nov 29 01:02:20 2006
@@ -37,6 +37,11 @@
 public abstract class LengthManager extends AbstractValueManager {
 
     /**
+     * precomputed square-root of 2.0
+     */
+    static final double SQRT2 = Math.sqrt( 2.0 );
+
+    /**
      * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
      */
     public Value createValue(LexicalUnit lu, CSSEngine engine)
@@ -196,7 +201,7 @@
                 double w = ctx.getBlockWidth(elt);
                 double h = ctx.getBlockHeight(elt);
                 fs = (float)(value.getFloatValue() *
-                        (Math.sqrt(w * w + h * h) / Math.sqrt(2)) / 100.0);
+                        (Math.sqrt(w * w + h * h) / SQRT2 ) / 100.0);
             }
             return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, fs);
         }

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java?view=diff&rev=480490&r1=480489&r2=480490
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java Wed Nov 29 01:02:20 2006
@@ -681,7 +681,7 @@
                 (( g1 + ((((int) ( fI * tempG )) +1) >> 1 ) & 0xff ) <<  8) |
                 (( b1 + ((((int) ( fI * tempB )) +1) >> 1 ) & 0xff )      );
         }
-        Math.round( 2.6 );
+
     }
 
 

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/UnitProcessor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/UnitProcessor.java?view=diff&rev=480490&r1=480489&r2=480490
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/UnitProcessor.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/UnitProcessor.java Wed Nov 29 01:02:20 2006
@@ -47,6 +47,11 @@
     public static final short OTHER_LENGTH = 0;
 
     /**
+     * precomputed square-root of 2.0
+     */
+    static final double SQRT2 = Math.sqrt( 2.0 );
+    
+    /**
      * No instance of this class is required.
      */
     protected UnitProcessor() { }
@@ -232,7 +237,7 @@
         } else {
             double w = ctx.getViewportWidth();
             double h = ctx.getViewportHeight();
-            double vpp = Math.sqrt(w * w + h * h) / Math.sqrt(2);
+            double vpp = Math.sqrt(w * w + h * h) / SQRT2;
             return (float)(vpp * v / 100d);
         }
     }
@@ -254,7 +259,7 @@
         } else {
             double w = ctx.getViewportWidth();
             double h = ctx.getViewportHeight();
-            double vpp = Math.sqrt(w * w + h * h) / Math.sqrt(2);
+            double vpp = Math.sqrt(w * w + h * h) / SQRT2;
             return (float)(v * 100d / vpp);
         }
     }