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 2020/02/01 14:09:45 UTC
svn commit: r1873476 -
/pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
Author: tilman
Date: Sat Feb 1 14:09:45 2020
New Revision: 1873476
URL: http://svn.apache.org/viewvc?rev=1873476&view=rev
Log:
PDFBOX-2941: simplify code, no need to pass so many parameters to a private class constructor
Modified:
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/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=1873476&r1=1873475&r2=1873476&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 Sat Feb 1 14:09:45 2020
@@ -64,8 +64,6 @@ import org.apache.pdfbox.pdmodel.interac
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageDestination;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.interactive.form.PDField;
-import org.apache.pdfbox.rendering.ImageType;
-import org.apache.pdfbox.rendering.RenderDestination;
/**
* Display the page number and a page rendering.
@@ -248,12 +246,7 @@ public class PagePane implements ActionL
{
// 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(),
- ImageTypeMenu.getImageType(),
- RenderDestinationMenu.getRenderDestination()
- ).execute();
+ new RenderWorker().execute();
zoomMenu.setPageZoomScale(ZoomMenu.getZoomScale());
}
@@ -390,33 +383,23 @@ public class PagePane implements ActionL
*/
private final class RenderWorker extends SwingWorker<BufferedImage, Integer>
{
- private final float scale;
- private final int rotation;
- private final boolean allowSubsampling;
- private final ImageType imageType;
- private final RenderDestination renderDestination;
-
- private RenderWorker(float scale, int rotation, boolean allowSubsampling,
- ImageType imageType, RenderDestination renderDestination)
- {
- this.scale = scale;
- this.rotation = rotation;
- this.allowSubsampling = allowSubsampling;
- this.imageType = imageType;
- this.renderDestination = renderDestination;
- }
-
@Override
protected BufferedImage doInBackground() throws IOException
{
+ // rendering can take a long time, so remember all options that are used later
+ float scale = ZoomMenu.getZoomScale();
+ int rotation = RotationMenu.getRotationDegrees();
+
label.setIcon(null);
labelText = "Rendering...";
label.setText(labelText);
+
PDFRenderer renderer = new PDFRenderer(document);
- renderer.setSubsamplingAllowed(allowSubsampling);
+ renderer.setSubsamplingAllowed(PDFDebugger.allowSubsampling.isSelected());
+
long t0 = System.currentTimeMillis();
statuslabel.setText(labelText);
- BufferedImage bim = renderer.renderImage(pageIndex, scale, imageType, renderDestination);
+ BufferedImage bim = renderer.renderImage(pageIndex, scale, ImageTypeMenu.getImageType(), RenderDestinationMenu.getRenderDestination());
float t = (System.currentTimeMillis() - t0) / 1000f;
labelText = "Rendered in " + t + " second" + (t > 1 ? "s" : "");
statuslabel.setText(labelText);