pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1644566 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java
Date Thu, 11 Dec 2014 07:21:43 GMT
Author: tilman
Date: Thu Dec 11 07:21:42 2014
New Revision: 1644566

URL: http://svn.apache.org/r1644566
Log:
PDFBOX-2552: normalize the rotation angle for all values

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=1644566&r1=1644565&r2=1644566&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 Thu Dec 11
07:21:42 2014
@@ -126,17 +126,17 @@ public final class TextPosition
         this.endX = endX;
         this.endY = endY;
 
-        int rotation = pageRotation;
-        // make sure it is 0 to 270 and no negative numbers
-        if (rotation < 0)
+        int rotationAngle = pageRotation;
+        // normalize the rotation angle
+        while (rotationAngle < 0)
         {
-            rotation += 360;
+            rotationAngle += 360;
         }
-        else if (rotation >= 360)
+        while (rotationAngle >= 360)
         {
-            rotation -= 360;
+            rotationAngle -= 360;
         }
-        this.rotation = rotation;
+        this.rotation = rotationAngle;
 
         this.maxHeight = maxHeight;
         this.pageHeight = pageHeight;
@@ -150,14 +150,14 @@ public final class TextPosition
         this.fontSize = fontSize;
         this.fontSizePt = fontSizeInPt;
 
-        x = getXRot(rotation);
-        if (rotation == 0 || rotation == 180)
+        x = getXRot(rotationAngle);
+        if (rotationAngle == 0 || rotationAngle == 180)
         {
-            y = this.pageHeight - getYLowerLeftRot(rotation);
+            y = this.pageHeight - getYLowerLeftRot(rotationAngle);
         }
         else
         {
-            y = this.pageWidth - getYLowerLeftRot(rotation);
+            y = this.pageWidth - getYLowerLeftRot(rotationAngle);
         }
     }
 



Mime
View raw message