xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r1352939 [2/3] - in /xmlgraphics/commons/branches/Temp_TrueTypeInPostScript: ./ src/java/org/apache/xmlgraphics/fonts/ src/java/org/apache/xmlgraphics/image/ src/java/org/apache/xmlgraphics/image/codec/png/ src/java/org/apache/xmlgraphics/i...
Date Fri, 22 Jun 2012 15:55:19 GMT
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java Fri Jun 22 15:55:07 2012
@@ -33,13 +33,23 @@ import java.awt.image.WritableRaster;
 
 import org.apache.xmlgraphics.image.GraphicsUtil;
 
+// CSOFF: ConstantName
+// CSOFF: MethodName
+// CSOFF: MultipleVariableDeclarations
+// CSOFF: NeedBraces
+// CSOFF: OperatorWrap
+// CSOFF: WhitespaceAfter
+// CSOFF: WhitespaceAround
+
 /**
  * This function will tranform an image from any colorspace into a
  * luminance image.  The alpha channel if any will be copied to the
  * new image.
  *
- * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id$ */
+ * @version $Id$
+ *
+ * Originally authored by Thomas DeWeese.
+ */
 public class Any2sRGBRed extends AbstractRed {
 
     boolean srcIsLsRGB = false;
@@ -301,8 +311,7 @@ public class Any2sRGBRed extends Abstrac
                 return GraphicsUtil.sRGB_Unpre;
 
             return GraphicsUtil.sRGB;
-        }
-        else {
+        } else {
             // No ColorModel so try to make some intelligent
             // decisions based just on the number of bands...
             // 1 bands -> replicated into RGB
@@ -318,8 +327,9 @@ public class Any2sRGBRed extends Abstrac
                 return GraphicsUtil.sRGB_Unpre;
             case 3:
                 return GraphicsUtil.sRGB;
+            default:
+                return GraphicsUtil.sRGB_Unpre;
             }
-            return GraphicsUtil.sRGB_Unpre;
         }
     }
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java Fri Jun 22 15:55:07 2012
@@ -26,14 +26,19 @@ import java.awt.image.WritableRaster;
 
 import org.apache.xmlgraphics.image.GraphicsUtil;
 
+// CSOFF: NeedBraces
+// CSOFF: WhitespaceAfter
+// CSOFF: WhitespaceAround
+
 /**
  * This implements CachableRed based on a BufferedImage.
  * You can use this to wrap a BufferedImage that you want to
  * appear as a CachableRed.
  * It essentially ignores the dependency and dirty region methods.
  *
- * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id$ */
+ * Originally authored by Thomas DeWeese.
+ * @version $Id$
+ */
 public class BufferedImageCachableRed extends AbstractRed {
     // The bufferedImage that we wrap...
     BufferedImage bi;

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java Fri Jun 22 15:55:07 2012
@@ -27,8 +27,9 @@ import java.awt.image.RenderedImage;
  * This provides a number of extra methods that enable a system to
  * better analyse the dependencies between nodes in a render graph.
  *
- * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  * @version $Id$
+ *
+ * Originally authored by Thomas DeWeese.
 */
 public interface CachableRed extends RenderedImage {
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java Fri Jun 22 15:55:07 2012
@@ -35,21 +35,26 @@ import java.awt.image.WritableRaster;
 
 import org.apache.xmlgraphics.image.GraphicsUtil;
 
+// CSOFF: NeedBraces
+// CSOFF: WhitespaceAfter
+// CSOFF: WhitespaceAround
+
 /**
  * This allows you to specify the ColorModel, Alpha premult and/or
  * SampleModel to be used for output.  If the input image lacks
  * Alpha and alpha is included in output then it is filled with
  * alpha=1.  In all other cases bands are simply copied.
  *
- * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  * @version $Id$
+ *
+ * Originally authored by Thomas DeWeese.
  */
 public class FormatRed extends AbstractRed {
 
     public static CachableRed construct(CachableRed src, ColorModel cm) {
         ColorModel srcCM = src.getColorModel();
-        if ((cm.hasAlpha() != srcCM.hasAlpha()) ||
-            (cm.isAlphaPremultiplied() != srcCM.isAlphaPremultiplied()))
+        if ((cm.hasAlpha() != srcCM.hasAlpha())
+            || (cm.isAlphaPremultiplied() != srcCM.isAlphaPremultiplied()))
             return new FormatRed(src, cm);
 
         if (cm.getNumComponents() != srcCM.getNumComponents())
@@ -57,12 +62,12 @@ public class FormatRed extends AbstractR
                 ("Incompatible ColorModel given");
 
 
-        if ((srcCM instanceof ComponentColorModel) &&
-            (cm    instanceof ComponentColorModel))
+        if ((srcCM instanceof ComponentColorModel)
+            && (cm    instanceof ComponentColorModel))
             return src;
 
-        if ((srcCM instanceof DirectColorModel) &&
-            (cm    instanceof DirectColorModel))
+        if ((srcCM instanceof DirectColorModel)
+            && (cm    instanceof DirectColorModel))
             return src;
 
         return new FormatRed(src, cm);

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java Fri Jun 22 15:55:07 2012
@@ -29,14 +29,18 @@ import java.awt.image.SampleModel;
 import java.awt.image.WritableRaster;
 import java.util.Vector;
 
+// CSOFF: NeedBraces
+// CSOFF: WhitespaceAround
+
 /**
  * This implements CachableRed around a RenderedImage.
  * You can use this to wrap a RenderedImage that you want to
  * appear as a CachableRed.
  * It essentially ignores the dependency and dirty region methods.
  *
- * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  * @version $Id$
+ *
+ * Originally authored by Thomas DeWeese.
  */
 public class RenderedImageCachableRed implements CachableRed {
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java Fri Jun 22 15:55:07 2012
@@ -36,7 +36,7 @@ public interface ImageWriter {
      * @param out the OutputStream to write to
      * @throws IOException In case of an /IO problem
      */
-    public void writeImage(RenderedImage image, OutputStream out)
+    void writeImage(RenderedImage image, OutputStream out)
             throws IOException;
 
     /**
@@ -46,18 +46,18 @@ public interface ImageWriter {
      * @param params a parameters object to customize the encoding.
      * @throws IOException In case of an /IO problem
      */
-    public void writeImage(RenderedImage image, OutputStream out,
+    void writeImage(RenderedImage image, OutputStream out,
             ImageWriterParams params)
             throws IOException;
 
     /** @return the target MIME type supported by this ImageWriter */
-    public String getMIMEType();
+    String getMIMEType();
 
     /** @return true if the ImageWriter is expected to work properly in the current environment */
-    public boolean isFunctional();
+    boolean isFunctional();
 
     /** @return true if the implemented format supports multiple pages in a single file */
-    public boolean supportsMultiImageWriter();
+    boolean supportsMultiImageWriter();
 
     /**
      * Creates a MultiImageWriter instance that lets you put multiple pages into a single file
@@ -66,6 +66,6 @@ public interface ImageWriter {
      * @return the requested MultiImageWriter instance
      * @throws IOException In case of an /IO problem
      */
-    public MultiImageWriter createMultiImageWriter(OutputStream out) throws IOException;
+    MultiImageWriter createMultiImageWriter(OutputStream out) throws IOException;
 
 }

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriterUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriterUtil.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriterUtil.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/ImageWriterUtil.java Fri Jun 22 15:55:07 2012
@@ -29,7 +29,10 @@ import org.apache.commons.io.IOUtils;
 /**
  * Convenience methods around ImageWriter for the most important tasks.
  */
-public class ImageWriterUtil {
+public final class ImageWriterUtil {
+
+    private ImageWriterUtil() {
+    }
 
     /**
      * Saves a RenderedImage as a PNG file with 96 dpi.

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/MultiImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/MultiImageWriter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/MultiImageWriter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/MultiImageWriter.java Fri Jun 22 15:55:07 2012
@@ -36,9 +36,9 @@ public interface MultiImageWriter {
      * @param params a parameters object to customize the encoding.
      * @throws IOException In case of an /IO problem
      */
-    public void writeImage(RenderedImage image, ImageWriterParams params)
+    void writeImage(RenderedImage image, ImageWriterParams params)
             throws IOException;
 
-    public void close() throws IOException;
+    void close() throws IOException;
 
 }

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java Fri Jun 22 15:55:07 2012
@@ -25,6 +25,8 @@ import javax.imageio.metadata.IIOMetadat
 
 import org.apache.xmlgraphics.image.writer.ImageWriterParams;
 
+// CSOFF: MultipleVariableDeclarations
+
 /**
  * ImageWriter that encodes TIFF images using Image I/O.
  *

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/internal/PNGImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/internal/PNGImageWriter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/internal/PNGImageWriter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/image/writer/internal/PNGImageWriter.java Fri Jun 22 15:55:07 2012
@@ -25,7 +25,6 @@ import java.io.OutputStream;
 
 import org.apache.xmlgraphics.image.codec.png.PNGImageEncoder;
 import org.apache.xmlgraphics.image.writer.AbstractImageWriter;
-import org.apache.xmlgraphics.image.writer.ImageWriter;
 import org.apache.xmlgraphics.image.writer.ImageWriterParams;
 
 /**

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java Fri Jun 22 15:55:07 2012
@@ -47,6 +47,10 @@ import java.awt.image.ImageObserver;
 import java.text.AttributedCharacterIterator;
 import java.util.Map;
 
+// CSOFF: NeedBraces
+// CSOFF: ParameterName
+// CSOFF: WhitespaceAround
+
 /**
  * This extension of the <tt>java.awt.Graphics2D</tt> abstract class
  * is still abstract, but it implements a lot of the <tt>Graphics2D</tt>
@@ -62,9 +66,10 @@ import java.util.Map;
  * <tt>drawRect</tt> can be expressed as <tt>draw(new Rectangle(..))</tt>),
  * are implemented by <tt>AbstractGraphics2D</tt>
  *
- * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  * @version $Id$
  * @see org.apache.xmlgraphics.java2d.GraphicContext
+ *
+ * Originally authored by Vincent Hardy.
  */
 public abstract class AbstractGraphics2D extends Graphics2D implements Cloneable {
     /**
@@ -912,8 +917,7 @@ public abstract class AbstractGraphics2D
             gc.transform(xform);
             retVal = drawImage(img, 0, 0, null);
             gc.transform(inverseTransform);
-        }
-        else{
+        } else {
             AffineTransform savTransform = new AffineTransform(gc.getTransform());
             gc.transform(xform);
             retVal = drawImage(img, 0, 0, null);

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/DefaultGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/DefaultGraphics2D.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/DefaultGraphics2D.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/DefaultGraphics2D.java Fri Jun 22 15:55:07 2012
@@ -34,6 +34,8 @@ import java.awt.image.RenderedImage;
 import java.awt.image.renderable.RenderableImage;
 import java.text.AttributedCharacterIterator;
 
+// CSOFF: WhitespaceAround
+
 /**
  * This concrete implementation of <tt>AbstractGraphics2D</tt> is a
  * simple help to programmers to get started with their own
@@ -42,9 +44,10 @@ import java.text.AttributedCharacterIter
  * is <tt>AbstractGraphics2D</tt> and makes it easy to start
  * implementing a <tt>Graphic2D</tt> piece-meal.
  *
- * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  * @version $Id$
  * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D
+ *
+ * Originally authored by Vincent Hardy.
  */
 public class DefaultGraphics2D extends AbstractGraphics2D {
     /**

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Dimension2DDouble.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Dimension2DDouble.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Dimension2DDouble.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Dimension2DDouble.java Fri Jun 22 15:55:07 2012
@@ -95,4 +95,4 @@ public class Dimension2DDouble extends D
     public String toString() {
         return getClass().getName() + "[width=" + width + ",height=" + height + "]";
     }
-}
\ No newline at end of file
+}

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/GraphicContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/GraphicContext.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/GraphicContext.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/GraphicContext.java Fri Jun 22 15:55:07 2012
@@ -38,6 +38,10 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+// CSOFF: OperatorWrap
+// CSOFF: ParameterName
+// CSOFF: WhitespaceAround
+
 /**
  * Handles the attributes in a graphic context:<br>
  * + Composite <br>
@@ -48,9 +52,9 @@ import java.util.Map;
  * + RenderingHints <br>
  * + AffineTransform <br>
  *
- * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
- * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  * @version $Id$
+ *
+ * Originally authored by Vincent Hardy and Christophe Jolif.
  */
 public class GraphicContext implements Cloneable{
     /**

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Graphics2DImagePainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Graphics2DImagePainter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Graphics2DImagePainter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/Graphics2DImagePainter.java Fri Jun 22 15:55:07 2012
@@ -42,4 +42,4 @@ public interface Graphics2DImagePainter 
      */
     Dimension getImageSize();
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java Fri Jun 22 15:55:07 2012
@@ -21,14 +21,19 @@ package org.apache.xmlgraphics.java2d;
 
 import java.awt.geom.AffineTransform;
 
+// CSOFF: EmptyBlock
+// CSOFF: NoWhitespaceAfter
+// CSOFF: OperatorWrap
+// CSOFF: WhitespaceAround
+
 /**
  * Contains a description of an elementary transform stack element,
  * such as a rotate or translate. A transform stack element has a
  * type and a value, which is an array of double values.<br>
  *
- * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @author <a href="mailto:paul_evenblij@compuware.com">Paul Evenblij</a>
  * @version $Id$
+ *
+ * Originally authored by Vincent Hardy and Paul Evenblij.
  */
 public abstract class TransformStackElement implements Cloneable{
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformType.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformType.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TransformType.java Fri Jun 22 15:55:07 2012
@@ -19,13 +19,15 @@
 
 package org.apache.xmlgraphics.java2d;
 
+// CSOFF: WhitespaceAround
+
 /**
  * Enumeration for transformation types.
  *
- * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  * @version $Id$
+ * Originally authored by Vincent Hardy.
  */
-public class TransformType{
+public final class TransformType{
     /*
      * Transform type constants
      */

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorSpaceOrigin.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorSpaceOrigin.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorSpaceOrigin.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorSpaceOrigin.java Fri Jun 22 15:55:07 2012
@@ -19,8 +19,6 @@
 
 package org.apache.xmlgraphics.java2d.color;
 
-import java.awt.color.ColorSpace;
-
 /**
  * Interface used to decorate {@link ColorSpace} subclasses to report the origin of the
  * associated color profile.

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java Fri Jun 22 15:55:07 2012
@@ -21,8 +21,6 @@ package org.apache.xmlgraphics.java2d.co
 
 import java.awt.Color;
 
-import org.apache.xmlgraphics.java2d.color.ColorConverter;
-
 /**
  * A default implementation that does not apply any conversion
  */

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java Fri Jun 22 15:55:07 2012
@@ -20,7 +20,6 @@
 package org.apache.xmlgraphics.java2d.color;
 
 import java.awt.Color;
-import java.awt.color.ColorSpace;
 
 /**
  * This class represents an uncalibrated CMYK color space.

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/GrayScaleColorConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/GrayScaleColorConverter.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/GrayScaleColorConverter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/GrayScaleColorConverter.java Fri Jun 22 15:55:07 2012
@@ -33,7 +33,8 @@ public final class GrayScaleColorConvert
 
     private static final GrayScaleColorConverter SINGLETON = new GrayScaleColorConverter();
 
-    private GrayScaleColorConverter() { }
+    private GrayScaleColorConverter() {
+    }
 
     /**
      * Returns a singleton instance.

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/ColorProfileUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/ColorProfileUtil.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/ColorProfileUtil.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/ColorProfileUtil.java Fri Jun 22 15:55:07 2012
@@ -26,6 +26,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 
+// CSOFF: MethodName
+
 /**
  * Helper methods for handling color profiles.
  */

Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/ColorProfileUtil.java
------------------------------------------------------------------------------
  Merged /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/ColorProfileUtil.java:r1343306-1352933

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java Fri Jun 22 15:55:07 2012
@@ -19,8 +19,6 @@
 
 package org.apache.xmlgraphics.java2d.color.profile;
 
-import java.awt.color.ICC_Profile;
-
 import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
 import org.apache.xmlgraphics.java2d.color.RenderingIntent;
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java Fri Jun 22 15:55:07 2012
@@ -34,9 +34,10 @@ import org.apache.xmlgraphics.ps.PSProcS
  * is used to create a full document around the PostScript rendering from
  * <tt>PSGraphics2D</tt>.
  *
- * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
  * @version $Id$
  * @see org.apache.xmlgraphics.java2d.ps.PSGraphics2D
+ *
+ * Originally authored by Keiron Liddle.
  */
 public abstract class AbstractPSDocumentGraphics2D extends PSGraphics2D {
 
@@ -244,7 +245,7 @@ public abstract class AbstractPSDocument
         AffineTransform at;
         if ((this.viewportWidth != this.width
                 || this.viewportHeight != this.height)
-                && (this.viewportWidth > 0) && (this.viewportHeight > 0)){
+                && (this.viewportWidth > 0) && (this.viewportHeight > 0)) {
             at = new AffineTransform(this.width / this.viewportWidth, 0,
                        0, -1 * (this.height / this.viewportHeight),
                        0, this.height);

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java Fri Jun 22 15:55:07 2012
@@ -29,9 +29,10 @@ import org.apache.xmlgraphics.ps.DSCCons
  * is used to create a full document around the PostScript rendering from
  * <tt>PSGraphics2D</tt>.
  *
- * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
  * @version $Id$
  * @see org.apache.xmlgraphics.java2d.ps.PSGraphics2D
+ *
+ * Originally authored by Keiron Liddle.
  */
 public class PSDocumentGraphics2D extends AbstractPSDocumentGraphics2D {
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java Fri Jun 22 15:55:07 2012
@@ -56,9 +56,10 @@ import org.apache.xmlgraphics.ps.PSImage
  * therefore of <tt>Graphics2D</tt>) which is able to generate PostScript
  * code.
  *
- * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
  * @version $Id$
  * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D
+ *
+ * Originally authored by Keiron Liddle.
  */
 public class PSGraphics2D extends AbstractGraphics2D {
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java Fri Jun 22 15:55:07 2012
@@ -116,4 +116,4 @@ class PSGraphicsConfiguration extends Gr
         return new PSGraphicsDevice(this);
     }
 
-}
\ No newline at end of file
+}

Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java
------------------------------------------------------------------------------
  Merged /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsConfiguration.java:r1343306-1352933

Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java
------------------------------------------------------------------------------
  Merged /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphicsDevice.java:r1343306-1352933

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java Fri Jun 22 15:55:07 2012
@@ -28,7 +28,7 @@ import java.util.List;
  * This class is implementation of PostScript tiling pattern. It allows to make a pattern
  * with defined PaintProc or texture.
  *
- * @author Jiri Kunhart
+ * Originally authored by Jiri Kunhart.
  */
 public class PSTilingPattern {
 
@@ -313,7 +313,7 @@ public class PSTilingPattern {
      * @param tilingType the tiling type
      */
     public void setTilingType(int tilingType) {
-        if (! ((tilingType <= 3) && (tilingType >= 1))) {
+        if (!((tilingType <= 3) && (tilingType >= 1))) {
             throw new IllegalArgumentException("Parameter tilingType must not be "
                     + tilingType + " (only 1, 2 or 3)");
         }
@@ -429,6 +429,21 @@ public class PSTilingPattern {
         return sb.toString();
     }
 
+    /** {@inheritDoc} */
+    public int hashCode() {
+        return
+            0
+            ^ patternType
+            ^ ( ( xUID != null ) ? xUID.hashCode() : 0 )
+            ^ ( ( paintProc != null ) ? paintProc.hashCode() : 0 )
+            ^ ( ( bBox != null ) ? bBox.hashCode() : 0 )
+            ^ new Double(xStep).hashCode()
+            ^ new Double(yStep).hashCode()
+            ^ paintType
+            ^ tilingType
+            ^ ( ( texture != null ) ? texture.hashCode() : 0 );
+    }
+
     /**
      * Compares two patterns data (except their names).
      * {@inheritDoc}
@@ -451,8 +466,8 @@ public class PSTilingPattern {
 
         TexturePaint patternTexture = patternObj.getTexturePaint();
 
-        if ( ((patternTexture == null) && (texture != null)) ||
-             ((patternTexture != null) && (texture == null))) {
+        if ( ((patternTexture == null) && (texture != null))
+             || ((patternTexture != null) && (texture == null))) {
             return false;
         }
 
@@ -482,10 +497,9 @@ public class PSTilingPattern {
                     return false;
                 }
             }
-        }
-        else {
+        } else {
             // compare PaintProc
-            if (! paintProc.toString().equals(patternObj.getPaintProc().toString())) {
+            if (!paintProc.toString().equals(patternObj.getPaintProc().toString())) {
                 return false;
             }
         }
@@ -503,11 +517,11 @@ public class PSTilingPattern {
         if (tilingType != patternObj.getTilingType()) {
             return false;
         }
-        if (! bBox.equals(patternObj.getBoundingBox())) {
+        if (!bBox.equals(patternObj.getBoundingBox())) {
             return false;
         }
         if ((xUID != null) && (patternObj.getXUID() != null)) {
-            if (! xUID.equals(patternObj.getXUID())) {
+            if (!xUID.equals(patternObj.getXUID())) {
                 return false;
             }
         }

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java Fri Jun 22 15:55:07 2012
@@ -24,7 +24,10 @@ package org.apache.xmlgraphics.ps;
  *
  * @version $Id$
  */
-public class DSCConstants {
+public final class DSCConstants {
+
+    private DSCConstants() {
+    }
 
     // ----==== General Header Comments ====----
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java Fri Jun 22 15:55:07 2012
@@ -47,6 +47,7 @@ public class ImageEncodingHelper {
     private ColorModel encodedColorModel;
     private boolean firstTileDump;
     private boolean enableCMYK;
+    private boolean isBGR;
 
     /**
      * Main constructor
@@ -142,8 +143,8 @@ public class ImageEncodingHelper {
             data = new double[nbands];
             break;
         default:
-            throw new IllegalArgumentException("Unknown data buffer type: "+
-                                               dataType);
+            throw new IllegalArgumentException("Unknown data buffer type: "
+                                               + dataType);
         }
 
         ColorModel colorModel = image.getColorModel();
@@ -234,7 +235,17 @@ public class ImageEncodingHelper {
             Raster raster = image.getTile(0, 0);
             DataBuffer buffer = raster.getDataBuffer();
             if (buffer instanceof DataBufferByte) {
-                out.write(((DataBufferByte)buffer).getData());
+                byte[] bytes = ((DataBufferByte) buffer).getData();
+                // see determineEncodingColorModel() to see why we permute B and R here
+                if (isBGR) {
+                    for (int i = 0; i < bytes.length; i += 3) {
+                        out.write(bytes[i + 2]);
+                        out.write(bytes[i + 1]);
+                        out.write(bytes[i]);
+                    }
+                } else {
+                    out.write(bytes);
+                }
                 return true;
             }
         }
@@ -285,12 +296,26 @@ public class ImageEncodingHelper {
                     piSampleModel = (PixelInterleavedSampleModel)sampleModel;
                     int[] offsets = piSampleModel.getBandOffsets();
                     for (int i = 0; i < offsets.length; i++) {
-                        if (offsets[i] != i) {
+                        if (offsets[i] != i && offsets[i] != offsets.length - 1 - i) {
                             //Don't encode directly as samples are not next to each other
                             //i.e. offsets are not 012 (RGB) or 0123 (CMYK)
+                            // let also pass 210 BGR and 3210 (KYMC); 3210 will be skipped below
+                            // if 210 (BGR) the B and R bytes will be permuted later in optimizeWriteTo()
                             return;
                         }
                     }
+                    // check if we are in a BGR case; this is added here as a workaround for bug fix
+                    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6549882 that causes some PNG
+                    // images to be loaded as BGR with the consequence that performance was being impacted
+                    this.isBGR = false;
+                    if (offsets.length == 3 && offsets[0] == 2 && offsets[1] == 1 && offsets[2] == 0) {
+                        this.isBGR = true;
+                    }
+                    // make sure we did not get here due to a KMYC image
+                    if (offsets.length == 4 && offsets[0] == 3 && offsets[1] == 2 && offsets[2] == 1
+                            && offsets[3] == 0) {
+                        return;
+                    }
                 }
                 if (cm.getTransferType() == DataBuffer.TYPE_BYTE
                         && buffer.getOffset() == 0

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSDictionary.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSDictionary.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSDictionary.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSDictionary.java Fri Jun 22 15:55:07 2012
@@ -23,6 +23,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
+// CSOFF: InnerAssignment
+
 /**
  * This class is used to encapsulate postscript dictionary objects.
  */

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSFontUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSFontUtils.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSFontUtils.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSFontUtils.java Fri Jun 22 15:55:07 2012
@@ -30,11 +30,16 @@ import org.apache.xmlgraphics.fonts.Glyp
 import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream;
 import org.apache.xmlgraphics.util.io.SubInputStream;
 
+// CSOFF: HideUtilityClassConstructor
+
 /**
  * Utility code for font handling in PostScript.
  */
 public class PSFontUtils {
 
+    public PSFontUtils() {
+    }
+
     /**
      * This method reads a Type 1 font from a stream and embeds it into a PostScript stream.
      * Note: Only the IBM PC Format as described in section 3.3 of the Adobe Technical Note #5040

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java Fri Jun 22 15:55:07 2012
@@ -881,4 +881,5 @@ public class PSGenerator implements PSCo
     public void includeProcsetCIDInitResource() throws IOException {
         writeDSCComment(DSCConstants.INCLUDE_RESOURCE, getProcsetCIDInitResource());
     }
- }
+
+}

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java Fri Jun 22 15:55:07 2012
@@ -39,11 +39,16 @@ import org.apache.xmlgraphics.util.io.Fi
 import org.apache.xmlgraphics.util.io.FlateEncodeOutputStream;
 import org.apache.xmlgraphics.util.io.RunLengthEncodeOutputStream;
 
+// CSOFF: HideUtilityClassConstructor
+
 /**
  * Utility code for rendering images in PostScript.
  */
 public class PSImageUtils {
 
+    public PSImageUtils() {
+    }
+
     /**
      * Writes a bitmap image to the PostScript stream.
      * @param img the bitmap image as a byte array
@@ -138,25 +143,23 @@ public class PSImageUtils {
 
     /**
      * Writes a bitmap image to the PostScript stream.
-     * @param img the bitmap image as a byte array
+     * @param encoder the image encoder
+     * @param imgDim the dimensions of the image
+     * @param imgDescription the name of the image
      * @param targetRect the target rectangle to place the image in
+     * @param colorModel the color model of the image
      * @param gen the PostScript generator
      * @throws IOException In case of an I/O exception
      */
-    private static void writeImage(RenderedImage img,
-            Rectangle2D targetRect, PSGenerator gen) throws IOException {
-        ImageEncoder encoder = ImageEncodingHelper.createRenderedImageEncoder(img);
-        String imgDescription = img.getClass().getName();
+    public static void writeImage(ImageEncoder encoder, Dimension imgDim, String imgDescription,
+            Rectangle2D targetRect, ColorModel colorModel, PSGenerator gen)
+            throws IOException {
 
         gen.saveGraphicsState();
         translateAndScale(gen, null, targetRect);
-
         gen.commentln("%AXGBeginBitmap: " + imgDescription);
-
         gen.writeln("{{");
-        // Template: (RawData is used for the EOF signal only)
-        // gen.write("/RawData currentfile <first filter> filter def");
-        // gen.write("/Data RawData <second filter> <third filter> [...] def");
+
         String implicitFilter = encoder.getImplicitFilter();
         if (implicitFilter != null) {
             gen.writeln("/RawData currentfile /ASCII85Decode filter def");
@@ -170,11 +173,15 @@ public class PSImageUtils {
                 gen.writeln("/Data RawData /RunLengthDecode filter def");
             }
         }
+
         PSDictionary imageDict = new PSDictionary();
         imageDict.put("/DataSource", "Data");
-        writeImageCommand(img, imageDict, gen);
 
-        /* the following two lines could be enabled if something still goes wrong
+        populateImageDictionary(imgDim, colorModel, imageDict);
+        writeImageCommand(imageDict, colorModel, gen);
+
+        /*
+         * the following two lines could be enabled if something still goes wrong
          * gen.write("Data closefile");
          * gen.write("RawData flushfile");
          */
@@ -184,43 +191,40 @@ public class PSImageUtils {
 
         compressAndWriteBitmap(encoder, gen);
 
-        gen.writeln("");
+        gen.newLine();
         gen.commentln("%AXGEndBitmap");
         gen.restoreGraphicsState();
     }
 
-    private static ColorModel populateImageDictionary(
-                ImageEncodingHelper helper, PSDictionary imageDict) {
-        RenderedImage img = helper.getImage();
-        String w = Integer.toString(img.getWidth());
-        String h = Integer.toString(img.getHeight());
+    private static ColorModel populateImageDictionary(Dimension imgDim, ColorModel colorModel,
+            PSDictionary imageDict) {
+        String w = Integer.toString(imgDim.width);
+        String h = Integer.toString(imgDim.height);
         imageDict.put("/ImageType", "1");
         imageDict.put("/Width", w);
         imageDict.put("/Height", h);
 
-        ColorModel cm = helper.getEncodedColorModel();
-
         boolean invertColors = false;
-        String decodeArray = getDecodeArray(cm.getNumComponents(), invertColors);
-        int bitsPerComp = cm.getComponentSize(0);
+        String decodeArray = getDecodeArray(colorModel.getNumColorComponents(), invertColors);
+        int bitsPerComp = colorModel.getComponentSize(0);
 
         // Setup scanning for left-to-right and top-to-bottom
         imageDict.put("/ImageMatrix", "[" + w + " 0 0 " + h + " 0 0]");
 
-        if ((cm instanceof IndexColorModel)) {
-            IndexColorModel im = (IndexColorModel)cm;
-            int c = im.getMapSize();
+        if ((colorModel instanceof IndexColorModel)) {
+            IndexColorModel indexColorModel = (IndexColorModel) colorModel;
+            int c = indexColorModel.getMapSize();
             int hival = c - 1;
             if (hival > 4095) {
                 throw new UnsupportedOperationException("hival must not go beyond 4095");
             }
-            bitsPerComp = im.getPixelSize();
-            int ceiling = ((int)Math.pow(2, bitsPerComp)) - 1;
+            bitsPerComp = indexColorModel.getPixelSize();
+            int ceiling = ((int) Math.pow(2, bitsPerComp)) - 1;
             decodeArray = "[0 " + ceiling + "]";
         }
         imageDict.put("/BitsPerComponent", Integer.toString(bitsPerComp));
         imageDict.put("/Decode", decodeArray);
-        return cm;
+        return colorModel;
     }
 
     private static String getDecodeArray(int numComponents, boolean invertColors) {
@@ -283,8 +287,9 @@ public class PSImageUtils {
             PSDictionary imageDict, PSGenerator gen) throws IOException {
         ImageEncodingHelper helper = new ImageEncodingHelper(img, true);
         ColorModel cm = helper.getEncodedColorModel();
-        populateImageDictionary(helper, imageDict);
+        Dimension imgDim = new Dimension(img.getWidth(), img.getHeight());
 
+        populateImageDictionary(imgDim, cm, imageDict);
         writeImageCommand(imageDict, cm, gen);
     }
 
@@ -340,7 +345,13 @@ public class PSImageUtils {
                 float x, float y, float w, float h, PSGenerator gen)
                     throws IOException {
         Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
-        writeImage(img, targetRect, gen);
+        ImageEncoder encoder = ImageEncodingHelper.createRenderedImageEncoder(img);
+        Dimension imgDim = new Dimension(img.getWidth(), img.getHeight());
+        String imgDescription = img.getClass().getName();
+        ImageEncodingHelper helper = new ImageEncodingHelper(img);
+        ColorModel cm = helper.getEncodedColorModel();
+
+        writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen);
     }
 
     /**
@@ -517,11 +528,11 @@ public class PSImageUtils {
 
     private static String getColorSpaceName(ColorSpace colorSpace) {
         if (colorSpace.getType() == ColorSpace.TYPE_CMYK) {
-            return("/DeviceCMYK");
+            return "/DeviceCMYK";
         } else if (colorSpace.getType() == ColorSpace.TYPE_GRAY) {
-            return("/DeviceGray");
+            return "/DeviceGray";
         } else {
-            return("/DeviceRGB");
+            return "/DeviceRGB";
         }
     }
 
@@ -611,8 +622,8 @@ public class PSImageUtils {
             data = new double[nbands];
             break;
         default:
-            throw new IllegalArgumentException("Unknown data buffer type: "+
-                                               dataType);
+            throw new IllegalArgumentException("Unknown data buffer type: "
+                                               + dataType);
         }
 
         if (rgbArray == null) {

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSProcSets.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSProcSets.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSProcSets.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSProcSets.java Fri Jun 22 15:55:07 2012
@@ -31,6 +31,9 @@ import java.util.Map;
  */
 public final class PSProcSets {
 
+    private PSProcSets() {
+    }
+
     /** the standard procset for the XML Graphics project */
     public static final PSResource STD_PROCSET;
     /** the EPS procset for the XML Graphics project */
@@ -99,7 +102,7 @@ public final class PSProcSets {
             Iterator iter = STANDARD_MACROS.entrySet().iterator();
             while (iter.hasNext()) {
                 Map.Entry entry = (Map.Entry)iter.next();
-                gen.writeln("/" + entry.getValue() + "/" + entry.getKey()+" ld");
+                gen.writeln("/" + entry.getValue() + "/" + entry.getKey() + " ld");
             }
 
             gen.writeln("/re {4 2 roll M"); //define rectangle

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCCommentFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCCommentFactory.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCCommentFactory.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCCommentFactory.java Fri Jun 22 15:55:07 2012
@@ -43,7 +43,10 @@ import org.apache.xmlgraphics.ps.dsc.eve
 /**
  * Factory for DSCComment subclasses.
  */
-public class DSCCommentFactory {
+public final class DSCCommentFactory {
+
+    private DSCCommentFactory() {
+    }
 
     private static final Map DSC_FACTORIES = new java.util.HashMap();
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCHandler.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCHandler.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCHandler.java Fri Jun 22 15:55:07 2012
@@ -34,13 +34,13 @@ public interface DSCHandler {
      * @param header the first line of the DSC-compliant file
      * @throws IOException In case of an I/O error
      */
-    public void startDocument(String header) throws IOException;
+    void startDocument(String header) throws IOException;
 
     /**
      * Called when the PostScript file is fully processed, i.e. after the %%EOF comment.
      * @throws IOException In case of an I/O error
      */
-    public void endDocument() throws IOException;
+    void endDocument() throws IOException;
 
     /**
      * Called for each standard DSC comment. The classes passed to this method may be simple
@@ -48,14 +48,14 @@ public interface DSCHandler {
      * @param comment the DSC comment
      * @throws IOException In case of an I/O error
      */
-    public void handleDSCComment(DSCComment comment) throws IOException;
+    void handleDSCComment(DSCComment comment) throws IOException;
 
     /**
      * Called for a normal line of PostScript code.
      * @param line the line of code
      * @throws IOException In case of an I/O error
      */
-    public void line(String line) throws IOException;
+    void line(String line) throws IOException;
 
     /**
      * Called for any line containing a full-line PostScript comment. This is also called for
@@ -63,6 +63,6 @@ public interface DSCHandler {
      * @param comment the comment line
      * @throws IOException In case of an I/O error
      */
-    public void comment(String comment) throws IOException;
+    void comment(String comment) throws IOException;
 
 }

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java Fri Jun 22 15:55:07 2012
@@ -125,7 +125,7 @@ public class DSCParser implements DSCPar
         }
     }
 
-    private final boolean isWhitespace(char c) {
+    private boolean isWhitespace(char c) {
         return c == ' ' || c == '\t';
     }
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/NestedDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/NestedDocumentHandler.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/NestedDocumentHandler.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/NestedDocumentHandler.java Fri Jun 22 15:55:07 2012
@@ -45,4 +45,4 @@ public interface NestedDocumentHandler {
      */
     void handle(DSCEvent event, DSCParser parser) throws IOException, DSCException;
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/events/AbstractDSCComment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/events/AbstractDSCComment.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/events/AbstractDSCComment.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/events/AbstractDSCComment.java Fri Jun 22 15:55:07 2012
@@ -26,7 +26,7 @@ import java.util.List;
  */
 public abstract class AbstractDSCComment extends AbstractEvent implements DSCComment {
 
-    private final boolean isWhitespace(char c) {
+    private boolean isWhitespace(char c) {
         return c == ' ' || c == '\t';
     }
 

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/DSCTools.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/DSCTools.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/DSCTools.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/DSCTools.java Fri Jun 22 15:55:07 2012
@@ -34,7 +34,10 @@ import org.apache.xmlgraphics.ps.dsc.eve
 /**
  * Helper methods commonly used when dealing with DSC-compliant PostScript files.
  */
-public class DSCTools implements DSCParserConstants {
+public final class DSCTools implements DSCParserConstants {
+
+    private DSCTools() {
+    }
 
     /**
      * Indicates whether the given event ends a header comment section according to the rules in

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/PageExtractor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/PageExtractor.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/PageExtractor.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/dsc/tools/PageExtractor.java Fri Jun 22 15:55:07 2012
@@ -39,7 +39,10 @@ import org.apache.xmlgraphics.ps.dsc.eve
 /**
  * This class can extract a certain range of pages from a DSC-compliant PostScript file.
  */
-public class PageExtractor implements DSCParserConstants {
+public final class PageExtractor implements DSCParserConstants {
+
+    private PageExtractor() {
+    }
 
     /**
      * Parses a DSC-compliant file and pipes the content through to the OutputStream omitting
@@ -116,4 +119,4 @@ public class PageExtractor implements DS
         }
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/DoubleFormatUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/DoubleFormatUtil.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/DoubleFormatUtil.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/DoubleFormatUtil.java Fri Jun 22 15:55:07 2012
@@ -24,7 +24,7 @@ package org.apache.xmlgraphics.util;
  * with a given number of decimal digits.
  * <p>
  * The contract for the format methods is this one:
- * if the source is greater than or equal to 1 (in absolute value), 
+ * if the source is greater than or equal to 1 (in absolute value),
  * use the decimals parameter to define the number of decimal digits; else,
  * use the precision parameter to define the number of decimal digits.
  * <p>
@@ -39,15 +39,18 @@ package org.apache.xmlgraphics.util;
  * <li>0.00000001 should be rendered as "0.00000001"
  * <li>0.000000001 should be rendered as "0"
  * </ul>
- * 
+ *
  * Originally authored by Julien Aym&eacute;.
  */
-public class DoubleFormatUtil {
+public final class DoubleFormatUtil {
+
+    private DoubleFormatUtil() {
+    }
 
     /**
-     * Rounds the given source value at the given precision 
+     * Rounds the given source value at the given precision
      * and writes the rounded value into the given target
-     * 
+     *
      * @param source the source value to round
      * @param decimals the decimals to round at (use if abs(source) &ge; 1.0)
      * @param precision the precision to round at (use if abs(source) &lt; 1.0)
@@ -63,12 +66,12 @@ public class DoubleFormatUtil {
     }
 
     /**
-     * Rounds the given source value at the given precision 
+     * Rounds the given source value at the given precision
      * and writes the rounded value into the given target
      * <p>
      * This method internally uses the String representation of the source value,
      * in order to avoid any double precision computation error.
-     * 
+     *
      * @param source the source value to round
      * @param decimals the decimals to round at (use if abs(source) &ge; 1.0)
      * @param precision the precision to round at (use if abs(source) &lt; 1.0)
@@ -79,6 +82,10 @@ public class DoubleFormatUtil {
             // Will always be rounded to 0
             target.append('0');
             return;
+        } else if (Double.isNaN(source) || Double.isInfinite(source)) {
+            // Cannot be formated
+            target.append(Double.toString(source));
+            return;
         }
 
         boolean negative = source < 0.0;
@@ -92,7 +99,7 @@ public class DoubleFormatUtil {
         // The only way to format precisely the double is to use the String
         // representation of the double, and then to do mathematical integer operation on it.
         String s = Double.toString(source);
-        if (source >= 10e-3 && source < 1e7) {
+        if (source >= 1e-3 && source < 1e7) {
             // Plain representation of double: "intPart.decimalPart"
             int dot = s.indexOf('.');
             String decS = s.substring(dot + 1);
@@ -103,6 +110,10 @@ public class DoubleFormatUtil {
                     target.append(s.substring(0, dot));
                 } else {
                     target.append(s);
+                    // Remove trailing zeroes
+                    for (int l = target.length() - 1; l >= 0 && target.charAt(l) == '0'; l--) {
+                        target.setLength(l);
+                    }
                 }
                 return;
             } else if (scale + 1 < decLength) {
@@ -116,7 +127,9 @@ public class DoubleFormatUtil {
         } else {
             // Scientific representation of double: "x.xxxxxEyyy"
             int dot = s.indexOf('.');
+            assert dot >= 0;
             int exp = s.indexOf('E');
+            assert exp >= 0;
             int exposant = Integer.parseInt(s.substring(exp + 1));
             String intS = s.substring(0, dot);
             String decS = s.substring(dot + 1, exp);
@@ -154,8 +167,12 @@ public class DoubleFormatUtil {
                 } else if (digits == 0) {
                     long decP = Long.parseLong(intS);
                     format(target, scale, 0L, decP);
+                } else if (decLength < digits) {
+                    long decP = Long.parseLong(intS) * tenPow(decLength + 1) + Long.parseLong(decS) * 10;
+                    format(target, exposant + decLength, 0L, decP);
                 } else {
-                    long decP = Long.parseLong(intS) * tenPow(digits) + Long.parseLong(decS.substring(0, Math.min(decLength, digits)));
+                    long subDecP = Long.parseLong(decS.substring(0, digits));
+                    long decP = Long.parseLong(intS) * tenPow(digits) + subDecP;
                     format(target, scale, 0L, decP);
                 }
             }
@@ -164,56 +181,65 @@ public class DoubleFormatUtil {
 
     /**
      * Returns true if the given source value will be rounded to zero
-     * 
+     *
      * @param source the source value to round
      * @param decimals the decimals to round at (use if abs(source) &ge; 1.0)
      * @param precision the precision to round at (use if abs(source) &lt; 1.0)
      * @return true if the source value will be rounded to zero
      */
     private static boolean isRoundedToZero(double source, int decimals, int precision) {
-        return Math.abs(source) < 5.0 / tenPow(Math.max(decimals, precision) + 1);
+        // Use 4.999999999999999 instead of 5 since in some cases, 5.0 / 1eN > 5e-N (e.g. for N = 37, 42, 45, 66, ...)
+        return source == 0.0 || Math.abs(source) < 4.999999999999999 / tenPowDouble(Math.max(decimals, precision) + 1);
     }
 
     /**
      * Most used power of ten (to avoid the cost of Math.pow(10, n)
      */
-    private static final long[] tenPows = new long[20];
+    private static final long[] POWERS_OF_TEN_LONG = new long[19];
+    private static final double[] POWERS_OF_TEN_DOUBLE = new double[30];
     static {
-        tenPows[0] = 1L;
-        for (int i = 1; i < tenPows.length; i++) {
-            tenPows[i] = tenPows[i - 1] * 10L;
+        POWERS_OF_TEN_LONG[0] = 1L;
+        for (int i = 1; i < POWERS_OF_TEN_LONG.length; i++) {
+            POWERS_OF_TEN_LONG[i] = POWERS_OF_TEN_LONG[i - 1] * 10L;
+        }
+        for (int i = 0; i < POWERS_OF_TEN_DOUBLE.length; i++) {
+            POWERS_OF_TEN_DOUBLE[i] = Double.parseDouble("1e" + i);
         }
     }
 
     /**
      * Returns ten to the power of n
-     * 
+     *
      * @param n the nth power of ten to get
      * @return ten to the power of n
      */
     public static long tenPow(int n) {
         assert n >= 0;
-        return n < tenPows.length ? tenPows[n] : (long) Math.pow(10, n);
+        return n < POWERS_OF_TEN_LONG.length ? POWERS_OF_TEN_LONG[n] : (long) Math.pow(10, n);
+    }
+
+    private static double tenPowDouble(int n) {
+        assert n >= 0;
+        return n < POWERS_OF_TEN_DOUBLE.length ? POWERS_OF_TEN_DOUBLE[n] : Math.pow(10, n);
     }
 
     /**
      * Helper method to do the custom rounding used within formatDoublePrecise
-     * 
+     *
      * @param target the buffer to write to
      * @param scale the expected rounding scale
      * @param intP the source integer part
-     * @param decP the source decimal part, truncated to scale + 1 digit 
+     * @param decP the source decimal part, truncated to scale + 1 digit
      */
     private static void format(StringBuffer target, int scale, long intP, long decP) {
-        long scaleTen = tenPow(scale);
         if (decP != 0L) {
             // decP is the decimal part of source, truncated to scale + 1 digit.
             // Custom rounding: add 5
             decP += 5L;
             decP /= 10L;
-            if (decP >= scaleTen) {
+            if (decP >= tenPowDouble(scale)) {
                 intP++;
-                decP -= scaleTen;
+                decP -= tenPow(scale);
             }
             if (decP != 0L) {
                 // Remove trailing zeroes
@@ -226,7 +252,11 @@ public class DoubleFormatUtil {
         target.append(intP);
         if (decP != 0L) {
             target.append('.');
-            while (scale > 0 && decP < tenPow(--scale)) {
+            // Use tenPow instead of tenPowDouble for scale below 18,
+            // since the casting of decP to double may cause some imprecisions:
+            // E.g. for decP = 9999999999999999L and scale = 17,
+            // decP < tenPow(16) while (double) decP == tenPowDouble(16)
+            while (scale > 0 && (scale > 18 ? decP < tenPowDouble(--scale) : decP < tenPow(--scale))) {
                 // Insert leading zeroes
                 target.append('0');
             }
@@ -235,12 +265,12 @@ public class DoubleFormatUtil {
     }
 
     /**
-     * Rounds the given source value at the given precision 
+     * Rounds the given source value at the given precision
      * and writes the rounded value into the given target
      * <p>
      * This method internally uses double precision computation and rounding,
      * so the result may not be accurate (see formatDouble method for conditions).
-     * 
+     *
      * @param source the source value to round
      * @param decimals the decimals to round at (use if abs(source) &ge; 1.0)
      * @param precision the precision to round at (use if abs(source) &lt; 1.0)
@@ -251,6 +281,10 @@ public class DoubleFormatUtil {
             // Will always be rounded to 0
             target.append('0');
             return;
+        } else if (Double.isNaN(source) || Double.isInfinite(source)) {
+            // Cannot be formated
+            target.append(Double.toString(source));
+            return;
         }
 
         boolean isPositive = source >= 0.0;
@@ -258,12 +292,12 @@ public class DoubleFormatUtil {
         int scale = (source >= 1.0) ? decimals : precision;
 
         long intPart = (long) Math.floor(source);
-        long tenScale = tenPow(scale);
+        double tenScale = tenPowDouble(scale);
         double fracUnroundedPart = (source - intPart) * tenScale;
         long fracPart = Math.round(fracUnroundedPart);
         if (fracPart >= tenScale) {
             intPart++;
-            fracPart -= tenScale;
+            fracPart = Math.round(fracPart - tenScale);
         }
         if (fracPart != 0L) {
             // Remove trailing zeroes
@@ -285,7 +319,7 @@ public class DoubleFormatUtil {
                 // append fractional part
                 target.append('.');
                 // insert leading zeroes
-                while (scale > 0 && fracPart < tenPow(--scale)) {
+                while (scale > 0 && fracPart < tenPowDouble(--scale)) {
                     target.append('0');
                 }
                 target.append(fracPart);
@@ -297,7 +331,7 @@ public class DoubleFormatUtil {
 
     /**
      * Returns the exponent of the given value
-     * 
+     *
      * @param value the value to get the exponent from
      * @return the value's exponent
      */
@@ -310,21 +344,23 @@ public class DoubleFormatUtil {
     }
 
     /**
-     * Returns true if the rounding is considered to use too many digits 
+     * Returns true if the rounding is considered to use too many digits
      * of the double for a fast rounding
-     * 
+     *
      * @param source the source to round
      * @param scale the scale to round at
      * @return true if the rounding will potentially use too many digits
      */
     private static boolean tooManyDigitsUsed(double source, int scale) {
-        return getExponant(source) + scale >= 14;
+        // if scale >= 308, 10^308 ~= Infinity
+        double decExp = Math.log10(source);
+        return scale >= 308 || decExp + scale >= 14.5;
     }
 
     /**
      * Returns true if the given source is considered to be too close
      * of a rounding value for the given scale.
-     * 
+     *
      * @param source the source to round
      * @param scale the scale to round at
      * @return true if the source will be potentially rounded at the scale
@@ -332,11 +368,12 @@ public class DoubleFormatUtil {
     private static boolean tooCloseToRound(double source, int scale) {
         source = Math.abs(source);
         long intPart = (long) Math.floor(source);
-        double fracPart = (source - intPart) * tenPow(scale);
-        double distanceToRound = Math.abs(fracPart - Math.floor(fracPart) - 0.5);
-        // For huge scale, we have to reduce the range.
-        double range = scale > 12 ? .1 : .001;
-        return distanceToRound <= range;
+        double fracPart = (source - intPart) * tenPowDouble(scale);
+        double decExp = Math.log10(source);
+        double range = decExp + scale >= 12 ? .1 : .001;
+        double distanceToRound1 = Math.abs(fracPart - Math.floor(fracPart));
+        double distanceToRound2 = Math.abs(fracPart - Math.floor(fracPart) - 0.5);
+        return distanceToRound1 <= range || distanceToRound2 <= range;
         // .001 range: Totally arbitrary range,
         // I never had a failure in 10e7 random tests with this value
         // May be JVM dependent or architecture dependent

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/ImageIODebugUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/ImageIODebugUtil.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/ImageIODebugUtil.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/ImageIODebugUtil.java Fri Jun 22 15:55:07 2012
@@ -36,7 +36,10 @@ import org.w3c.dom.Node;
  *
  * @version $Id$
  */
-public class ImageIODebugUtil {
+public final class ImageIODebugUtil {
+
+    private ImageIODebugUtil() {
+    }
 
     public static void dumpMetadata(IIOMetadata meta, boolean nativeFormat) {
         String format;

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java Fri Jun 22 15:55:07 2012
@@ -41,10 +41,14 @@ import org.apache.commons.io.IOUtils;
  * interface is very similar to the one they describe which seems to
  * be missing in the JDK.
  *
- * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
  * @version $Id$
+ *
+ * Originally authored by Thomas DeWeese.
  */
-public class Service {
+public final class Service {
+
+    private Service() {
+    }
 
     // Remember providers we have looked up before.
     static Map<String, List<String>> classMap = new java.util.HashMap<String, List<String>>();

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/UnitConv.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/UnitConv.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/UnitConv.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/UnitConv.java Fri Jun 22 15:55:07 2012
@@ -26,6 +26,9 @@ import java.awt.geom.AffineTransform;
  */
 public final class UnitConv {
 
+    private UnitConv() {
+    }
+
     /** conversion factory from millimeters to inches. */
     public static final float IN2MM = 25.4f;
 
@@ -189,27 +192,21 @@ public final class UnitConv {
             if (value.toLowerCase().indexOf(PX) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 2));
                 retValue *= 1000;
-            }
-            else if (value.toLowerCase().indexOf(INCH) > 0) {
+            } else if (value.toLowerCase().indexOf(INCH) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 2));
                 retValue *= 72000;
-            }
-            else if (value.toLowerCase().indexOf(CM) > 0) {
+            } else if (value.toLowerCase().indexOf(CM) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 2));
                 retValue *= 28346.4567;
-            }
-            else if (value.toLowerCase().indexOf(MM) > 0) {
+            } else if (value.toLowerCase().indexOf(MM) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 2));
                 retValue *= 2834.64567;
-            }
-            else if (value.toLowerCase().indexOf(MPT) > 0) {
+            } else if (value.toLowerCase().indexOf(MPT) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 3));
-            }
-            else if (value.toLowerCase().indexOf(POINT) > 0) {
+            } else if (value.toLowerCase().indexOf(POINT) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 2));
                 retValue *= 1000;
-            }
-            else if (value.toLowerCase().indexOf(PICA) > 0) {
+            } else if (value.toLowerCase().indexOf(PICA) > 0) {
                 retValue = Double.parseDouble(value.substring(0, value.length() - 2));
                 retValue *= 12000;
             }

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/dijkstra/EdgeDirectory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/dijkstra/EdgeDirectory.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/dijkstra/EdgeDirectory.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/dijkstra/EdgeDirectory.java Fri Jun 22 15:55:07 2012
@@ -42,4 +42,4 @@ public interface EdgeDirectory {
      */
     Iterator getDestinations(Vertex origin);
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/ExtendedLocalizable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/ExtendedLocalizable.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/ExtendedLocalizable.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/ExtendedLocalizable.java Fri Jun 22 15:55:07 2012
@@ -26,8 +26,9 @@ import java.util.ResourceBundle;
  * This interface provides much more control over internationalization
  * than the Localizable interface.
  *
- * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  * @version $Id$
+ *
+ * Originally authored by Stephane Hillion.
  */
 public interface ExtendedLocalizable extends Localizable {
     /**

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocaleGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocaleGroup.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocaleGroup.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocaleGroup.java Fri Jun 22 15:55:07 2012
@@ -25,8 +25,9 @@ import java.util.Locale;
  * This class represents a group of ExtendedLocalizable objects which
  * have a shared default locale.
  *
- * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  * @version $Id$
+ *
+ * Originally authored by Stephane Hillion.
  */
 public class LocaleGroup {
     /**

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/Localizable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/Localizable.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/Localizable.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/Localizable.java Fri Jun 22 15:55:07 2012
@@ -26,8 +26,9 @@ import java.util.MissingResourceExceptio
  * This interface must be implemented by the classes which must provide a
  * way to override the default locale.
  *
- * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  * @version $Id$
+ *
+ * Originally authored by Stephane Hillion.
  */
 public interface Localizable {
     /**

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocalizableSupport.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocalizableSupport.java?rev=1352939&r1=1352938&r2=1352939&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocalizableSupport.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/i18n/LocalizableSupport.java Fri Jun 22 15:55:07 2012
@@ -23,6 +23,8 @@ import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
+// CSOFF: InnerAssignment
+
 /**
  * This class provides a default implementation of the Localizable interface.
  * You can use it as a base class or as a member field and delegates various
@@ -73,8 +75,9 @@ import java.util.ResourceBundle;
  * Note: if no group is specified a LocalizableSupport object belongs to a
  * default group common to each instance of LocalizableSupport.
  *
- * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  * @version $Id$
+ *
+ * Originally authored by Stephane Hillion.
  */
 public class LocalizableSupport implements Localizable {
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message