Class PagePanel

All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class PagePanel extends JPanel implements ImageObserver, MouseListener, MouseMotionListener
A Swing-based panel that displays a PDF page image. If the zoom tool is in use, allows the user to select a particular region of the image to be zoomed.
See Also:
  • Constructor Details

    • PagePanel

      public PagePanel()
      Create a new PagePanel, with a default size of 800 by 600 pixels.
  • Method Details

    • showPage

      public void showPage(PDFPage page)
      Stop the generation of any previous page, and draw the new one.
      Parameters:
      page - the PDFPage to draw.
    • flush

      public void flush()
      Deprecated.
    • paint

      public void paint(Graphics g)
      Draw the image.
      Overrides:
      paint in class JComponent
    • getPage

      public PDFPage getPage()
      Gets the page currently being displayed
    • getCurSize

      public Dimension getCurSize()
      Gets the size of the image currently being displayed
    • getCurClip

      public Rectangle2D getCurClip()
      Gets the clipping rectangle in page space currently being displayed
    • waitForCurrentPage

      public void waitForCurrentPage()
      Waits until the page is either complete or had an error.
    • imageUpdate

      public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
      Handles notification of the fact that some part of the image changed. Repaints that portion.
      Specified by:
      imageUpdate in interface ImageObserver
      Overrides:
      imageUpdate in class Component
      Returns:
      true if more updates are desired.
    • useZoomTool

      public void useZoomTool(boolean use)
      Turns the zoom tool on or off. If on, mouse drags will draw the zooming marquee. If off, mouse drags are ignored.
    • setClip

      public void setClip(Rectangle2D clip)
      Set the desired clipping region (in screen coordinates), and redraw the image.
    • mousePressed

      public void mousePressed(MouseEvent evt)
      Handles a mousePressed event
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent evt)
      Handles a mouseReleased event. If zooming is turned on and there's a valid zoom rectangle, set the image clip to the zoom rect.
      Specified by:
      mouseReleased in interface MouseListener
    • mouseClicked

      public void mouseClicked(MouseEvent evt)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent evt)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent evt)
      Specified by:
      mouseExited in interface MouseListener
    • mouseMoved

      public void mouseMoved(MouseEvent evt)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseDragged

      public void mouseDragged(MouseEvent evt)
      Handles a mouseDragged event. Constrains the zoom rect to the aspect ratio of the panel unless the shift key is down.
      Specified by:
      mouseDragged in interface MouseMotionListener