org.faceless.pdf2.viewer2
Class DocumentViewport

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.faceless.pdf2.viewer2.DocumentViewport
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
SinglePageDocumentViewport

public abstract class DocumentViewport
extends JPanel

A DocumentViewport displays a view of a PDF inside a DocumentPanel, although it can also be instantiated on it's own if required. It typically will contain one or more PagePanel objects along with scrollbars and whatever else is required to display the document in limited screen space. See the viewer tutorial for more detail on how to use this class and the "viewer" package.

This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

Since:
2.8
See Also:
PagePanel, DocumentPanel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DocumentViewport()
           
DocumentViewport(LayoutManager manager)
           
 
Method Summary
abstract  void addPagePanelInteractionListener(PagePanelInteractionListener listener)
          Add a PagePanelInteractionListener to any PagePanel objects that have been or will be created by this DocumentViewport
abstract  void addPagePanelListener(PagePanelListener listener)
          Add a PagePanelListener to any PagePanel objects that have been or will be created by this DocumentViewport
abstract  Adjustable getAdjustable(int position)
          Return the "Adjustable" object for the specified position - typically this is the horizontal or vertical JScrollBar, although this method may return null or accept other parameters.
 DocumentPanel getDocumentPanel()
          Return the DocumentPanel this DocumentViewport is a part of
 PDFPage getPage()
          Return the PDFPage in use by getPagePanel()
abstract  PagePanel getPagePanel()
          Get the currently displayed PagePanel.
abstract  PDFPage getRenderingPage()
          Return the page that is currently in the process of rendering.
abstract  Dimension getViewportSize()
          Return the size in pixels of the space available to display pages in this viewport, not including scrollbars or other decoration
abstract  float getZoom()
          Get the current zoom level
abstract  void redraw(Object o)
          Redraw the specified object.
abstract  void removePagePanelInteractionListener(PagePanelInteractionListener listener)
          Remove a PagePanelInteractionListener from any PagePanel objects that have been created by this DocumentViewport
abstract  void removePagePanelListener(PagePanelListener listener)
          Remove a PagePanelListener from any PagePanel objects that have been created by this DocumentViewport
abstract  void setPage(PDFPage page, double x, double y, double zoom)
          Set the currently displayed page.
abstract  void setRenderingHints(RenderingHints hints)
          Set the RenderingHints that should be used when rendering the pages
abstract  void setZoom(float zoom)
          Set the zoom level of this DocumentViewport.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DocumentViewport

public DocumentViewport()

DocumentViewport

public DocumentViewport(LayoutManager manager)
Method Detail

setRenderingHints

public abstract void setRenderingHints(RenderingHints hints)
Set the RenderingHints that should be used when rendering the pages


setPage

public abstract void setPage(PDFPage page,
                             double x,
                             double y,
                             double zoom)
Set the currently displayed page. The exact implementation of this depends on the type of viewport, but the idea is that the specified page and position becomes the primary focus of this viewport.

Parameters:
page - the page to display
x - the left-most X position of the page, relative to PagePanel.getFullPageView(org.faceless.pdf2.PDFPage). A value of NaN means keep the current value
y - the top-most Y position of the page, relative to PagePanel.getFullPageView(org.faceless.pdf2.PDFPage). A value of NaN means keep the current value
zoom - the zoom level. A value of <= 0 or NaN means keep the current zoom.

setZoom

public abstract void setZoom(float zoom)
Set the zoom level of this DocumentViewport. The page and position should remain unchanged if possible.


getZoom

public abstract float getZoom()
Get the current zoom level


getPagePanel

public abstract PagePanel getPagePanel()
Get the currently displayed PagePanel. As for setPage(), the exact implementation of this method depends on the type of viewport, but the idea is it returns the PagePanel that is the primary focus of this viewport


getPage

public PDFPage getPage()
Return the PDFPage in use by getPagePanel()


getRenderingPage

public abstract PDFPage getRenderingPage()
Return the page that is currently in the process of rendering. If the page has rendered this method returns the same as getPage()


getViewportSize

public abstract Dimension getViewportSize()
Return the size in pixels of the space available to display pages in this viewport, not including scrollbars or other decoration


getAdjustable

public abstract Adjustable getAdjustable(int position)
Return the "Adjustable" object for the specified position - typically this is the horizontal or vertical JScrollBar, although this method may return null or accept other parameters.

Parameters:
position - one of Adjustable.HORIZONTAL or Adjustable.VERTICAL
Since:
2.10

getDocumentPanel

public DocumentPanel getDocumentPanel()
Return the DocumentPanel this DocumentViewport is a part of


addPagePanelListener

public abstract void addPagePanelListener(PagePanelListener listener)
Add a PagePanelListener to any PagePanel objects that have been or will be created by this DocumentViewport

Parameters:
listener - the listener

removePagePanelListener

public abstract void removePagePanelListener(PagePanelListener listener)
Remove a PagePanelListener from any PagePanel objects that have been created by this DocumentViewport

Parameters:
listener - the listener

addPagePanelInteractionListener

public abstract void addPagePanelInteractionListener(PagePanelInteractionListener listener)
Add a PagePanelInteractionListener to any PagePanel objects that have been or will be created by this DocumentViewport

Parameters:
listener - the listener

removePagePanelInteractionListener

public abstract void removePagePanelInteractionListener(PagePanelInteractionListener listener)
Remove a PagePanelInteractionListener from any PagePanel objects that have been created by this DocumentViewport

Parameters:
listener - the listener

redraw

public abstract void redraw(Object o)
Redraw the specified object. Typically this will call the PagePanel.redrawAnnotation(org.faceless.pdf2.PDFAnnotation) or PagePanel.setPage(org.faceless.pdf2.PDFPage, java.awt.geom.Rectangle2D, float) method for the PagePanels in use by this Viewport, as appropriate.

Parameters:
o - the Object that is to be redrawn


Copyright © 2001-2008 Big Faceless Organization