pdfbox-commits mailing list archives

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

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

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java?rev=1852535&r1=1852534&r2=1852535&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java Wed Jan
30 16:24:20 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/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1852535&r1=1852534&r2=1852535&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Wed Jan
30 16:24:20 2019
@@ -567,9 +567,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());
@@ -580,8 +580,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(),

@@ -1474,7 +1474,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()),
@@ -1592,8 +1592,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