Class ThumbPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Runnable, Accessible, Scrollable

public class ThumbPanel extends JPanel implements Runnable, Scrollable, ImageObserver
A panel of thumbnails, one for each page of a PDFFile. You can add a PageChangeListener to be informed of when the user clicks one of the pages.
See Also:
  • Constructor Details

    • ThumbPanel

      public ThumbPanel(PDFFile file)
      Creates a new ThumbPanel based on a PDFFile. The file may be null. Automatically starts rendering thumbnails for that file.
      Parameters:
      file - a PDFFile object.
  • Method Details

    • run

      public void run()

      Renders each of the pages in the PDFFile into a thumbnail. Preferentially works on the needdrawn thumbnail, otherwise, go in order.

      Specified by:
      run in interface Runnable
    • addPageChangeListener

      public void addPageChangeListener(PageChangeListener pl)
      Adds a PageChangeListener to receive notification of page clicks.
      Parameters:
      pl - a PageChangeListener object.
    • removePageChangeListener

      public void removePageChangeListener()
      Removes a PageChangeListener from the notification list.
    • stop

      public void stop()
      Stops the render thread. Be sure to call this before dropping a ThumbPanel.
    • handleClick

      public void handleClick(int x, int y)
      Handles a mouse click in the panel. Figures out which page was clicked, and calls showPage.
      Parameters:
      x - the x coordinate of the mouse click
      y - the y coordinate of the mouse click
    • pageShown

      public void pageShown(int pagenum)
      Sets the currently viewed page, indicates it with a highlight border, and makes sure the thumbnail is visible.
      Parameters:
      pagenum - a Integer object.
    • showPage

      public void showPage(int pagenum)
      Notifies the listeners that a page has been selected. Performs the notification in the AWT thread. Also highlights the selected page. Does this first so that feedback is immediate.
      Parameters:
      pagenum - a Integer object.
    • paint

      public void paint(Graphics g)

      Updates the positions of the thumbnails, and draws them to the screen.

      Overrides:
      paint in class JComponent
    • imageUpdate

      public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)

      Handles notification of any image updates. Not used any more.

      Specified by:
      imageUpdate in interface ImageObserver
      Overrides:
      imageUpdate in class Component
    • getPreferredScrollableViewportSize

      public Dimension getPreferredScrollableViewportSize()
      Specified by:
      getPreferredScrollableViewportSize in interface Scrollable
    • getScrollableBlockIncrement

      public int getScrollableBlockIncrement(Rectangle visrect, int orientation, int direction)
      Specified by:
      getScrollableBlockIncrement in interface Scrollable
    • getScrollableTracksViewportHeight

      public boolean getScrollableTracksViewportHeight()
      Specified by:
      getScrollableTracksViewportHeight in interface Scrollable
    • getScrollableTracksViewportWidth

      public boolean getScrollableTracksViewportWidth()
      Specified by:
      getScrollableTracksViewportWidth in interface Scrollable
    • getScrollableUnitIncrement

      public int getScrollableUnitIncrement(Rectangle visrect, int orientation, int direction)
      Specified by:
      getScrollableUnitIncrement in interface Scrollable