You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/06/18 23:16:28 UTC

svn commit: r1603637 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java

Author: jahewson
Date: Wed Jun 18 21:16:28 2014
New Revision: 1603637

URL: http://svn.apache.org/r1603637
Log:
PDFBOX-2145: Clean up TextPosition

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java?rev=1603637&r1=1603636&r2=1603637&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java Wed Jun 18 21:16:28 2014
@@ -36,8 +36,8 @@ public final class TextPosition
 
     private final float maxTextHeight; // maximum height of text, in display units
     private final int rotation; // 0, 90, 180, 270 degrees of page rotation
-    private final float x = Float.NEGATIVE_INFINITY;
-    private final float y = Float.NEGATIVE_INFINITY;
+    private final float x;
+    private final float y;
     private final float pageHeight;
     private final float pageWidth;
 
@@ -103,6 +103,16 @@ public final class TextPosition
         this.font = currentFont;
         this.fontSize = fontSizeValue;
         this.fontSizePt = fontSizeInPt;
+
+        x = getXRot(rotation);
+        if (rotation == 0 || rotation == 180)
+        {
+            y = pageHeight - getYLowerLeftRot(rotation);
+        }
+        else
+        {
+            y = pageWidth - getYLowerLeftRot(rotation);
+        }
     }
 
     /**
@@ -209,10 +219,6 @@ public final class TextPosition
      */
     public float getX()
     {
-        if (x == Float.NEGATIVE_INFINITY)
-        {
-            return getXRot(rotation);
-        }
         return x;
     }
 
@@ -264,17 +270,6 @@ public final class TextPosition
      */
     public float getY()
     {
-        if (y == Float.NEGATIVE_INFINITY)
-        {
-            if (rotation == 0 || rotation == 180)
-            {
-                return pageHeight - getYLowerLeftRot(rotation);
-            }
-            else
-            {
-                return pageWidth - getYLowerLeftRot(rotation);
-            }
-        }
         return y;
     }