From commits-return-12147-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Fri Mar 9 18:23:51 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 44FE518064A for ; Fri, 9 Mar 2018 18:23:51 +0100 (CET) Received: (qmail 65273 invoked by uid 500); 9 Mar 2018 17:23:50 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 65264 invoked by uid 99); 9 Mar 2018 17:23:50 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Mar 2018 17:23:50 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 6545D3A019A for ; Fri, 9 Mar 2018 17:23:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1826360 - in /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger: PDFDebugger.java pagepane/PagePane.java Date: Fri, 09 Mar 2018 17:23:48 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180309172349.6545D3A019A@svn01-us-west.apache.org> 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();