pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1852534 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering: PDFRenderer.java PageDrawer.java
Date Wed, 30 Jan 2019 16:24:14 GMT
Author: tilman
Date: Wed Jan 30 16:24:14 2019
New Revision: 1852534

URL: http://svn.apache.org/viewvc?rev=1852534&view=rev
Log:
PDFBOX-4449: remove uneeded cast; apply Math.abs() to scale values

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java?rev=1852534&r1=1852533&r2=1852534&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
Wed Jan 30 16:24:14 2019
@@ -441,7 +441,7 @@ public class PDFRenderer
                     break;
             }
             graphics.translate(translateX, translateY);
-            graphics.rotate((float) Math.toRadians(rotationAngle));
+            graphics.rotate(Math.toRadians(rotationAngle));
         }
     }
 

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1852534&r1=1852533&r2=1852534&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Wed
Jan 30 16:24:14 2019
@@ -634,9 +634,9 @@ public class PageDrawer extends PDFGraph
     private void adjustRectangle(Rectangle2D r)
     {
         Matrix m = new Matrix(xform);
-        double scaleX = m.getScalingFactorX();
-        double scaleY = m.getScalingFactorY();
-        
+        double scaleX = Math.abs(m.getScalingFactorX());
+        double scaleY = Math.abs(m.getScalingFactorY());
+
         AffineTransform adjustedTransform = new AffineTransform(xform);
         adjustedTransform.scale(1.0 / scaleX, 1.0 / scaleY);
         r.setRect(adjustedTransform.createTransformedShape(r).getBounds2D());
@@ -647,8 +647,8 @@ public class PageDrawer extends PDFGraph
     {
         AffineTransform at = new AffineTransform(xform);
         Matrix m = new Matrix(at);
-        at.scale(1.0 / m.getScalingFactorX(), 1.0 / m.getScalingFactorY());
-        
+        at.scale(1.0 / Math.abs(m.getScalingFactorX()), 1.0 / Math.abs(m.getScalingFactorY()));
+
         Rectangle originalBounds = new Rectangle(gray.getWidth(), gray.getHeight());
         Rectangle2D transformedBounds = at.createTransformedShape(originalBounds).getBounds2D();
         at.preConcatenate(AffineTransform.getTranslateInstance(-transformedBounds.getMinX(),

@@ -1689,7 +1689,7 @@ public class PageDrawer extends PDFGraph
             g.transform(dpiTransform);
 
             AffineTransform xformOriginal = xform;
-            xform = AffineTransform.getScaleInstance(m.getScalingFactorX(), m.getScalingFactorY());
+            xform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY()));
             PDRectangle pageSizeOriginal = pageSize;
             pageSize = new PDRectangle(minX / Math.abs(m.getScalingFactorX()), 
                                        minY / Math.abs(m.getScalingFactorY()),
@@ -1806,8 +1806,8 @@ public class PageDrawer extends PDFGraph
             AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()),
Math.abs(m.getScalingFactorY()));
             size = dpiTransform.transform(size, size);
             // Flip y
-            return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * m.getScalingFactorX(),
-                    size.getY() - minY - height + pageSize.getLowerLeftY() * m.getScalingFactorY(),
+            return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * Math.abs(m.getScalingFactorX()),
+                    size.getY() - minY - height + pageSize.getLowerLeftY() * Math.abs(m.getScalingFactorY()),
                     width, height);
         }
     }



Mime
View raw message