You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/03/09 17:56:55 UTC
svn commit: r1826366 - in
/pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger:
PDFDebugger.java pagepane/PagePane.java
Author: tilman
Date: Fri Mar 9 17:56:55 2018
New Revision: 1826366
URL: http://svn.apache.org/viewvc?rev=1826366&view=rev
Log:
PDFBOX-4137, PDFBOX-2941: add subsampling option in PDFDebugger; keep PDFDebugger options for every page
Modified:
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
Modified: pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1826366&r1=1826365&r2=1826366&view=diff
==============================================================================
--- pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Fri Mar 9 17:56:55 2018
@@ -49,6 +49,7 @@ import javax.print.attribute.standard.Si
import javax.swing.AbstractAction;
import javax.swing.Action;
+import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -167,6 +168,8 @@ public class PDFDebugger extends JFrame
// view menu
private JMenuItem viewModeItem;
+ public static JCheckBoxMenuItem allowSubsampling;
+
/**
* Constructor.
*/
@@ -503,6 +506,12 @@ public class PDFDebugger extends JFrame
rotationMenu.setEnableMenu(false);
viewMenu.add(rotationMenu.getMenu());
+ viewMenu.addSeparator();
+
+ allowSubsampling = new JCheckBoxMenuItem("Allow subsampling");
+ allowSubsampling.setEnabled(false);
+ viewMenu.add(allowSubsampling);
+
return viewMenu;
}
Modified: pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java?rev=1826366&r1=1826365&r2=1826366&view=diff
==============================================================================
--- pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java (original)
+++ pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java Fri Mar 9 17:56:55 2018
@@ -101,9 +101,7 @@ public class PagePane implements ActionL
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(zoomMenu.getPageZoomScale(), 0).execute();
+ startRendering();
}
/**
@@ -120,13 +118,26 @@ public class PagePane implements ActionL
public void actionPerformed(ActionEvent actionEvent)
{
String actionCommand = actionEvent.getActionCommand();
- if (ZoomMenu.isZoomMenu(actionCommand) || RotationMenu.isRotationMenu(actionCommand))
+ if (ZoomMenu.isZoomMenu(actionCommand) ||
+ RotationMenu.isRotationMenu(actionCommand) ||
+ actionEvent.getSource() == PDFDebugger.allowSubsampling)
{
- new RenderWorker(ZoomMenu.getZoomScale(), RotationMenu.getRotationDegrees()).execute();
+ startRendering();
zoomMenu.setPageZoomScale(ZoomMenu.getZoomScale());
}
}
+ private void startRendering()
+ {
+ // 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(ZoomMenu.getZoomScale(),
+ RotationMenu.getRotationDegrees(),
+ PDFDebugger.allowSubsampling.isSelected()
+ ).execute();
+ zoomMenu.setPageZoomScale(ZoomMenu.getZoomScale());
+ }
+
@Override
public void ancestorAdded(AncestorEvent ancestorEvent)
{
@@ -136,6 +147,9 @@ public class PagePane implements ActionL
rotationMenu = RotationMenu.getInstance();
rotationMenu.addMenuListeners(this);
rotationMenu.setEnableMenu(true);
+
+ PDFDebugger.allowSubsampling.setEnabled(true);
+ PDFDebugger.allowSubsampling.addActionListener(this);
}
@Override
@@ -143,6 +157,9 @@ public class PagePane implements ActionL
{
zoomMenu.setEnableMenu(false);
rotationMenu.setEnableMenu(false);
+
+ PDFDebugger.allowSubsampling.setEnabled(false);
+ PDFDebugger.allowSubsampling.removeActionListener(this);
}
@Override
@@ -227,11 +244,13 @@ public class PagePane implements ActionL
{
private final float scale;
private final int rotation;
+ private final boolean allowSubsampling;
- private RenderWorker(float scale, int rotation)
+ private RenderWorker(float scale, int rotation, boolean allowSubsampling)
{
this.scale = scale;
this.rotation = rotation;
+ this.allowSubsampling = allowSubsampling;
}
@Override
@@ -240,6 +259,7 @@ public class PagePane implements ActionL
label.setIcon(null);
label.setText("Rendering...");
PDFRenderer renderer = new PDFRenderer(document);
+ renderer.setSubsamplingAllowed(allowSubsampling);
long t0 = System.currentTimeMillis();
statuslabel.setText("Rendering...");
BufferedImage bim = renderer.renderImage(pageIndex, scale);