From affc5a1434de487ec79c44cf222e4bc2605460a3 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 18:55:54 +0000 Subject: don't use clip bounds to determine redraw area git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@45 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/composites/PDFViewerComposite.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'pdf-over-gui/src/main') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PDFViewerComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PDFViewerComposite.java index 7792fa3f..f2852fcc 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PDFViewerComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PDFViewerComposite.java @@ -34,11 +34,20 @@ import org.icepdf.core.exceptions.PDFSecurityException; import org.icepdf.core.pobjects.Document; import org.icepdf.core.pobjects.Page; import org.icepdf.core.util.GraphicsRenderingHints; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.workflow.states.PositioningState; /** * Displays a PDF document */ public class PDFViewerComposite extends Composite { + /** + * SFL4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(PDFViewerComposite.class); /** * PDF document @@ -125,16 +134,17 @@ public class PDFViewerComposite extends Composite { return; int page = getPage(); // Make page always fit to window - Rectangle2D clip = g.getClip().getBounds2D(); - double h_zoom = clip.getWidth() / PDFViewerComposite.this.base_dimensions[page].width; - double v_zoom = clip.getHeight() / PDFViewerComposite.this.base_dimensions[page].height; + Dimension d = getSize(); + double h_zoom = d.getWidth() / PDFViewerComposite.this.base_dimensions[page].width; + double v_zoom = d.getHeight() / PDFViewerComposite.this.base_dimensions[page].height; float zoom = (float) (h_zoom < v_zoom ? h_zoom : v_zoom); if (v_zoom < h_zoom) { // Page is narrower than window, center it - g.translate((int) ((clip.getWidth() - (PDFViewerComposite.this.base_dimensions[page].width * zoom)) / 2), 0); + g.translate((int) ((d.width - (PDFViewerComposite.this.base_dimensions[page].width * zoom)) / 2), 0); } + log.debug("Repainting " + g.getClipBounds().width + "x" + g.getClipBounds().height + " - " + d.width + "x" + d.height); PDFViewerComposite.this.document.paintPage(page, g, GraphicsRenderingHints.SCREEN, Page.BOUNDARY_CROPBOX, 0f, zoom); } }; -- cgit v1.2.3