pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1830416 - /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
Date Sat, 28 Apr 2018 09:03:32 GMT
Author: tilman
Date: Sat Apr 28 09:03:32 2018
New Revision: 1830416

URL: http://svn.apache.org/viewvc?rev=1830416&view=rev
Log:
PDFBOX-4207: apply default transform to mouse coordinates

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java?rev=1830416&r1=1830415&r2=1830416&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
Sat Apr 28 09:03:32 2018
@@ -77,6 +77,8 @@ public class PagePane implements ActionL
     private ViewMenu viewMenu;
     private String labelText = "";
     private final Map<PDRectangle,String> rectMap = new HashMap<>();
+    private final AffineTransform defaultTransform = GraphicsEnvironment.getLocalGraphicsEnvironment().
+                        getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform();
 
     public PagePane(PDDocument document, COSDictionary pageDict, JLabel statuslabel)
     {
@@ -256,8 +258,8 @@ public class PagePane implements ActionL
         float offsetX = page.getCropBox().getLowerLeftX();
         float offsetY = page.getCropBox().getLowerLeftY();
         float zoomScale = zoomMenu.getPageZoomScale();
-        float x = e.getX() / zoomScale;
-        float y = e.getY() / zoomScale;
+        float x = e.getX() / zoomScale * (float) defaultTransform.getScaleX();
+        float y = e.getY() / zoomScale * (float) defaultTransform.getScaleY();
         int x1, y1;
         switch ((RotationMenu.getRotationDegrees() + page.getRotation()) % 360)
         {
@@ -388,10 +390,8 @@ public class PagePane implements ActionL
                 // a smaller size than the image to compensate that the
                 // image is scaled up with some screen configurations (e.g. 125% on windows).
                 // See PDFBOX-3665 for more sample code and discussion.
-                AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment().
-                        getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform();
-                label.setSize((int) Math.ceil(image.getWidth() / tx.getScaleX()), 
-                              (int) Math.ceil(image.getHeight() / tx.getScaleY()));
+                label.setSize((int) Math.ceil(image.getWidth() / defaultTransform.getScaleX()),

+                              (int) Math.ceil(image.getHeight() / defaultTransform.getScaleY()));
                 label.setIcon(new HighResolutionImageIcon(image, label.getWidth(), label.getHeight()));
                 label.setText(null);
             }



Mime
View raw message