You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ju...@apache.org on 2010/01/15 00:39:44 UTC

svn commit: r899476 - /pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java

Author: jukka
Date: Thu Jan 14 23:39:43 2010
New Revision: 899476

URL: http://svn.apache.org/viewvc?rev=899476&view=rev
Log:
PDFBOX-599: PDFBox performance issue: TextPosition performance tweak

Patch by Mel Martinez.

Modified:
    pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java?rev=899476&r1=899475&r2=899476&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java Thu Jan 14 23:39:43 2010
@@ -37,6 +37,8 @@
 
     private float maxTextHeight; // maximum height of text, in display units
     private int rot; // 0, 90, 180, 270 degrees of page rotation
+    private float x = Float.NEGATIVE_INFINITY;
+    private float y = Float.NEGATIVE_INFINITY;
     private float pageHeight;
     private float pageWidth;
     private float[] widths;
@@ -206,7 +208,10 @@
      */
     public float getX()
     {
-        return getXRot(rot);
+        if(x==Float.NEGATIVE_INFINITY){
+        	x = getXRot(rot);
+        }
+        return x;
     }
 
     /**
@@ -257,14 +262,17 @@
      */
     public float getY()
     {
-        if ((rot == 0) || (rot == 180))
-        {
-            return pageHeight - getYLowerLeftRot(rot);
-        }
-        else 
-        {
-            return pageWidth - getYLowerLeftRot(rot);
-        }
+    	if(y==Float.NEGATIVE_INFINITY){
+            if ((rot == 0) || (rot == 180))
+            {
+                y = pageHeight - getYLowerLeftRot(rot);
+            }
+            else 
+            {
+                y = pageWidth - getYLowerLeftRot(rot);
+            }
+    	}
+    	return y;
     }
 
     /**
@@ -637,4 +645,4 @@
                 || Character.getType(cText.charAt(0)) == Character.MODIFIER_SYMBOL
                 || Character.getType(cText.charAt(0)) == Character.MODIFIER_LETTER));
     }
-}
+}
\ No newline at end of file