You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by je...@apache.org on 2011/07/27 10:46:21 UTC

svn commit: r1151382 [2/2] - in /pdfbox/trunk/pdfbox/src: main/java/org/apache/pdfbox/ main/java/org/apache/pdfbox/filter/ main/java/org/apache/pdfbox/pdfparser/ main/java/org/apache/pdfbox/pdmodel/ main/java/org/apache/pdfbox/pdmodel/font/ main/java/o...

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java Wed Jul 27 08:46:12 2011
@@ -78,18 +78,18 @@ public abstract class PDFont implements 
      *  The font matrix
      */
     protected PDMatrix fontMatrix = null;
-    
+
     /**
      * This is only used if this is a font object and it has an encoding and it is
      * a type0 font with a cmap.
      */
     protected CMap cmap = null;
-    
+
     private boolean hasToUnicode = false;
 
     protected static Map<String, CMap> cmapObjects =
         Collections.synchronizedMap( new HashMap<String, CMap>() );
-    
+
     /**
      *  A list a floats representing the widths
      */
@@ -103,7 +103,8 @@ public abstract class PDFont implements 
 
     // TODO move the Map to PDType1Font as these are the 14 Standard fonts
     // which are definitely Type 1 fonts
-    private static Map<String, FontMetric> getAdobeFontMetrics() {
+    private static Map<String, FontMetric> getAdobeFontMetrics()
+    {
         Map<String, FontMetric> metrics = new HashMap<String, FontMetric>();
         addAdobeFontMetric( metrics, "Courier-Bold" );
         addAdobeFontMetric( metrics, "Courier-BoldOblique" );
@@ -126,21 +127,28 @@ public abstract class PDFont implements 
     private final static String resourceRootAFM = "org/apache/pdfbox/resources/afm/";
 
     private static void addAdobeFontMetric(
-            Map<String, FontMetric> metrics, String name ) {
-        try {
+            Map<String, FontMetric> metrics, String name )
+    {
+        try
+        {
             String resource = resourceRootAFM + name + ".afm";
             InputStream afmStream = ResourceLoader.loadResource( resource );
             if( afmStream != null )
             {
-                try {
+                try
+                {
                     AFMParser parser = new AFMParser( afmStream );
                     parser.parse();
                     metrics.put( name, parser.getResult() );
-                } finally {
+                }
+                finally
+                {
                     afmStream.close();
                 }
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             // ignore
         }
     }
@@ -192,7 +200,7 @@ public abstract class PDFont implements 
         if(fontDescriptor == null)
         {
             COSDictionary fd = (COSDictionary)font.getDictionaryObject( COSName.FONT_DESC );
-            if (fd != null) 
+            if (fd != null)
             {
                 fontDescriptor = new PDFontDescriptorDictionary( fd );
             }
@@ -207,7 +215,7 @@ public abstract class PDFont implements 
         }
         return fontDescriptor;
     }
-    
+
     /**
      * This will set the font descriptor.
      *
@@ -223,14 +231,14 @@ public abstract class PDFont implements 
         font.setItem( COSName.FONT_DESC, dic );
         this.fontDescriptor = fontDescriptor;
     }
-    
+
     /**
      * Determines the encoding for the font.
-     * This method as to be overwritten, as there are different 
+     * This method as to be overwritten, as there are different
      * possibilities to define a mapping.
      */
-   	protected abstract void determineEncoding();
-    
+    protected abstract void determineEncoding();
+
     /**
      * {@inheritDoc}
      */
@@ -377,7 +385,8 @@ public abstract class PDFont implements 
      */
     protected FontMetric getAFM()
     {
-        if(isType1Font() && afm==null){
+        if (isType1Font() && afm == null)
+        {
             COSBase baseFont = font.getDictionaryObject( COSName.BASE_FONT );
             String name = null;
             if( baseFont instanceof COSName )
@@ -389,12 +398,12 @@ public abstract class PDFont implements 
                 }
 
             }
-            else if( baseFont instanceof COSString )
+            else if ( baseFont instanceof COSString )
             {
                 COSString string = (COSString)baseFont;
                 name = string.getString();
             }
-            if( name != null )
+            if ( name != null )
             {
                 afm = afmObjects.get( name );
             }
@@ -403,7 +412,7 @@ public abstract class PDFont implements 
     }
 
     private FontMetric afm = null;
-    
+
     private COSBase encoding = null;
     /**
      * cache the {@link COSName#ENCODING} object from
@@ -415,30 +424,32 @@ public abstract class PDFont implements 
      * </pre>
      * @return
      */
-    protected COSBase getEncoding(){
-    	if(encoding==null)
-    	{
-    		encoding = font.getDictionaryObject( COSName.ENCODING );
-    	}
-    	return encoding;
+    protected COSBase getEncoding()
+    {
+        if (encoding == null)
+        {
+            encoding = font.getDictionaryObject( COSName.ENCODING );
+        }
+        return encoding;
     }
 
     /**
      * Set the encoding object from the fonts dictionary.
      * @param encoding the given encoding.
      */
-    protected void setEncoding(COSBase encoding){
+    protected void setEncoding(COSBase encoding)
+    {
         font.setItem( COSName.ENCODING, encoding );
         this.encoding = encoding;
     }
-    
+
     /**
      * Encode the given value using the CMap of the font.
-     * 
+     *
      * @param code the code to encode.
      * @param length the byte length of the given code.
      * @param isCIDFont indicates that the used font is a CID font.
-     * 
+     *
      * @return The value of the encoded character.
      */
     protected String cmapEncoding( int code, int length, boolean isCIDFont ) throws IOException
@@ -447,7 +458,7 @@ public abstract class PDFont implements 
         if (cmap != null)
         {
             retval = cmap.lookup(code, length);
-            if (retval == null && isCIDFont) 
+            if (retval == null && isCIDFont)
             {
                 retval = cmap.lookupCID(code);
             }
@@ -473,7 +484,7 @@ public abstract class PDFont implements 
         {
             retval = cmapEncoding(code, length, false);
         }
-        
+
         // there is no cmap but probably an encoding with a suitable mapping
         if( retval == null )
         {
@@ -543,7 +554,7 @@ public abstract class PDFont implements 
         if( cmapStream != null )
         {
             CMapParser parser = new CMapParser();
-            try 
+            try
             {
                 cmap = parser.parse( cmapRoot, cmapStream );
                 // limit the cache to external CMaps
@@ -599,7 +610,8 @@ public abstract class PDFont implements 
      */
     public String getSubType()
     {
-        if (subtype == null) {
+        if (subtype == null)
+        {
             subtype = font.getNameAsString( COSName.SUBTYPE );
             type1Font = "Type1".equals(subtype);
             trueTypeFont = "TrueType".equals(subtype);
@@ -612,17 +624,20 @@ public abstract class PDFont implements 
      * Determines if the font is a type 1 font.
      * @return returns true if the font is a type 1 font
      */
-    protected boolean isType1Font() {
+    protected boolean isType1Font()
+    {
         getSubType();
         return type1Font;
     }
 
-    private boolean isTrueTypeFont() {
+    private boolean isTrueTypeFont()
+    {
         getSubType();
         return trueTypeFont;
     }
 
-    private boolean isTypeFont() {
+    private boolean isTypeFont()
+    {
         getSubType();
         return typeFont;
     }
@@ -773,7 +788,7 @@ public abstract class PDFont implements 
 
     /**
      * Determines the width of the given character.
-     * @param charCode the code of the given character 
+     * @param charCode the code of the given character
      * @return the width of the character
      */
     public float getFontWidth( int charCode )
@@ -790,7 +805,7 @@ public abstract class PDFont implements 
                 width = widths.get(charCode-firstChar).floatValue();
             }
         }
-        else 
+        else
         {
             PDFontDescriptor fd = getFontDescriptor();
             if (fd instanceof PDFontDescriptorDictionary)
@@ -805,11 +820,11 @@ public abstract class PDFont implements 
      * Determines if a font as a ToUnicode entry.
      * @return true if the font has a ToUnicode entry
      */
-    protected boolean hasToUnicode() 
+    protected boolean hasToUnicode()
     {
         return hasToUnicode;
     }
-    
+
     /**
      * Sets hasToUnicode to the given value.
      * @param hasToUnicode the given value for hasToUnicode
@@ -818,11 +833,11 @@ public abstract class PDFont implements 
     {
         this.hasToUnicode = hasToUnicode;
     }
-    
+
     public COSString createString(String text) throws IOException
     {
         return new COSString(text);
-        
+
     }
 
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptorDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptorDictionary.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptorDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptorDictionary.java Wed Jul 27 08:46:12 2011
@@ -342,9 +342,10 @@ public class PDFontDescriptorDictionary 
      */
     public float getCapHeight()
     {
-        if(capHeight==Float.NEGATIVE_INFINITY){
-        	/* We observed a negative value being returned with
-             * the Scheherazade font. PDFBOX-429 was logged for this. 
+        if(capHeight==Float.NEGATIVE_INFINITY)
+        {
+            /* We observed a negative value being returned with
+             * the Scheherazade font. PDFBOX-429 was logged for this.
              * We are not sure if returning the absolute value
              * is the correct fix, but it seems to work.  */
             capHeight = java.lang.Math.abs(dic.getFloat( COSName.CAP_HEIGHT, 0 ));
@@ -352,7 +353,7 @@ public class PDFontDescriptorDictionary 
         return capHeight;
     }
 
-    
+
     /**
      * This will set the cap height for the font.
      *
@@ -371,9 +372,10 @@ public class PDFontDescriptorDictionary 
      */
     public float getXHeight()
     {
-        if(xHeight==Float.NEGATIVE_INFINITY){
-        	/* We observed a negative value being returned with
-             * the Scheherazade font. PDFBOX-429 was logged for this. 
+        if(xHeight==Float.NEGATIVE_INFINITY)
+        {
+            /* We observed a negative value being returned with
+             * the Scheherazade font. PDFBOX-429 was logged for this.
              * We are not sure if returning the absolute value
              * is the correct fix, but it seems to work.  */
             xHeight = java.lang.Math.abs(dic.getFloat( COSName.XHEIGHT, 0 ));

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java Wed Jul 27 08:46:12 2011
@@ -38,9 +38,9 @@ import org.apache.pdfbox.cos.COSArray;
  */
 public class CompositeImage
 {
-	private BufferedImage baseImage;
-	private BufferedImage smaskImage;
-	
+    private BufferedImage baseImage;
+    private BufferedImage smaskImage;
+
     /**
      * Standard constructor.
      * @param baseImage the base Image.
@@ -49,56 +49,56 @@ public class CompositeImage
      */
     public CompositeImage(BufferedImage baseImage, BufferedImage smaskImage)
     {
-    	this.baseImage = baseImage;
-    	this.smaskImage = smaskImage;
+        this.baseImage = baseImage;
+        this.smaskImage = smaskImage;
     }
-    
+
     /**
      * This method applies the specified transparency mask to a given image and returns a new BufferedImage
      * whose alpha values are computed from the transparency mask (smask) image.
      */
     public BufferedImage createMaskedImage(COSArray decodeArray) throws IOException
     {
-    	// The decode array should only be [0 1] or [1 0]. See PDF spec.
-    	// [0 1] means the smask's RGB values give transparency. Default: see PDF spec section 8.9.5.1
-    	// [1 0] means the smask's RGB values give opacity.
-
-    	boolean isOpaque = false;
-    	if (decodeArray != null)
-    	{
-    	    isOpaque = decodeArray.getInt(0) > decodeArray.getInt(1);
-    	}
-    	
-    	final int baseImageWidth = baseImage.getWidth();
-    	final int baseImageHeight = baseImage.getHeight();
-    	
-    	BufferedImage result = new BufferedImage(baseImageWidth, baseImageHeight, BufferedImage.TYPE_INT_ARGB);
-    	for (int x = 0; x < baseImageWidth; x++)
-    	{
-    		for (int y = 0; y < baseImageHeight; y++)
-    		{
-    			int rgb = baseImage.getRGB(x, y);
-    			int alpha = smaskImage.getRGB(x, y);
-    			
-    			// The smask image defines a transparency mask but it has no alpha values itself, instead
-    			// using the greyscale values to indicate transparency.
-    			// 0xAARRGGBB
-    			
-    			// We need to remove any alpha value in the main image.
-    			int rgbOnly = 0x00FFFFFF & rgb;
-    			
-    			// We need to use one of the rgb values as the new alpha value for the main image.
-    			// It seems the mask is greyscale, so it shouldn't matter whether we use R, G or B
-    			// as the indicator of transparency.
-    			if (isOpaque)
-    			{
-    				alpha = ~alpha;
-    			}
-    			int alphaOnly = alpha << 24;
-    			
-    			result.setRGB(x, y, rgbOnly | alphaOnly);
-    		}
-    	}
-    	return result;
+        // The decode array should only be [0 1] or [1 0]. See PDF spec.
+        // [0 1] means the smask's RGB values give transparency. Default: see PDF spec section 8.9.5.1
+        // [1 0] means the smask's RGB values give opacity.
+
+        boolean isOpaque = false;
+        if (decodeArray != null)
+        {
+            isOpaque = decodeArray.getInt(0) > decodeArray.getInt(1);
+        }
+
+        final int baseImageWidth = baseImage.getWidth();
+        final int baseImageHeight = baseImage.getHeight();
+
+        BufferedImage result = new BufferedImage(baseImageWidth, baseImageHeight, BufferedImage.TYPE_INT_ARGB);
+        for (int x = 0; x < baseImageWidth; x++)
+        {
+            for (int y = 0; y < baseImageHeight; y++)
+            {
+                int rgb = baseImage.getRGB(x, y);
+                int alpha = smaskImage.getRGB(x, y);
+
+                // The smask image defines a transparency mask but it has no alpha values itself, instead
+                // using the greyscale values to indicate transparency.
+                // 0xAARRGGBB
+
+                // We need to remove any alpha value in the main image.
+                int rgbOnly = 0x00FFFFFF & rgb;
+
+                // We need to use one of the rgb values as the new alpha value for the main image.
+                // It seems the mask is greyscale, so it shouldn't matter whether we use R, G or B
+                // as the indicator of transparency.
+                if (isOpaque)
+                {
+                    alpha = ~alpha;
+                }
+                int alphaOnly = alpha << 24;
+
+                result.setRGB(x, y, rgbOnly | alphaOnly);
+            }
+        }
+        return result;
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDJpeg.java Wed Jul 27 08:46:12 2011
@@ -59,11 +59,11 @@ public class PDJpeg extends PDXObjectIma
 {
 
     private static final String JPG = "jpg";
-    
+
     private static final List<String> DCT_FILTERS = new ArrayList<String>();
 
-    private final static float defaultCompressionLevel = 0.75f;
-    
+    private static final float DEFAULT_COMPRESSION_LEVEL = 0.75f;
+
     static
     {
         DCT_FILTERS.add( COSName.DCT_DECODE.getName() );
@@ -96,7 +96,7 @@ public class PDJpeg extends PDXObjectIma
         dic.setItem( COSName.TYPE, COSName.XOBJECT );
 
         BufferedImage image = getRGBImage();
-        if (image != null) 
+        if (image != null)
         {
             setBitsPerComponent( 8 );
             setColorSpace( PDDeviceRGB.INSTANCE );
@@ -108,7 +108,7 @@ public class PDJpeg extends PDXObjectIma
 
     /**
      * Construct from a buffered image.
-     * The default compression level of 0.75 will be used. 
+     * The default compression level of 0.75 will be used.
      *
      * @param doc The document to create the image as part of.
      * @param bi The image to convert to a jpeg
@@ -117,9 +117,9 @@ public class PDJpeg extends PDXObjectIma
     public PDJpeg( PDDocument doc, BufferedImage bi ) throws IOException
     {
         super( new PDStream( doc ) , JPG);
-        createImageStream(doc, bi, defaultCompressionLevel);
+        createImageStream(doc, bi, DEFAULT_COMPRESSION_LEVEL);
     }
-    
+
     /**
      * Construct from a buffered image.
      *
@@ -133,7 +133,7 @@ public class PDJpeg extends PDXObjectIma
         super( new PDStream( doc ), JPG);
         createImageStream(doc, bi, compressionQuality);
     }
-    
+
     private void createImageStream(PDDocument doc, BufferedImage bi, float compressionQuality) throws IOException
     {
         BufferedImage alpha = null;
@@ -164,29 +164,29 @@ public class PDJpeg extends PDXObjectIma
             g.drawImage(bi, 0, 0, null);
             bi = image;
         }
-        
+
         java.io.OutputStream os = getCOSStream().createFilteredStream();
         try
         {
             ImageWriter writer = null;
             Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName(JPG);
-            if (iter.hasNext()) 
+            if (iter.hasNext())
             {
                 writer = iter.next();
             }
             ImageOutputStream ios = ImageIO.createImageOutputStream(os);
             writer.setOutput(ios);
-                
+
             // Set the compression quality
             JPEGImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
             iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
             iwparam.setCompressionQuality(compressionQuality);
-                
+
             // Write the image
             writer.write(null, new IIOImage(bi, null, null), iwparam);
-                
+
             writer.dispose();
-            
+
             COSDictionary dic = getCOSStream();
             dic.setItem( COSName.FILTER, COSName.DCT_DECODE );
             dic.setItem( COSName.SUBTYPE, COSName.IMAGE);
@@ -198,17 +198,17 @@ public class PDJpeg extends PDXObjectIma
                 dic.setItem(COSName.SMASK, alphaPdImage);
             }
             setBitsPerComponent( 8 );
-            if (bi.getColorModel().getNumComponents() == 3) 
+            if (bi.getColorModel().getNumComponents() == 3)
             {
                 setColorSpace( PDDeviceRGB.INSTANCE );
-            } 
+            }
             else
             {
-                if (bi.getColorModel().getNumComponents() == 1) 
+                if (bi.getColorModel().getNumComponents() == 1)
                 {
                     setColorSpace( new PDDeviceGray() );
-                } 
-                else 
+                }
+                else
                 {
                     throw new IllegalStateException();
                 }
@@ -230,7 +230,7 @@ public class PDJpeg extends PDXObjectIma
     {   //TODO PKOCH
         BufferedImage bi = null;
         boolean readError = false;
-        try 
+        try
         {
             ByteArrayOutputStream os = new ByteArrayOutputStream();
             write2OutputStream(os);
@@ -238,23 +238,23 @@ public class PDJpeg extends PDXObjectIma
             byte[] img = os.toByteArray();
 
             // 1. try to read jpeg image
-            try 
+            try
             {
                 bi = ImageIO.read(new ByteArrayInputStream(img));
-            } 
-            catch (IIOException iioe) 
+            }
+            catch (IIOException iioe)
             {
                 // cannot read jpeg
                 readError = true;
-            } 
-            catch (Exception ignore) 
+            }
+            catch (Exception ignore)
             {
             }
 
             // 2. try to read jpeg again. some jpegs have some strange header containing
             //    "Adobe " at some place. so just replace the header with a valid jpeg header.
             // TODO : not sure if it works for all cases
-            if (bi == null && readError) 
+            if (bi == null && readError)
             {
                 byte[] newImage = replaceHeader(img);
 
@@ -262,30 +262,30 @@ public class PDJpeg extends PDXObjectIma
 
                 bi = ImageIO.read(bai);
             }
-        } 
-        finally 
+        }
+        finally
         {
         }
-        
+
         // If there is a 'soft mask' image then we use that as a transparency mask.
         PDXObjectImage smask = getSMaskImage();
         if (smask != null)
         {
             BufferedImage smaskBI = smask.getRGBImage();
-            
-           	COSArray decodeArray = smask.getDecode();
-           	CompositeImage compositeImage = new CompositeImage(bi, smaskBI);
-           	BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
+
+            COSArray decodeArray = smask.getDecode();
+            CompositeImage compositeImage = new CompositeImage(bi, smaskBI);
+            BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
 
             return rgbImage;
         }
         else
         {
-        	// But if there is no soft mask, use the unaltered image.
+            // But if there is no soft mask, use the unaltered image.
             return bi;
         }
     }
-    
+
     /**
      * This writes the JPeg to out.
      * {@inheritDoc}
@@ -307,12 +307,12 @@ public class PDJpeg extends PDXObjectIma
      * @return given file as byte array
      * @throws IOException if somethin went wrong during reading the file
      */
-    public static byte[] getBytesFromFile(File file) throws IOException 
+    public static byte[] getBytesFromFile(File file) throws IOException
     {
         InputStream is = new FileInputStream(file);
         long length = file.length();
 
-        if (length > Integer.MAX_VALUE) 
+        if (length > Integer.MAX_VALUE)
         {
             // File is too large
             throw new IOException("File is tooo large");
@@ -326,13 +326,13 @@ public class PDJpeg extends PDXObjectIma
         int numRead = 0;
 
         while (offset < bytes.length
-                && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) 
+                && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0)
         {
             offset += numRead;
         }
 
         // Ensure all the bytes have been read in
-        if (offset < bytes.length) 
+        if (offset < bytes.length)
         {
             throw new IOException("Could not completely read file "+file.getName());
         }
@@ -340,13 +340,13 @@ public class PDJpeg extends PDXObjectIma
         return bytes;
     }
 
-    private int getHeaderEndPos(byte[] image) 
+    private int getHeaderEndPos(byte[] image)
     {
-        for (int i = 0; i < image.length; i++) 
+        for (int i = 0; i < image.length; i++)
         {
             byte b = image[i];
-            if (b == (byte) 0xDB) 
-            {        
+            if (b == (byte) 0xDB)
+            {
                 // TODO : check for ff db
                 return i -2;
             }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java Wed Jul 27 08:46:12 2011
@@ -133,9 +133,9 @@ public class PDPixelMap extends PDXObjec
             int width = getWidth();
             int height = getHeight();
             int bpc = getBitsPerComponent();
-            
+
             byte[] array = getPDStream().getByteArray();
-            if (array.length == 0) 
+            if (array.length == 0)
             {
                 log.error("Something went wrong ... the pixelmap doesn't contain any data.");
                 return null;
@@ -147,7 +147,7 @@ public class PDPixelMap extends PDXObjec
                 log.error("getColorSpace() returned NULL.  Predictor = " + getPredictor());
                 return null;
             }
-            
+
             ColorModel cm = null;
             if (colorspace instanceof PDIndexed)
             {
@@ -181,7 +181,8 @@ public class PDPixelMap extends PDXObjec
                 {
                     cm = new IndexColorModel(bpc, size+1, r, g, b, a);
                 }
-                else {
+                else
+                {
                     if (maskArray != null)
                     {
                         cm = new IndexColorModel(bpc, size+1, r, g, b, maskArray.getInt(0));
@@ -198,7 +199,7 @@ public class PDPixelMap extends PDXObjec
                 if (colorspace instanceof PDDeviceGray)
                 {
                     COSArray decode = getDecode();
-                    // we have to invert the b/w-values, 
+                    // we have to invert the b/w-values,
                     // if the Decode array exists and consists of (1,0)
                     if (decode != null && decode.getInt(0) == 1)
                     {
@@ -211,7 +212,7 @@ public class PDPixelMap extends PDXObjec
                 }
                 else if (colorspace instanceof PDICCBased)
                 {
-                    if ( ((PDICCBased)colorspace).getNumberOfComponents() == 1) 
+                    if ( ((PDICCBased)colorspace).getNumberOfComponents() == 1)
                     {
                         map = new byte[] {(byte)0xff};
                     }
@@ -228,48 +229,52 @@ public class PDPixelMap extends PDXObjec
             }
             else
             {
-                if (colorspace instanceof PDICCBased) 
+                if (colorspace instanceof PDICCBased)
                 {
-                    if (((PDICCBased)colorspace).getNumberOfComponents() == 1) 
+                    if (((PDICCBased)colorspace).getNumberOfComponents() == 1)
                     {
                         byte[] map = new byte[] {(byte)0xff};
                         cm = new IndexColorModel(bpc, 1, map, map, map, Transparency.OPAQUE);
                     }
                     else
+                    {
                         cm = colorspace.createColorModel( bpc );
+                    }
                 }
                 else
+                {
                     cm = colorspace.createColorModel( bpc );
+                }
             }
 
             log.debug("ColorModel: " + cm.toString());
             WritableRaster raster = cm.createCompatibleWritableRaster( width, height );
             DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
             byte[] bufferData = buffer.getData();
-        
-            System.arraycopy( array, 0,bufferData, 0, 
+
+            System.arraycopy( array, 0,bufferData, 0,
                     (array.length<bufferData.length?array.length: bufferData.length) );
             image = new BufferedImage(cm, raster, false, null);
-            
-	        // If there is a 'soft mask' image then we use that as a transparency mask.
-	        PDXObjectImage smask = getSMaskImage();
-	        if (smask != null)
-	        {
+
+            // If there is a 'soft mask' image then we use that as a transparency mask.
+            PDXObjectImage smask = getSMaskImage();
+            if (smask != null)
+            {
                 BufferedImage smaskBI = smask.getRGBImage();
-                
-               	COSArray decodeArray = smask.getDecode();
-               	
-               	CompositeImage compositeImage = new CompositeImage(image, smaskBI);
-               	BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
+
+                COSArray decodeArray = smask.getDecode();
+
+                CompositeImage compositeImage = new CompositeImage(image, smaskBI);
+                BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
 
                 return rgbImage;
-	        }
-	        else
-	        {
-	        	// But if there is no soft mask, use the unaltered image.
-	            return image;
-	        }
-        } 
+            }
+            else
+            {
+                // But if there is no soft mask, use the unaltered image.
+                return image;
+            }
+        }
         catch (Exception exception)
         {
             log.error(exception, exception);
@@ -287,7 +292,7 @@ public class PDPixelMap extends PDXObjec
     public void write2OutputStream(OutputStream out) throws IOException
     {
         getRGBImage();
-        if (image!=null)
+        if (image != null)
         {
             ImageIO.write(image, "png", out);
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java Wed Jul 27 08:46:12 2011
@@ -59,7 +59,7 @@ public abstract class PDXObjectImage ext
      * This contains the suffix used when writing to file.
      */
     private String suffix;
-    
+
     private PDGraphicsState graphicsState;
 
     /**
@@ -101,22 +101,23 @@ public abstract class PDXObjectImage ext
      * See section 11.5 of the pdf specification for details on Soft Masks.
      *
      * @return the PDXObjectImage of the SMask if there is one, else <code>null</code>.
+     * @throws IOException if an I/O error occurs creating an XObject
      */
     public PDXObjectImage getSMaskImage() throws IOException
     {
-    	COSStream cosStream = getPDStream().getStream();
-    	COSBase smask = cosStream.getDictionaryObject(COSName.SMASK);
-    	
-    	if (smask == null)
-    	{
-    		return null;
-    	}
-    	else
-    	{
-    		return (PDXObjectImage)PDXObject.createXObject(smask);
-    	}
+        COSStream cosStream = getPDStream().getStream();
+        COSBase smask = cosStream.getDictionaryObject(COSName.SMASK);
+
+        if (smask == null)
+        {
+            return null;
+        }
+        else
+        {
+            return (PDXObjectImage)PDXObject.createXObject(smask);
+        }
     }
-    
+
     /**
      * Writes the Image to out.
      * @param out the OutputStream that the Image is written to.
@@ -249,7 +250,7 @@ file.
         if( cs != null )
         {
             retval = PDColorSpaceFactory.createColorSpace( cs );
-            if (retval == null) 
+            if (retval == null)
                 {
                     log.info("About to return NULL from createColorSpace branch");
                 }
@@ -263,7 +264,7 @@ file.
                 COSName.CCITTFAX_DECODE_ABBREVIATION.equals( filter ) )
             {
                 retval = new PDDeviceGray();
-                if (retval == null) 
+                if (retval == null)
                     {
                         log.info("About to return NULL from CCITT branch");
                     }
@@ -271,7 +272,7 @@ file.
             else if( COSName.JBIG2_DECODE.equals( filter ) )
             {
                 retval = new PDDeviceGray();
-                if (retval == null) 
+                if (retval == null)
                 {
                     log.info("About to return NULL from JBIG2 branch");
                 }
@@ -282,7 +283,7 @@ file.
                 retval = graphicsState.getNonStrokingColor().getColorSpace();
                 log.info("Stencil Mask branch returning " + retval.toString());
                 //throw new IOException("Trace the Stencil Mask!!!!");
-            
+
             }
             else
             {
@@ -317,7 +318,7 @@ file.
     {
         return suffix;
     }
-    
+
     /**
      * Get the ImageMask flag. Used in Stencil Masking.  Section 4.8.5 of the spec.
      *
@@ -327,9 +328,9 @@ file.
     {
         return getCOSStream().getBoolean( COSName.IMAGE_MASK, false );
     }
-    
+
     /**
-     * Allow the Invoke operator to set the graphics state so that, 
+     * Allow the Invoke operator to set the graphics state so that,
      * in the case of an Image Mask, we can get to the current nonstroking colorspace.
      * @param newGS The new graphicstate
      */
@@ -342,18 +343,19 @@ file.
      * Returns the Decode Array of an XObjectImage.
      * @return the decode array
      */
-    public COSArray getDecode() {
+    public COSArray getDecode()
+    {
         COSBase decode = getCOSStream().getDictionaryObject( COSName.DECODE );
-        if (decode != null && decode instanceof COSArray) 
+        if (decode != null && decode instanceof COSArray)
         {
             return (COSArray)decode;
         }
         return null;
     }
 
-    /** 
+    /**
      * Returns the optional mask of a XObjectImage if there is one.
-     * 
+     *
      * @return The mask as COSArray otherwise null.
      */
     public COSArray getMask()

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java Wed Jul 27 08:46:12 2011
@@ -47,7 +47,7 @@ public class DateConverter
         new SimpleDateFormat("EEEE, MMM dd, yyyy hh:mm:ss a", Locale.ENGLISH),
         new SimpleDateFormat("MM/dd/yyyy hh:mm:ss", Locale.ENGLISH),
         new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH),
-        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH), 
+        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH),
         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz", Locale.ENGLISH),
         new SimpleDateFormat("EEEE, MMM dd, yyyy", Locale.ENGLISH), // Acrobat Distiller 1.0.2 for Macintosh
         new SimpleDateFormat("EEEE MMM dd, yyyy HH:mm:ss", Locale.ENGLISH), // ECMP5
@@ -55,44 +55,44 @@ public class DateConverter
         new SimpleDateFormat("EEEE, MMM dd, yyyy 'at' hh:mma", Locale.ENGLISH), // Acrobat Net Distiller 1.0 for Windows
         new SimpleDateFormat("d/MM/yyyy hh:mm:ss", Locale.ENGLISH), // PDFBOX-164
         new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.ENGLISH), // PDFBOX-170
-        new SimpleDateFormat("EEEEEEEEEE, MMMMMMMMMMMM dd, yyyy", Locale.ENGLISH),  // PDFBOX-465 
-        new SimpleDateFormat("dd MMM yyyy hh:mm:ss", Locale.ENGLISH),  // for 26 May 2000 11:25:00          
+        new SimpleDateFormat("EEEEEEEEEE, MMMMMMMMMMMM dd, yyyy", Locale.ENGLISH),  // PDFBOX-465
+        new SimpleDateFormat("dd MMM yyyy hh:mm:ss", Locale.ENGLISH),  // for 26 May 2000 11:25:00
         new SimpleDateFormat("dd MMM yyyy hh:mm", Locale.ENGLISH),  // for 26 May 2000 11:25
-		new SimpleDateFormat("M/dd/yyyy hh:mm:ss", Locale.ENGLISH),		
-		new SimpleDateFormat("MM/d/yyyy hh:mm:ss", Locale.ENGLISH),
-		new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH),
-		new SimpleDateFormat("MM/d/yyyy", Locale.ENGLISH),
-		new SimpleDateFormat("M/d/yyyy hh:mm:ss", Locale.ENGLISH),
-		new SimpleDateFormat("M/d/yyyy", Locale.ENGLISH),
-		new SimpleDateFormat("M/d/yy hh:mm:ss", Locale.ENGLISH),
-		new SimpleDateFormat("M/d/yy", Locale.ENGLISH),
-        new SimpleDateFormat("yyyymmdd hh:mm:ss Z"), // 
-        new SimpleDateFormat("yyyymmdd hh:mm:ss"), 	 // 
-        new SimpleDateFormat("yyyymmdd'+00''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+01''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+02''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+03''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+04''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+05''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+06''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+07''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+08''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+09''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+10''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+11''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'+12''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-01''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-02''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-03''00'''"), // 
+        new SimpleDateFormat("M/dd/yyyy hh:mm:ss", Locale.ENGLISH),
+        new SimpleDateFormat("MM/d/yyyy hh:mm:ss", Locale.ENGLISH),
+        new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH),
+        new SimpleDateFormat("MM/d/yyyy", Locale.ENGLISH),
+        new SimpleDateFormat("M/d/yyyy hh:mm:ss", Locale.ENGLISH),
+        new SimpleDateFormat("M/d/yyyy", Locale.ENGLISH),
+        new SimpleDateFormat("M/d/yy hh:mm:ss", Locale.ENGLISH),
+        new SimpleDateFormat("M/d/yy", Locale.ENGLISH),
+        new SimpleDateFormat("yyyymmdd hh:mm:ss Z"), //
+        new SimpleDateFormat("yyyymmdd hh:mm:ss"),   //
+        new SimpleDateFormat("yyyymmdd'+00''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+01''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+02''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+03''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+04''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+05''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+06''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+07''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+08''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+09''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+10''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+11''00'''"), //
+        new SimpleDateFormat("yyyymmdd'+12''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-01''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-02''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-03''00'''"), //
         new SimpleDateFormat("yyyymmdd'-04''00'''"), //
-        new SimpleDateFormat("yyyymmdd'-05''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-06''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-07''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-08''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-09''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-10''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-11''00'''"), // 
-        new SimpleDateFormat("yyyymmdd'-12''00'''"), // 
+        new SimpleDateFormat("yyyymmdd'-05''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-06''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-07''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-08''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-09''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-10''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-11''00'''"), //
+        new SimpleDateFormat("yyyymmdd'-12''00'''"), //
         new SimpleDateFormat("yyyymmdd"), // for 20090401+0200
     };
 
@@ -244,10 +244,10 @@ public class DateConverter
                                 //parseInt cannot handle the + sign
                                 hours = Integer.parseInt( date.substring( 15, 17 ) );
                             }
-                            else if (sign == '-') 
-                            { 
-                                hours = -Integer.parseInt(date.substring(15,17)); 
-                            } 
+                            else if (sign == '-')
+                            {
+                                hours = -Integer.parseInt(date.substring(15,17));
+                            }
                             else
                             {
                                 hours = -Integer.parseInt( date.substring( 14, 16 ) );

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java Wed Jul 27 08:46:12 2011
@@ -26,7 +26,7 @@ import java.awt.geom.AffineTransform;
  */
 public class Matrix implements Cloneable
 {
-    static final float[] default_single =
+    static final float[] DEFAULT_SINGLE =
     {
         1,0,0,
         0,1,0,
@@ -40,17 +40,17 @@ public class Matrix implements Cloneable
      */
     public Matrix()
     {
-    	single = new float[default_single.length];
-    	reset();
+        single = new float[DEFAULT_SINGLE.length];
+        reset();
     }
-    
+
     /**
      * This method resets the numbers in this Matrix to the original values, which are
      * the values that a newly constructed Matrix would have.
      */
     public void reset()
     {
-    	System.arraycopy(default_single, 0, single, 0, default_single.length);
+        System.arraycopy(DEFAULT_SINGLE, 0, single, 0, DEFAULT_SINGLE.length);
     }
 
     /**
@@ -166,7 +166,7 @@ public class Matrix implements Cloneable
      * <p/>
      * It is allowed to have (other == this) or (result == this) or indeed (other == result) but if this is done,
      * the backing float[] matrix values may be copied in order to ensure a correct product.
-     * 
+     *
      * @param other the second operand Matrix in the multiplication
      * @param result the Matrix instance into which the result should be stored. If result is null, a new Matrix
      *               instance is created.
@@ -174,51 +174,69 @@ public class Matrix implements Cloneable
      */
     public Matrix multiply( Matrix other, Matrix result )
     {
-    	if (result == null)
-    	{
-    		result = new Matrix();
-    	}
-    	
-        if (other != null && other.single != null) 
+        if (result == null)
+        {
+            result = new Matrix();
+        }
+
+        if (other != null && other.single != null)
         {
-        	// the operands
-        	float[] thisOperand = this.single;
-        	float[] otherOperand = other.single;
-        	
-        	// We're multiplying 2 sets of floats together to produce a third, but we allow
-        	// any of these float[] instances to be the same objects.
-        	// There is the possibility then to overwrite one of the operands with result values
-        	// and therefore corrupt the result.
-        	
-        	// If either of these operands are the same float[] instance as the result, then
-        	// they need to be copied.
-        	
-        	if (this == result)
-        	{
-        		final float[] thisOrigVals = new float[this.single.length];
-        		System.arraycopy(this.single, 0, thisOrigVals, 0, this.single.length);
-        		
-        		thisOperand = thisOrigVals;
-        	}
-        	if (other == result)
-        	{
-        		final float[] otherOrigVals = new float[other.single.length];
-        		System.arraycopy(other.single, 0, otherOrigVals, 0, other.single.length);
-        		
-        		otherOperand = otherOrigVals;
-        	}
-        	
-            result.single[0] = thisOperand[0] * otherOperand[0] + thisOperand[1] * otherOperand[3] + thisOperand[2] * otherOperand[6];
-            result.single[1] = thisOperand[0] * otherOperand[1] + thisOperand[1] * otherOperand[4] + thisOperand[2] * otherOperand[7];
-            result.single[2] = thisOperand[0] * otherOperand[2] + thisOperand[1] * otherOperand[5] + thisOperand[2] * otherOperand[8];
-            result.single[3] = thisOperand[3] * otherOperand[0] + thisOperand[4] * otherOperand[3] + thisOperand[5] * otherOperand[6];
-            result.single[4] = thisOperand[3] * otherOperand[1] + thisOperand[4] * otherOperand[4] + thisOperand[5] * otherOperand[7];
-            result.single[5] = thisOperand[3] * otherOperand[2] + thisOperand[4] * otherOperand[5] + thisOperand[5] * otherOperand[8];
-            result.single[6] = thisOperand[6] * otherOperand[0] + thisOperand[7] * otherOperand[3] + thisOperand[8] * otherOperand[6];
-            result.single[7] = thisOperand[6] * otherOperand[1] + thisOperand[7] * otherOperand[4] + thisOperand[8] * otherOperand[7];
-            result.single[8] = thisOperand[6] * otherOperand[2] + thisOperand[7] * otherOperand[5] + thisOperand[8] * otherOperand[8];
+            // the operands
+            float[] thisOperand = this.single;
+            float[] otherOperand = other.single;
+
+            // We're multiplying 2 sets of floats together to produce a third, but we allow
+            // any of these float[] instances to be the same objects.
+            // There is the possibility then to overwrite one of the operands with result values
+            // and therefore corrupt the result.
+
+            // If either of these operands are the same float[] instance as the result, then
+            // they need to be copied.
+
+            if (this == result)
+            {
+                final float[] thisOrigVals = new float[this.single.length];
+                System.arraycopy(this.single, 0, thisOrigVals, 0, this.single.length);
+
+                thisOperand = thisOrigVals;
+            }
+            if (other == result)
+            {
+                final float[] otherOrigVals = new float[other.single.length];
+                System.arraycopy(other.single, 0, otherOrigVals, 0, other.single.length);
+
+                otherOperand = otherOrigVals;
+            }
+
+            result.single[0] = thisOperand[0] * otherOperand[0]
+                             + thisOperand[1] * otherOperand[3]
+                             + thisOperand[2] * otherOperand[6];
+            result.single[1] = thisOperand[0] * otherOperand[1]
+                             + thisOperand[1] * otherOperand[4]
+                             + thisOperand[2] * otherOperand[7];
+            result.single[2] = thisOperand[0] * otherOperand[2]
+                             + thisOperand[1] * otherOperand[5]
+                             + thisOperand[2] * otherOperand[8];
+            result.single[3] = thisOperand[3] * otherOperand[0]
+                             + thisOperand[4] * otherOperand[3]
+                             + thisOperand[5] * otherOperand[6];
+            result.single[4] = thisOperand[3] * otherOperand[1]
+                             + thisOperand[4] * otherOperand[4]
+                             + thisOperand[5] * otherOperand[7];
+            result.single[5] = thisOperand[3] * otherOperand[2]
+                             + thisOperand[4] * otherOperand[5]
+                             + thisOperand[5] * otherOperand[8];
+            result.single[6] = thisOperand[6] * otherOperand[0]
+                             + thisOperand[7] * otherOperand[3]
+                             + thisOperand[8] * otherOperand[6];
+            result.single[7] = thisOperand[6] * otherOperand[1]
+                             + thisOperand[7] * otherOperand[4]
+                             + thisOperand[8] * otherOperand[7];
+            result.single[8] = thisOperand[6] * otherOperand[2]
+                             + thisOperand[7] * otherOperand[5]
+                             + thisOperand[8] * otherOperand[8];
         }
-        
+
         return result;
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java Wed Jul 27 08:46:12 2011
@@ -26,12 +26,12 @@ import org.apache.pdfbox.pdmodel.PDDocum
 /**
  * Wrap stripped text in simple HTML, trying to form HTML paragraphs. Paragraphs
  * broken by pages, columns, or figures are not mended.
- * 
- * 
+ *
+ *
  * @author jjb - http://www.johnjbarton.com
  * @version $Revision: 1.3 $
  */
-public class PDFText2HTML extends PDFTextStripper 
+public class PDFText2HTML extends PDFTextStripper
 {
     private static final int INITIAL_PDF_TO_HTML_BYTES = 8192;
 
@@ -42,7 +42,7 @@ public class PDFText2HTML extends PDFTex
      * @param encoding The encoding to be used
      * @throws IOException If there is an error during initialization.
      */
-    public PDFText2HTML(String encoding) throws IOException 
+    public PDFText2HTML(String encoding) throws IOException
     {
         super(encoding);
         setLineSeparator(systemLineSeparator);
@@ -57,20 +57,20 @@ public class PDFText2HTML extends PDFTex
     /**
      * Write the header to the output document. Now also writes the tag defining
      * the character encoding.
-     * 
+     *
      * @throws IOException
      *             If there is a problem writing out the header to the document.
      */
-    protected void writeHeader() throws IOException 
+    protected void writeHeader() throws IOException
     {
         StringBuffer buf = new StringBuffer(INITIAL_PDF_TO_HTML_BYTES);
-        buf.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"" + "\n" 
+        buf.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"" + "\n"
                 + "\"http://www.w3.org/TR/html4/loose.dtd\">\n");
         buf.append("<html><head>");
         buf.append("<title>" + escape(getTitle()) + "</title>\n");
         if(outputEncoding != null)
         {
-            buf.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" 
+            buf.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="
                     + this.outputEncoding + "\">\n");
         }
         buf.append("</head>\n");
@@ -81,9 +81,9 @@ public class PDFText2HTML extends PDFTex
     /**
      * {@inheritDoc}
      */
-    protected void writePage() throws IOException 
+    protected void writePage() throws IOException
     {
-        if (onFirstPage) 
+        if (onFirstPage)
         {
             writeHeader();
             onFirstPage = false;
@@ -94,7 +94,7 @@ public class PDFText2HTML extends PDFTex
     /**
      * {@inheritDoc}
      */
-    public void endDocument(PDDocument pdf) throws IOException 
+    public void endDocument(PDDocument pdf) throws IOException
     {
         super.writeString("</body></html>");
     }
@@ -102,41 +102,41 @@ public class PDFText2HTML extends PDFTex
     /**
      * This method will attempt to guess the title of the document using
      * either the document properties or the first lines of text.
-     * 
+     *
      * @return returns the title.
      */
-    protected String getTitle() 
+    protected String getTitle()
     {
         String titleGuess = document.getDocumentInformation().getTitle();
         if(titleGuess != null && titleGuess.length() > 0)
         {
             return titleGuess;
         }
-        else 
+        else
         {
             Iterator<List<TextPosition>> textIter = getCharactersByArticle().iterator();
             float lastFontSize = -1.0f;
 
             StringBuffer titleText = new StringBuffer();
-            while (textIter.hasNext()) 
+            while (textIter.hasNext())
             {
                 Iterator<TextPosition> textByArticle = textIter.next().iterator();
-                while (textByArticle.hasNext()) 
+                while (textByArticle.hasNext())
                 {
                     TextPosition position = textByArticle.next();
 
                     float currentFontSize = position.getFontSize();
                     //If we're past 64 chars we will assume that we're past the title
-                    //64 is arbitrary 
-                    if (currentFontSize != lastFontSize || titleText.length() > 64) 
+                    //64 is arbitrary
+                    if (currentFontSize != lastFontSize || titleText.length() > 64)
                     {
-                        if (titleText.length() > 0) 
+                        if (titleText.length() > 0)
                         {
                             return titleText.toString();
                         }
                         lastFontSize = currentFontSize;
                     }
-                    if (currentFontSize > 13.0f) 
+                    if (currentFontSize > 13.0f)
                     { // most body text is 12pt
                         titleText.append(position.getCharacter());
                     }
@@ -150,18 +150,18 @@ public class PDFText2HTML extends PDFTex
     /**
      * Write out the article separator (div tag) with proper text direction
      * information.
-     * 
+     *
      * @param isltr true if direction of text is left to right
      * @throws IOException
      *             If there is an error writing to the stream.
      */
-    protected void startArticle(boolean isltr) throws IOException 
+    protected void startArticle(boolean isltr) throws IOException
     {
-        if (isltr) 
+        if (isltr)
         {
             super.writeString("<div>");
-        } 
-        else 
+        }
+        else
         {
             super.writeString("<div dir=\"RTL\">");
         }
@@ -169,11 +169,11 @@ public class PDFText2HTML extends PDFTex
 
     /**
      * Write out the article separator.
-     * 
+     *
      * @throws IOException
      *             If there is an error writing to the stream.
      */
-    protected void endArticle() throws IOException 
+    protected void endArticle() throws IOException
     {
         super.endArticle();
         super.writeString("</div>");
@@ -186,11 +186,11 @@ public class PDFText2HTML extends PDFTex
      * @throws IOException
      *             If there is an error writing to the stream.
      */
-    protected void writeString(String chars) throws IOException 
+    protected void writeString(String chars) throws IOException
     {
         super.writeString(escape(chars));
     }
-    
+
     /**
      * Escape some HTML characters.
      *
@@ -199,19 +199,19 @@ public class PDFText2HTML extends PDFTex
      */
     private String escape(String chars)
     {
-    	StringBuilder builder = new StringBuilder(chars.length());
-        for (int i = 0; i < chars.length(); i++) 
+        StringBuilder builder = new StringBuilder(chars.length());
+        for (int i = 0; i < chars.length(); i++)
         {
             char c = chars.charAt(i);
             // write non-ASCII as named entities
-            if ((c < 32) || (c > 126)) 
+            if ((c < 32) || (c > 126))
             {
                 int charAsInt = c;
                 builder.append("&#").append(charAsInt).append(";");
-            } 
-            else 
+            }
+            else
             {
-                switch (c) 
+                switch (c)
                 {
                 case 34:
                     builder.append("&quot;");

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PositionWrapper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PositionWrapper.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PositionWrapper.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PositionWrapper.java Wed Jul 27 08:46:12 2011
@@ -30,39 +30,44 @@ package org.apache.pdfbox.util;
  * @author m.martinez@ll.mit.edu
  *
  */
-public class PositionWrapper{
-	
-	private boolean isLineStart = false;
-	private boolean isParagraphStart = false;
-	private boolean isPageBreak = false;
-	private boolean isHangingIndent = false;
-	private boolean isArticleStart = false;
-	
-	private TextPosition position = null;
-	
-	/**
-	 * returns the underlying TextPosition object
-	 * @return
-	 */
-	protected TextPosition getTextPosition(){
-		return position;
-	}
-	
+public class PositionWrapper
+{
 
-    public boolean isLineStart() {
+    private boolean isLineStart = false;
+    private boolean isParagraphStart = false;
+    private boolean isPageBreak = false;
+    private boolean isHangingIndent = false;
+    private boolean isArticleStart = false;
+
+    private TextPosition position = null;
+
+    /**
+     * Returns the underlying TextPosition object.
+     * @return the text position
+     */
+    protected TextPosition getTextPosition()
+    {
+        return position;
+    }
+
+
+    public boolean isLineStart()
+    {
         return isLineStart;
     }
 
 
     /**
-     * sets the isLineStart() flag to true
+     * Sets the isLineStart() flag to true.
      */
-    public void setLineStart() {
+    public void setLineStart()
+    {
         this.isLineStart = true;
     }
 
 
-    public boolean isParagraphStart() {
+    public boolean isParagraphStart()
+    {
         return isParagraphStart;
     }
 
@@ -70,55 +75,63 @@ public class PositionWrapper{
     /**
      * sets the isParagraphStart() flag to true.
      */
-    public void setParagraphStart() {
+    public void setParagraphStart()
+    {
         this.isParagraphStart = true;
     }
 
 
-	public boolean isArticleStart() {
-		return isArticleStart;
-	}
+    public boolean isArticleStart()
+    {
+        return isArticleStart;
+    }
+
 
+    /**
+     * Sets the isArticleStart() flag to true.
+     */
+    public void setArticleStart()
+    {
+        this.isArticleStart = true;
+    }
 
-	/**
-	 * sets the isArticleStart() flag to true.
-	 */
-	public void setArticleStart() {
-		this.isArticleStart = true;
-	}
 
+    public boolean isPageBreak()
+    {
+        return isPageBreak;
+    }
 
-	public boolean isPageBreak() {
-		return isPageBreak;
-	}
 
-    
     /**
-     * sets the isPageBreak() flag to true
+     * Sets the isPageBreak() flag to true.
      */
-    public void setPageBreak() {
+    public void setPageBreak()
+    {
         this.isPageBreak = true;
     }
 
 
-    public boolean isHangingIndent() {
+    public boolean isHangingIndent()
+    {
         return isHangingIndent;
     }
 
 
     /**
-     * sets the isHangingIndent() flag to true
+     * Sets the isHangingIndent() flag to true.
      */
-    public void setHangingIndent() {
+    public void setHangingIndent()
+    {
         this.isHangingIndent = true;
     }
 
 
     /**
-     * constructs a PositionWrapper around the specified TextPosition object.
-     * @param position
+     * Constructs a PositionWrapper around the specified TextPosition object.
+     * @param position the text position
      */
-    public PositionWrapper(TextPosition position){
+    public PositionWrapper(TextPosition position)
+    {
         this.position = position;
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java Wed Jul 27 08:46:12 2011
@@ -43,7 +43,7 @@ public class TextPosition
     private float pageWidth;
     private float[] widths;
     private float widthOfSpace; // width of a space, in display units
-    private String str; 
+    private String str;
     private PDFont font;
     private float fontSize;
     private int fontSizePt;
@@ -127,7 +127,7 @@ public class TextPosition
      * @param currentFont The current for for this text position.
      * @param fontSizeValue The new font size.
      * @param fontSizeInPt The font size in pt units.
-     * 
+     *
      * @deprecated Use {@link TextPosition(int, float, float, Matrix, float, float, float, float, float, String, PDFont, float, int)} instead.
      */
     public TextPosition(
@@ -145,9 +145,9 @@ public class TextPosition
             int fontSizeInPt
     )
     {
-    	this(pageRotation, pageWidth, pageHeight, textPositionSt,
-    			textPositionEnd.getXPosition(), textPositionEnd.getYPosition(),
-    			maxFontH, individualWidth, spaceWidth, string, currentFont, fontSizeValue, fontSizeInPt);
+        this(pageRotation, pageWidth, pageHeight, textPositionSt,
+                textPositionEnd.getXPosition(), textPositionEnd.getYPosition(),
+                maxFontH, individualWidth, spaceWidth, string, currentFont, fontSizeValue, fontSizeInPt);
     }
 
     /**
@@ -206,7 +206,7 @@ public class TextPosition
         this.fontSize = fontSizeValue;
         this.fontSizePt = fontSizeInPt;
     }
-    
+
     /**
      * Return the string of characters stored in this object.
      *
@@ -219,10 +219,10 @@ public class TextPosition
 
     /**
      * Return the Matrix textPos stored in this object.
-     *  
+     *
      * @return The Matrix containing all infos of the starting textposition
      */
-    public Matrix getTextPos() 
+    public Matrix getTextPos()
     {
         return textPos;
     }
@@ -232,7 +232,7 @@ public class TextPosition
      * based on its text matrix.
      * @return The direction of the text (0, 90, 180, or 270)
      */
-    public float getDir() 
+    public float getDir()
     {
         float a = textPos.getValue(0,0);
         float b = textPos.getValue(0,1);
@@ -240,7 +240,7 @@ public class TextPosition
         float d = textPos.getValue(1,1);
 
         // 12 0   left to right
-        // 0 12 
+        // 0 12
         if ((a > 0) && (Math.abs(b) < d) && (Math.abs(c) < a) && (d > 0))
         {
             return 0;
@@ -252,13 +252,13 @@ public class TextPosition
             return 180;
         }
         // 0  12    up
-        // -12 0 
+        // -12 0
         else if ((Math.abs(a) < Math.abs(c)) && (b > 0) && (c < 0) && (Math.abs(d) < b))
         {
             return 90;
         }
         // 0  -12   down
-        // 12 0 
+        // 12 0
         else if ((Math.abs(a) < c) && (b < 0) && (c > 0) && (Math.abs(d) < Math.abs(b)))
         {
             return 270;
@@ -267,11 +267,11 @@ public class TextPosition
     }
 
     /**
-     * Return the X starting coordinate of the text, adjusted by 
+     * Return the X starting coordinate of the text, adjusted by
      * the given rotation amount.  The rotation adjusts where the 0,0
-     * location is relative to the text. 
-     *  
-     * @param rotation Rotation to apply (0, 90, 180, or 270).  0 will perform no adjustments. 
+     * location is relative to the text.
+     *
+     * @param rotation Rotation to apply (0, 90, 180, or 270).  0 will perform no adjustments.
      * @return X coordinate
      */
     private float getXRot(float rotation)
@@ -297,15 +297,16 @@ public class TextPosition
 
     /**
      * This will get the page rotation adjusted x position of the character.
-     * This is adjusted based on page rotation so that the upper 
-     * left is 0,0. 
+     * This is adjusted based on page rotation so that the upper
+     * left is 0,0.
      *
      * @return The x coordinate of the character.
      */
     public float getX()
     {
-        if(x==Float.NEGATIVE_INFINITY){
-        	x = getXRot(rot);
+        if (x == Float.NEGATIVE_INFINITY)
+        {
+            x = getXRot(rot);
         }
         return x;
     }
@@ -317,16 +318,16 @@ public class TextPosition
      *
      * @return The x coordinate of the text.
      */
-    public float getXDirAdj() 
+    public float getXDirAdj()
     {
-        return getXRot(getDir());  
+        return getXRot(getDir());
     }
 
-    /** 
-     * This will get the y position of the character with 0,0 in lower left. 
-     * This will be adjusted by the given rotation. 
+    /**
+     * This will get the y position of the character with 0,0 in lower left.
+     * This will be adjusted by the given rotation.
      * @param rotation Rotation to apply to text to adjust the 0,0 location (0,90,180,270)
-     * 
+     *
      * @return The y coordinate of the text
      */
     private float getYLowerLeftRot(float rotation)
@@ -351,29 +352,30 @@ public class TextPosition
     }
 
     /**
-     * This will get the y position of the text, adjusted so that 0,0 is upper left and 
-     * it is adjusted based on the page rotation. 
+     * This will get the y position of the text, adjusted so that 0,0 is upper left and
+     * it is adjusted based on the page rotation.
      *
      * @return The adjusted y coordinate of the character.
      */
     public float getY()
     {
-    	if(y==Float.NEGATIVE_INFINITY){
+        if (y == Float.NEGATIVE_INFINITY)
+        {
             if ((rot == 0) || (rot == 180))
             {
                 y = pageHeight - getYLowerLeftRot(rot);
             }
-            else 
+            else
             {
                 y = pageWidth - getYLowerLeftRot(rot);
             }
-    	}
-    	return y;
+        }
+        return y;
     }
 
     /**
-     * This will get the y position of the text, adjusted so that 0,0 is upper left and 
-     * it is adjusted based on the text direction. 
+     * This will get the y position of the text, adjusted so that 0,0 is upper left and
+     * it is adjusted based on the text direction.
      *
      * @return The adjusted y coordinate of the character.
      */
@@ -394,18 +396,18 @@ public class TextPosition
 
 
     /**
-     * Get the length or width of the text, based on a given rotation. 
-     * 
+     * Get the length or width of the text, based on a given rotation.
+     *
      * @param rotation Rotation that was used to determine coordinates (0,90,180,270)
      * @return Width of text in display units
      */
     private float getWidthRot(float rotation)
     {
-        if ((rotation == 90) || (rotation == 270)) 
+        if ((rotation == 90) || (rotation == 270))
         {
             return Math.abs(endY - textPos.getYPosition());
         }
-        else 
+        else
         {
             return Math.abs(endX - textPos.getXPosition());
         }
@@ -416,7 +418,7 @@ public class TextPosition
      *
      * @return The width of the text in display units.
      */
-    public float getWidth() 
+    public float getWidth()
     {
         return getWidthRot(rot);
     }
@@ -426,7 +428,7 @@ public class TextPosition
      *
      * @return The width of the text in display units.
      */
-    public float getWidthDirAdj() 
+    public float getWidthDirAdj()
     {
         return getWidthRot(getDir());
     }
@@ -436,7 +438,7 @@ public class TextPosition
      *
      * @return The maximum height of all characters in this string.
      */
-    public float getHeight() 
+    public float getHeight()
     {
         return maxTextHeight;
     }
@@ -446,7 +448,7 @@ public class TextPosition
      *
      * @return The maximum height of all characters in this string.
      */
-    public float getHeightDir() 
+    public float getHeightDir()
     {
         // this is not really a rotation-dependent calculation, but this is defined for symmetry.
         return maxTextHeight;
@@ -489,7 +491,7 @@ public class TextPosition
      *
      * @return The current word spacing.
      */
-    @Deprecated 
+    @Deprecated
     public float getWordSpacing()
     {
         return wordSpacing;
@@ -560,22 +562,22 @@ public class TextPosition
         double tp2Xend = tp2.getXDirAdj() + tp2.getWidthDirAdj();
 
         /*
-         * No X overlap at all so return as soon as possible. 
+         * No X overlap at all so return as soon as possible.
          */
         if(tp2Xend <= thisXstart || tp2Xstart >= thisXend)
         {
             return false;
-        }   
+        }
         /*
-         * No Y overlap at all so return as soon as possible. 
-         * Note: 0.0 is in the upper left and y-coordinate is 
+         * No Y overlap at all so return as soon as possible.
+         * Note: 0.0 is in the upper left and y-coordinate is
          * top of TextPosition
          */
         if((tp2.getYDirAdj() + tp2.getHeightDir() < getYDirAdj()) ||
                 (tp2.getYDirAdj() > getYDirAdj() + getHeightDir()))
         {
-            return false; 
-        }          
+            return false;
+        }
         /* We're going to calculate the percentage of overlap. If its less
          * than a 15% x-coordinate overlap then we'll return false because its negligible.
          * .15 was determined by trial and error in the regression test files.
@@ -592,7 +594,7 @@ public class TextPosition
             double overlapPercent = overlap/getWidthDirAdj();
             return (overlapPercent > .15);
         }
-        return true; 
+        return true;
     }
 
     /**
@@ -600,14 +602,14 @@ public class TextPosition
      * This is to be used only for cases where we have a diacritic that
      * overlaps an existing TextPosition.  In a graphical display, we could
      * overlay them, but for text extraction we need to merge them. Use the
-     * contains() method to test if two objects overlap. 
-     * 
+     * contains() method to test if two objects overlap.
+     *
      * @param diacritic TextPosition to merge into the current TextPosition.
      * @param normalize Instance of TextNormalize class to be used to normalize diacritic
      */
     public void mergeDiacritic(TextPosition diacritic, TextNormalize normalize)
     {
-        if (diacritic.getCharacter().length() > 1) 
+        if (diacritic.getCharacter().length() > 1)
         {
             return;
         }
@@ -620,23 +622,23 @@ public class TextPosition
         int strLen = str.length();
         boolean wasAdded = false;
 
-        for (int i = 0; i < strLen && !wasAdded; i++) 
+        for (int i = 0; i < strLen && !wasAdded; i++)
         {
             float currCharXEnd = currCharXStart + widths[i];
 
             /*
              * This is the case where there is an overlap of the diacritic character with
              * the current character and the previous character. If no previous character,
-             * just append the diacritic after the current one. 
+             * just append the diacritic after the current one.
              */
             if(diacXStart < currCharXStart && diacXEnd <= currCharXEnd)
-            {               
+            {
                 if(i == 0)
                 {
                     insertDiacritic(i, diacritic, normalize);
                 }
                 else
-                {    
+                {
                     float distanceOverlapping1 = diacXEnd - currCharXStart;
                     float percentage1 = distanceOverlapping1/widths[i];
 
@@ -663,10 +665,10 @@ public class TextPosition
             }
             //Otherwise, The diacritic modifies this character because its completely
             //contained by the character width
-            else if(diacXStart >= currCharXStart && diacXEnd <= currCharXEnd) 
+            else if(diacXStart >= currCharXStart && diacXEnd <= currCharXEnd)
             {
                 insertDiacritic(i, diacritic, normalize);
-                wasAdded = true;   
+                wasAdded = true;
             }
             /*
              * Last character in the TextPosition so we add diacritic to the end
@@ -675,10 +677,10 @@ public class TextPosition
             {
                 insertDiacritic(i, diacritic, normalize);
                 wasAdded = true;
-            }        
+            }
             /*
-             * Couldn't find anything useful so we go to the next character in the 
-             * TextPosition 
+             * Couldn't find anything useful so we go to the next character in the
+             * TextPosition
              */
             currCharXStart += widths[i];
         }
@@ -694,8 +696,8 @@ public class TextPosition
     {
         /* we add the diacritic to the right or left of the character
          * depending on the direction of the character.  Note that this
-         * is only required because the text is currently stored in 
-         * presentation order and not in logical order. 
+         * is only required because the text is currently stored in
+         * presentation order and not in logical order.
          */
         int dir = Character.getDirectionality(str.charAt(i));
         StringBuffer buf = new StringBuffer();
@@ -708,14 +710,14 @@ public class TextPosition
         if ((dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT)
                 || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC)
                 || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING)
-                || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE)) 
+                || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE))
         {
             buf.append(normalize.normalizeDiac(diacritic.getCharacter()));
             widths2[i] = 0;
             buf.append(str.charAt(i));
             widths2[i+1] = widths[i];
-        } 
-        else 
+        }
+        else
         {
             buf.append(str.charAt(i));
             widths2[i] = widths[i];
@@ -732,10 +734,10 @@ public class TextPosition
     }
 
     /**
-     * 
-     * @return True if the current character is a diacritic char. 
+     *
+     * @return True if the current character is a diacritic char.
      */
-    public boolean isDiacritic() 
+    public boolean isDiacritic()
     {
         String cText = this.getCharacter();
         return (cText.length() == 1 &&  (Character.getType(cText.charAt(0)) == Character.NON_SPACING_MARK

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java Wed Jul 27 08:46:12 2011
@@ -44,18 +44,18 @@ public class TestTextToPdf extends TestC
     {
         super( name );
     }
-    
+
     /**
      * This test ensures that a PDF created from an empty String is still readable by Adobe Reader
      */
     public void testCreateEmptyPdf() throws Exception
     {
-    	TextToPDF pdfCreator = new TextToPDF();
-    	StringReader reader = new StringReader("");
-    	PDDocument pdfDoc = pdfCreator.createPDFFromText(reader);
-    	reader.close();
+        TextToPDF pdfCreator = new TextToPDF();
+        StringReader reader = new StringReader("");
+        PDDocument pdfDoc = pdfCreator.createPDFFromText(reader);
+        reader.close();
         pdfDoc.close();
-        
+
         // In order for the PDF document to be openable by Adobe Reader, it needs
         // to have some pages in it. So we'll check that.
         PDDocumentCatalog docCatalog = pdfDoc.getDocumentCatalog();

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestMatrix.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestMatrix.java?rev=1151382&r1=1151381&r2=1151382&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestMatrix.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestMatrix.java Wed Jul 27 08:46:12 2011
@@ -43,115 +43,115 @@ public class TestMatrix extends TestCase
 
     public void testConstructionAndCopy() throws Exception
     {
-    	Matrix m1 = new Matrix();
-    	assertMatrixIsPristine(m1);
-    	
-    	Matrix m2 = m1.copy();
-    	assertNotSame(m1, m2);
-    	assertMatrixIsPristine(m2);
+        Matrix m1 = new Matrix();
+        assertMatrixIsPristine(m1);
+
+        Matrix m2 = m1.copy();
+        assertNotSame(m1, m2);
+        assertMatrixIsPristine(m2);
     }
-    
+
     public void testMultiplication() throws Exception
     {
-    	// This matrix will not change - we use it to drive the various multiplications.
-    	final Matrix testMatrix = new Matrix();
-    	
-    	// Create matrix with values
-    	// [ 0, 1, 2
-    	//   1, 2, 3
-    	//   2, 3, 4]
-    	for (int x = 0; x < 3; x++)
-    	{
-    		for (int y = 0; y < 3; y++)
-    		{
-    			testMatrix.setValue(x, y, x + y);
-    		}
-    	}
-    	
-    	Matrix m1 = testMatrix.copy();
-    	Matrix m2 = testMatrix.copy();
-
-    	// Multiply two matrices together producing a new result matrix.
-    	Matrix product = m1.multiply(m2);
-    	
-    	assertNotSame(m1, product);
-    	assertNotSame(m2, product);
+        // This matrix will not change - we use it to drive the various multiplications.
+        final Matrix testMatrix = new Matrix();
+
+        // Create matrix with values
+        // [ 0, 1, 2
+        //   1, 2, 3
+        //   2, 3, 4]
+        for (int x = 0; x < 3; x++)
+        {
+            for (int y = 0; y < 3; y++)
+            {
+                testMatrix.setValue(x, y, x + y);
+            }
+        }
+
+        Matrix m1 = testMatrix.copy();
+        Matrix m2 = testMatrix.copy();
+
+        // Multiply two matrices together producing a new result matrix.
+        Matrix product = m1.multiply(m2);
 
-    	// Operand 1 should not have changed
-    	assertMatrixValuesEqualTo(new float[] {0,  1,  2,
+        assertNotSame(m1, product);
+        assertNotSame(m2, product);
+
+        // Operand 1 should not have changed
+        assertMatrixValuesEqualTo(new float[] {0,  1,  2,
                                                1,  2,  3,
                                                2,  3,  4}, m1);
-    	// Operand 2 should not have changed
-    	assertMatrixValuesEqualTo(new float[] {0,  1,  2,
+        // Operand 2 should not have changed
+        assertMatrixValuesEqualTo(new float[] {0,  1,  2,
                                                1,  2,  3,
                                                2,  3,  4}, m2);
-    	assertMatrixValuesEqualTo(new float[] {5,  8,  11,
+        assertMatrixValuesEqualTo(new float[] {5,  8,  11,
                                                8,  14, 20,
                                                11, 20, 29}, product);
-    	product.reset();
-    	assertMatrixIsPristine(product);
-    	
-
-    	
-    	// Multiply two matrices together with the result being written to a third matrix
-    	// (Any existing values there will be overwritten).
-    	Matrix resultMatrix = new Matrix();
-    	
-    	Matrix retVal = m1.multiply(m2, resultMatrix);
-    	assertSame(retVal, resultMatrix);
-    	// Operand 1 should not have changed
-    	assertMatrixValuesEqualTo(new float[] {0,  1,  2,
+        product.reset();
+        assertMatrixIsPristine(product);
+
+
+
+        // Multiply two matrices together with the result being written to a third matrix
+        // (Any existing values there will be overwritten).
+        Matrix resultMatrix = new Matrix();
+
+        Matrix retVal = m1.multiply(m2, resultMatrix);
+        assertSame(retVal, resultMatrix);
+        // Operand 1 should not have changed
+        assertMatrixValuesEqualTo(new float[] {0,  1,  2,
                                                1,  2,  3,
                                                2,  3,  4}, m1);
-    	// Operand 2 should not have changed
-    	assertMatrixValuesEqualTo(new float[] {0,  1,  2,
+        // Operand 2 should not have changed
+        assertMatrixValuesEqualTo(new float[] {0,  1,  2,
                                                1,  2,  3,
                                                2,  3,  4}, m2);
-    	assertMatrixValuesEqualTo(new float[] {5,  8,  11,
-			   				                   8,  14, 20,
-			   			                       11, 20, 29}, resultMatrix);
-    	
-
-    	
-    	// Multiply two matrices together with the result being written into the other matrix
-    	retVal = m1.multiply(m2, m2);
-    	assertSame(retVal, m2);
-    	// Operand 1 should not have changed
-    	assertMatrixValuesEqualTo(new float[] {0,  1,  2,
+        assertMatrixValuesEqualTo(new float[] {5,  8,  11,
+                                               8,  14, 20,
+                                               11, 20, 29}, resultMatrix);
+
+
+
+        // Multiply two matrices together with the result being written into the other matrix
+        retVal = m1.multiply(m2, m2);
+        assertSame(retVal, m2);
+        // Operand 1 should not have changed
+        assertMatrixValuesEqualTo(new float[] {0,  1,  2,
                                                1,  2,  3,
                                                2,  3,  4}, m1);
-    	assertMatrixValuesEqualTo(new float[] {5,  8,  11,
-			   				                   8,  14, 20,
-			   			                       11, 20, 29}, retVal);
+        assertMatrixValuesEqualTo(new float[] {5,  8,  11,
+                                               8,  14, 20,
+                                               11, 20, 29}, retVal);
+
 
 
-    	
-    	// Multiply two matrices together with the result being written into 'this' matrix
-    	m1 = testMatrix.copy();
-    	m2 = testMatrix.copy();
-    	
-    	retVal = m1.multiply(m2, m1);
-    	assertSame(retVal, m1);
-    	// Operand 2 should not have changed
-    	assertMatrixValuesEqualTo(new float[] {0,  1,  2,
+        // Multiply two matrices together with the result being written into 'this' matrix
+        m1 = testMatrix.copy();
+        m2 = testMatrix.copy();
+
+        retVal = m1.multiply(m2, m1);
+        assertSame(retVal, m1);
+        // Operand 2 should not have changed
+        assertMatrixValuesEqualTo(new float[] {0,  1,  2,
                                                1,  2,  3,
                                                2,  3,  4}, m2);
-    	assertMatrixValuesEqualTo(new float[] {5,  8,  11,
-			   				                   8,  14, 20,
-			   			                       11, 20, 29}, retVal);
-
-
-    	
-    	// Multiply the same matrix with itself with the result being written into 'this' matrix
-    	m1 = testMatrix.copy();
-
-    	retVal = m1.multiply(m1, m1);
-    	assertSame(retVal, m1);
-    	assertMatrixValuesEqualTo(new float[] {5,  8,  11,
-			   				                   8,  14, 20,
-			   			                       11, 20, 29}, retVal);
+        assertMatrixValuesEqualTo(new float[] {5,  8,  11,
+                                               8,  14, 20,
+                                               11, 20, 29}, retVal);
+
+
+
+        // Multiply the same matrix with itself with the result being written into 'this' matrix
+        m1 = testMatrix.copy();
+
+        retVal = m1.multiply(m1, m1);
+        assertSame(retVal, m1);
+        assertMatrixValuesEqualTo(new float[] {5,  8,  11,
+                                               8,  14, 20,
+                                               11, 20, 29}, retVal);
     }
-    
+
     /**
      * This method asserts that the matrix values for the given {@link Matrix} object are equal
      * to the pristine, or original, values.
@@ -160,8 +160,8 @@ public class TestMatrix extends TestCase
     private void assertMatrixIsPristine(Matrix m)
     {
         assertMatrixValuesEqualTo(new float[] {1 ,0 ,0,
-        		                               0, 1, 0,
-        		                               0, 0, 1}, m);
+                                               0, 1, 0,
+                                               0, 0, 1}, m);
     }
 
     /**
@@ -170,20 +170,21 @@ public class TestMatrix extends TestCase
      * @param values the expected values
      * @param m the matrix to test
      */
-	private void assertMatrixValuesEqualTo(float[] values, Matrix m) {
-		float delta = 0.00001f;
-    	for (int i = 0; i < values.length; i++)
-    	{
-    		// Need to convert a (row, column) co-ordinate into a straight index.
-    		int row = (int)Math.floor(i / 3);
-			int column = i % 3;
-			StringBuilder failureMsg = new StringBuilder();
-			failureMsg.append("Incorrect value for matrix[")
-			          .append(row).append(",").append(column).append("]");
-			assertEquals(failureMsg.toString(), values[i], m.getValue(row, column), delta);
-    	}
-	}
-    
+    private void assertMatrixValuesEqualTo(float[] values, Matrix m)
+    {
+        float delta = 0.00001f;
+        for (int i = 0; i < values.length; i++)
+        {
+            // Need to convert a (row, column) co-ordinate into a straight index.
+            int row = (int)Math.floor(i / 3);
+            int column = i % 3;
+            StringBuilder failureMsg = new StringBuilder();
+            failureMsg.append("Incorrect value for matrix[")
+                    .append(row).append(",").append(column).append("]");
+            assertEquals(failureMsg.toString(), values[i], m.getValue(row, column), delta);
+        }
+    }
+
     /**
      * Set the tests in the suite for this test class.
      *