Class PagePanel

    • Constructor Detail

      • PagePanel

        public PagePanel()
        Create a new PagePanel
    • Method Detail

      • setParser

        public void setParser​(PDFParser parser)
        Set the PDFParser object which should be used to render the pages. Setting this to null will end the background thread that renders this object, and free any related resources.
        Parameters:
        parser - the PDFParser
      • setRenderingHints

        public void setRenderingHints​(RenderingHints hints)
        Set the RenderingHints to be used when rendering pages in this PagePanel.
        Parameters:
        hints - the RenderingHints to use - may be null
      • setExtractText

        public void setExtractText​(boolean extract)
        Set whether to extract text while rendering this page to a PageExtractor
        Parameters:
        extract - true to extract the text, false otherwise
      • getPageExtractor

        public PageExtractor getPageExtractor()
        Return the PageExtractor associated with this PagePanel. To render and extract text in a single pass, the setExtractText(boolean) method should be called before rendering, otherwise this method will run the extraction process in a separate pass.
      • setPage

        public void setPage​(PDFPage page,
                            Rectangle2D position,
                            float dpi)
        Redraw the page. The page will be rerendered in the background and when it's complete this component will be resized and repainted. If annotations are being created they will be repositioned and redrawn as well. This method may be called from any thread. Note since 2.11.26, the page must be the same as any page passed into previous calls to this method.
        Parameters:
        page - the page to draw
        position - the area of the page to draw, in points
        dpi - the resolution
      • setPage

        public void setPage​(PDFPage page,
                            Rectangle2D position,
                            float dpi,
                            Rectangle clip)
        Redraw the page. The page will be rerendered in the background and when it's complete this component will be resized and repainted. If annotations are being created they will be repositioned and redrawn as well. This method may be called from any thread. Note since 2.11.26, the page must be the same as any page passed into previous calls to this method.
        Parameters:
        page - the page to draw
        position - the area of the page to draw, in points
        dpi - the resolution
        clip - The graphics clip for this panel, in pixels. The panel will not not render any of the page outside this rectangle.
        Since:
        2.10.4
      • setPage

        public void setPage​(PDFPage page,
                            float x1,
                            float y1,
                            float x2,
                            float y2,
                            float dpi)
        Redraw the page. The page will be rerendered in the background and when it's complete this component will be resized and repainted. If annotations are being created they will be repositioned and redrawn as well. This method may be called from any thread. Note since 2.11.26, the page must be the same as any page passed into previous calls to this method.
        Parameters:
        page - the page to draw
        x1 - the left-most X co-ordinate to draw, in points from the bottom-left
        y1 - the bottom-most Y co-ordinate to draw, in points from the bottom-left
        x2 - the right-most X co-ordinate to draw, in points from the bottom-left
        y2 - the top-most Y co-ordinate to draw, in points from the bottom-left
        dpi - the resolution
      • setPage

        public void setPage​(PDFPage page,
                            float x1,
                            float y1,
                            float x2,
                            float y2,
                            float dpi,
                            Rectangle clip)
        Redraw the page. The page will be rerendered in the background and when it's complete this component will be resized and repainted. If annotations are being created they will be repositioned and redrawn as well. This method may be called from any thread. Note since 2.11.26, the page must be the same as any page passed into previous calls to this method.
        Parameters:
        page - the page to draw
        x1 - the left-most X co-ordinate to draw, in points from the bottom-left
        y1 - the bottom-most Y co-ordinate to draw, in points from the bottom-left
        x2 - the right-most X co-ordinate to draw, in points from the bottom-left
        y2 - the top-most Y co-ordinate to draw, in points from the bottom-left
        dpi - the resolution
        clip - the graphics clip for this panel in pixels. The panel will not render any of the page outside this rectangle.
        Since:
        2.10.4
      • redrawCurrentPage

        public void redrawCurrentPage()
        Force a redraw of the current page
        Since:
        2.11.7
      • getDocumentPanel

        public DocumentPanel getDocumentPanel()
        Get the DocumentPanel this PagePanel is contained inside, or null if this PagePanel was not created as part of a DocumentPanel. A shortcut for getViewport().getDocumentPanel()
      • getPage

        public PDFPage getPage()
        Return the PDFPage currently being displayed by this viewport. Note this method returns the page being displayed, not the page currently being rendered, so it's value will not immediately reflect the page passed in to setPage(), and will be null if the first page has not yet finished rendering.
      • getClip

        public Rectangle2D getClip()
        Return the clip area actually used by the PagePanel. This may be what was requested by the last call to setPage, or it may be null if the PagePanel elected to draw the entire page instead.
        Since:
        2.11.25
      • getView

        public Rectangle2D getView()
        Returns the area of the page currently being displayed, in points with (0,0) at the bottom-left. Like getPage() the return value of this method will not immediately reflect the position passed in to setPage(), and will be null if the first page has not yet finished rendering.
      • getPageToScreenTransform

        public AffineTransform getPageToScreenTransform()
        Return an AffineTransform that will map Page co-ordinates to Screen co-ordinates.
        Since:
        2.10.2
      • getScreenToPageTransform

        public AffineTransform getScreenToPageTransform()
        Return an AffineTransform that will map Page co-ordinates to Screen co-ordinates.
        Since:
        2.10.3
      • getDPI

        public float getDPI()
        Return the resolution of the page currently being displayed. Like getPage() the return value of this method will not immediately reflect the position passed in to setPage(), and will be 0 if the fist page has not yet finished rendering.
      • getPDFPoint

        public Point2D getPDFPoint​(int x,
                                   int y)
        Given a location on this panel in pixels, return the equivalent position on the current page in points.
        See Also:
        getAWTPoint(float, float)
      • getPDFPoint

        public Point2D getPDFPoint​(Point awt)
        Given a location on this panel in pixels, return the equivalent position on the current page in points.
        See Also:
        getAWTPoint(float, float)
      • getAWTPoint

        public Point getAWTPoint​(float x,
                                 float y)
        Given a location on the page in points, return the equivalent position on this PagePanel in pixels.
        See Also:
        getPDFPoint(int, int)
      • getAWTPoint

        public Point getAWTPoint​(Point2D f)
        Given a location on the page in points, return the equivalent position on this PagePanel in pixels.
        See Also:
        getPDFPoint(int, int)
      • setViewport

        public void setViewport​(DocumentViewport viewport)
        Set the viewport this PagePanel belongs to
        Since:
        2.11
      • redrawAnnotation

        public void redrawAnnotation​(PDFAnnotation annot)
        Redraw the specified annotation on this page. This should be called if the annotation is changed, if it's newly added to the page or if it's been removed from the page. May be called from any thread.
        Throws:
        IllegalStateException - if the PagePanel is not part of a DocumentPanel and so has no annotations.