pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1781436 - in /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger: pagepane/PagePane.java streampane/StreamImageView.java ui/HighResolutionImageIcon.java
Date Thu, 02 Feb 2017 17:19:46 GMT
Author: tilman
Date: Thu Feb  2 17:19:46 2017
New Revision: 1781436

URL: http://svn.apache.org/viewvc?rev=1781436&view=rev
Log:
PDFBOX-3665: move HighResolutionImageIcon to own file; replace panel.getGraphicsConfiguration()
with general call; use HighResolutionImageIcon for image XObject display

Added:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/HighResolutionImageIcon.java
  (with props)
Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamImageView.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=1781436&r1=1781435&r2=1781436&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
Thu Feb  2 17:19:46 2017
@@ -35,7 +35,7 @@ import javax.swing.event.AncestorEvent;
 import javax.swing.event.AncestorListener;
 import java.awt.Component;
 import java.awt.Font;
-import java.awt.Graphics;
+import java.awt.GraphicsEnvironment;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseEvent;
@@ -46,7 +46,7 @@ import java.awt.image.BufferedImage;
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
-import javax.swing.Icon;
+import org.apache.pdfbox.debugger.ui.HighResolutionImageIcon;
 
 /**
  * Display the page number and a page rendering.
@@ -314,7 +314,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 = panel.getGraphicsConfiguration().getDefaultTransform();
+                AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment().
+                        getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform();
                 label.setSize((int) Math.ceil(image.getWidth() / tx.getScaleX()), 
                               (int) Math.ceil(image.getHeight() / tx.getScaleY()));
                 label.setIcon(new HighResolutionImageIcon(image, label.getWidth(), label.getHeight()));
@@ -331,37 +332,5 @@ public class PagePane implements ActionL
                 throw new RuntimeException(e);
             }
         }
-
-        private class HighResolutionImageIcon implements Icon
-        {
-            private final BufferedImage image;
-            private final int baseWidth;
-            private final int baseHeight;
-
-            private HighResolutionImageIcon(BufferedImage image, int baseWidth, int baseHeight)
-            {
-                this.image = image;
-                this.baseWidth = baseWidth;
-                this.baseHeight = baseHeight;
-            }
-
-            @Override
-            public void paintIcon(Component c, Graphics g, int x, int y)
-            {
-                g.drawImage(image, x, y, getIconWidth(), getIconHeight(), null);
-            }
-
-            @Override
-            public int getIconWidth()
-            {
-                return baseWidth;
-            }
-
-            @Override
-            public int getIconHeight()
-            {
-                return baseHeight;
-            }            
-        }
     }
 }

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamImageView.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamImageView.java?rev=1781436&r1=1781435&r2=1781436&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamImageView.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamImageView.java
Thu Feb  2 17:19:46 2017
@@ -19,13 +19,15 @@ package org.apache.pdfbox.debugger.strea
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
+
 import javax.swing.Box;
 import javax.swing.BoxLayout;
-import javax.swing.ImageIcon;
 import javax.swing.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -34,6 +36,7 @@ import javax.swing.border.LineBorder;
 import javax.swing.event.AncestorEvent;
 import javax.swing.event.AncestorListener;
 
+import org.apache.pdfbox.debugger.ui.HighResolutionImageIcon;
 import org.apache.pdfbox.debugger.ui.ImageUtil;
 import org.apache.pdfbox.debugger.ui.RotationMenu;
 import org.apache.pdfbox.debugger.ui.ZoomMenu;
@@ -114,7 +117,12 @@ class StreamImageView implements ActionL
 
     private void addImage(Image img)
     {
-        label.setIcon(new ImageIcon(img));
+        // for JDK9; see explanation in PagePane
+        AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment().
+                getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform();
+        label.setSize((int) Math.ceil(img.getWidth(null) / tx.getScaleX()), 
+                      (int) Math.ceil(img.getHeight(null) / tx.getScaleY()));
+        label.setIcon(new HighResolutionImageIcon(img, label.getWidth(), label.getHeight()));
         label.revalidate();
     }
 

Added: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/HighResolutionImageIcon.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/HighResolutionImageIcon.java?rev=1781436&view=auto
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/HighResolutionImageIcon.java
(added)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/HighResolutionImageIcon.java
Thu Feb  2 17:19:46 2017
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.debugger.ui;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Image;
+import javax.swing.Icon;
+
+public class HighResolutionImageIcon implements Icon
+{
+    private final Image image;
+    private final int baseWidth;
+    private final int baseHeight;
+
+    public HighResolutionImageIcon(Image image, int baseWidth, int baseHeight)
+    {
+        this.image = image;
+        this.baseWidth = baseWidth;
+        this.baseHeight = baseHeight;
+    }
+
+    @Override
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+        g.drawImage(image, x, y, getIconWidth(), getIconHeight(), null);
+    }
+
+    @Override
+    public int getIconWidth()
+    {
+        return baseWidth;
+    }
+
+    @Override
+    public int getIconHeight()
+    {
+        return baseHeight;
+    }
+}

Propchange: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/HighResolutionImageIcon.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message