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:23:48 UTC
svn commit: r1826360 - in
/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger:
PDFDebugger.java pagepane/PagePane.java
Author: tilman
Date: Fri Mar 9 17:23:48 2018
New Revision: 1826360
URL: http://svn.apache.org/viewvc?rev=1826360&view=rev
Log:
PDFBOX-4137, PDFBOX-2941: add subsampling option in PDFDebugger; keep PDFDebugger options for every page; fix PDFDebugger bug that resulted in rendering being called several times because list of action listeners kept growing
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
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=1826360&r1=1826359&r2=1826360&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 Fri Mar 9 17:23:48 2018
@@ -169,6 +169,7 @@ public class PDFDebugger extends JFrame
public static JCheckBoxMenuItem showTextStripperBeads;
public static JCheckBoxMenuItem showFontBBox;
public static JCheckBoxMenuItem showGlyphBounds;
+ public static JCheckBoxMenuItem allowSubsampling;
// configuration
public static Properties configuration = new Properties();
@@ -644,7 +645,13 @@ public class PDFDebugger extends JFrame
showGlyphBounds = new JCheckBoxMenuItem("Show Glyph Bounds");
showGlyphBounds.setEnabled(false);
viewMenu.add(showGlyphBounds);
-
+
+ viewMenu.addSeparator();
+
+ allowSubsampling = new JCheckBoxMenuItem("Allow subsampling");
+ allowSubsampling.setEnabled(false);
+ viewMenu.add(allowSubsampling);
+
return viewMenu;
}
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=1826360&r1=1826359&r2=1826360&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 Fri Mar 9 17:23:48 2018
@@ -105,7 +105,7 @@ public class PagePane implements ActionL
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, false, false, false, false).execute();
+ startRendering();
}
/**
@@ -127,19 +127,28 @@ public class PagePane implements ActionL
actionEvent.getSource() == PDFDebugger.showTextStripper ||
actionEvent.getSource() == PDFDebugger.showTextStripperBeads ||
actionEvent.getSource() == PDFDebugger.showFontBBox ||
- actionEvent.getSource() == PDFDebugger.showGlyphBounds)
+ actionEvent.getSource() == PDFDebugger.showGlyphBounds ||
+ actionEvent.getSource() == PDFDebugger.allowSubsampling)
{
- new RenderWorker(ZoomMenu.getZoomScale(),
- RotationMenu.getRotationDegrees(),
- PDFDebugger.showTextStripper.isSelected(),
- PDFDebugger.showTextStripperBeads.isSelected(),
- PDFDebugger.showFontBBox.isSelected(),
- PDFDebugger.showGlyphBounds.isSelected()
- ).execute();
- zoomMenu.setPageZoomScale(ZoomMenu.getZoomScale());
+ startRendering();
}
}
+ 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.showTextStripper.isSelected(),
+ PDFDebugger.showTextStripperBeads.isSelected(),
+ PDFDebugger.showFontBBox.isSelected(),
+ PDFDebugger.showGlyphBounds.isSelected(),
+ PDFDebugger.allowSubsampling.isSelected()
+ ).execute();
+ zoomMenu.setPageZoomScale(ZoomMenu.getZoomScale());
+ }
+
@Override
public void ancestorAdded(AncestorEvent ancestorEvent)
{
@@ -162,6 +171,9 @@ public class PagePane implements ActionL
PDFDebugger.showGlyphBounds.setEnabled(true);
PDFDebugger.showGlyphBounds.addActionListener(this);
+
+ PDFDebugger.allowSubsampling.setEnabled(true);
+ PDFDebugger.allowSubsampling.addActionListener(this);
}
@Override
@@ -171,9 +183,15 @@ public class PagePane implements ActionL
rotationMenu.setEnableMenu(false);
PDFDebugger.showTextStripper.setEnabled(false);
+ PDFDebugger.showTextStripper.removeActionListener(this);
PDFDebugger.showTextStripperBeads.setEnabled(false);
+ PDFDebugger.showTextStripperBeads.removeActionListener(this);
PDFDebugger.showFontBBox.setEnabled(false);
+ PDFDebugger.showFontBBox.removeActionListener(this);
PDFDebugger.showGlyphBounds.setEnabled(false);
+ PDFDebugger.showGlyphBounds.removeActionListener(this);
+ PDFDebugger.allowSubsampling.setEnabled(false);
+ PDFDebugger.allowSubsampling.removeActionListener(this);
}
@Override
@@ -262,10 +280,11 @@ public class PagePane implements ActionL
private final boolean showTextStripperBeads;
private final boolean showFontBBox;
private final boolean showGlyphBounds;
-
+ private final boolean allowSubsampling;
+
private RenderWorker(float scale, int rotation, boolean showTextStripper,
boolean showTextStripperBeads, boolean showFontBBox,
- boolean showGlyphBounds)
+ boolean showGlyphBounds, boolean allowSubsampling)
{
this.scale = scale;
this.rotation = rotation;
@@ -273,6 +292,7 @@ public class PagePane implements ActionL
this.showTextStripperBeads = showTextStripperBeads;
this.showFontBBox = showFontBBox;
this.showGlyphBounds = showGlyphBounds;
+ this.allowSubsampling = allowSubsampling;
}
@Override
@@ -283,7 +303,8 @@ public class PagePane implements ActionL
statuslabel.setText("Rendering...");
PDFRenderer renderer = new DebugPDFRenderer(document, this.showGlyphBounds);
-
+ renderer.setSubsamplingAllowed(allowSubsampling);
+
long t0 = System.nanoTime();
BufferedImage image = renderer.renderImage(pageIndex, scale);
long t1 = System.nanoTime();