pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1737698 - in /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger: PDFDebugger.java pagepane/PagePane.java streampane/StreamImageView.java ui/ZoomMenu.java
Date Mon, 04 Apr 2016 15:51:17 GMT
Author: tilman
Date: Mon Apr  4 15:51:17 2016
New Revision: 1737698

URL: http://svn.apache.org/viewvc?rev=1737698&view=rev
Log:
PDFBOX-2941: keep zoom scales in a file, by Khyrul Bashar

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
    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
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/ZoomMenu.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1737698&r1=1737697&r2=1737698&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Mon Apr
 4 15:51:17 2016
@@ -1213,6 +1213,7 @@ public class PDFDebugger extends JFrame
         {
             File file = new File(currentFilePath);
             DocumentEntry documentEntry = new DocumentEntry(document, file.getName());
+            ZoomMenu.getInstance().resetZoom();
             tree.setModel(new PDFTreeModel(documentEntry));
             // Root/Pages/Kids/[0] is not always the first page, so use the first row instead:
             tree.setSelectionPath(tree.getPathForRow(1));

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=1737698&r1=1737697&r2=1737698&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
Mon Apr  4 15:51:17 2016
@@ -81,9 +81,11 @@ public class PagePane implements ActionL
         panel.add(label);
         panel.addAncestorListener(this);
 
+        zoomMenu = ZoomMenu.getInstance();
+        zoomMenu.changeZoomSelection(zoomMenu.getPageZoomScale());
         // render in a background thread: rendering is read-only, so this should be ok, despite
         // the fact that PDDocument is not officially thread safe
-        new RenderWorker(1, 0).execute();
+        new RenderWorker(zoomMenu.getPageZoomScale(), 0).execute();
     }
 
     /**
@@ -103,15 +105,14 @@ public class PagePane implements ActionL
         if (ZoomMenu.isZoomMenu(actionCommand) || RotationMenu.isRotationMenu(actionCommand))
         {
             new RenderWorker(ZoomMenu.getZoomScale(), RotationMenu.getRotationDegrees()).execute();
+            zoomMenu.setPageZoomScale(ZoomMenu.getZoomScale());
         }
     }
 
     @Override
     public void ancestorAdded(AncestorEvent ancestorEvent)
     {
-        zoomMenu = ZoomMenu.getInstance();
         zoomMenu.addMenuListeners(this);
-        zoomMenu.setZoomSelection(ZoomMenu.ZOOM_100_PERCENT);
         zoomMenu.setEnableMenu(true);
         
         rotationMenu = RotationMenu.getInstance();

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=1737698&r1=1737697&r2=1737698&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
Mon Apr  4 15:51:17 2016
@@ -66,10 +66,13 @@ class StreamImageView implements ActionL
         JPanel panel = new JPanel();
         panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
 
+        zoomMenu = ZoomMenu.getInstance();
+        zoomMenu.changeZoomSelection(zoomMenu.getImageZoomScale());
+
         label = new JLabel();
         label.setBorder(new LineBorder(Color.BLACK));
         label.setAlignmentX(Component.CENTER_ALIGNMENT);
-        label.setIcon(new ImageIcon(image));
+        addImage(zoomImage(image, zoomMenu.getImageZoomScale(), RotationMenu.getRotationDegrees()));
 
         panel.add(Box.createVerticalGlue());
         panel.add(label);
@@ -105,6 +108,7 @@ class StreamImageView implements ActionL
         if (ZoomMenu.isZoomMenu(actionCommand) || RotationMenu.isRotationMenu(actionCommand))
         {
             addImage(zoomImage(image, ZoomMenu.getZoomScale(), RotationMenu.getRotationDegrees()));
+            zoomMenu.setImageZoomScale(ZoomMenu.getZoomScale());
         }
     }
 
@@ -117,9 +121,7 @@ class StreamImageView implements ActionL
     @Override
     public void ancestorAdded(AncestorEvent ancestorEvent)
     {
-        zoomMenu = ZoomMenu.getInstance();
         zoomMenu.addMenuListeners(this);
-        zoomMenu.setZoomSelection(ZoomMenu.ZOOM_100_PERCENT);
         zoomMenu.setEnableMenu(true);
         
         rotationMenu = RotationMenu.getInstance();

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/ZoomMenu.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/ZoomMenu.java?rev=1737698&r1=1737697&r2=1737698&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/ZoomMenu.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/ZoomMenu.java Mon Apr
 4 15:51:17 2016
@@ -42,7 +42,8 @@ public final class ZoomMenu extends Menu
         }
     }
 
-    public static final String ZOOM_100_PERCENT = "100%";
+    private float pageZoomScale = 1;
+    private float imageZoomScale = 1;
     private static final int[] ZOOMS = new int[] { 25, 50, 100, 200, 400 };
 
     private static ZoomMenu instance;
@@ -81,11 +82,12 @@ public final class ZoomMenu extends Menu
     /**
      * Set the zoom selection.
      *
-     * @param selection zoom menu string, e.g. "100%".
+     * @param zoomValue, e.g. 1, 0.25, 4.
      * @throws IllegalArgumentException if the parameter doesn't belong to a zoom menu item.
      */
-    public void setZoomSelection(String selection)
+    public void changeZoomSelection(float zoomValue)
     {
+        String selection = (int)(zoomValue*100) +"%";
         for (Component comp : menu.getMenuComponents())
         {
             JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) comp;
@@ -132,4 +134,35 @@ public final class ZoomMenu extends Menu
         }
         throw new IllegalStateException("no zoom menu item is selected");
     }
+
+    public float getPageZoomScale()
+    {
+        return pageZoomScale;
+    }
+
+    public void setPageZoomScale(float pageZoomValue)
+    {
+        pageZoomScale = pageZoomValue;
+    }
+
+    public float getImageZoomScale()
+    {
+        return imageZoomScale;
+    }
+
+    public void setImageZoomScale(float imageZoomValue)
+    {
+        imageZoomScale = imageZoomValue;
+    }
+
+    /**
+     * When a new file is loaded zoom values should be reset.
+     *
+     */
+    public void resetZoom()
+    {
+        setPageZoomScale(1);
+        setImageZoomScale(1);
+        changeZoomSelection(1);
+    }
 }



Mime
View raw message