org.icepdf.ri.common.views
Class PageViewComponentImpl

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLayeredPane
                  extended by org.icepdf.ri.common.views.AbstractPageViewComponent
                      extended by org.icepdf.ri.common.views.PageViewComponentImpl
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, org.icepdf.core.events.PaintPageListener, PageViewComponent

public class PageViewComponentImpl
extends AbstractPageViewComponent
implements org.icepdf.core.events.PaintPageListener, java.awt.event.FocusListener, java.awt.event.ComponentListener

This class represents a single page view of a PDF document as a JComponent. This component can be used in any swing application to display a PDF page. The default RI implementation comes with four predefined page views which use this component. If custom page views are need then the following class should be referenced:

This component assumes that white paper is the default and thus uses white as the default background color for buffers and page painting if no color is specified by the PDF. This default colour can be changed using the system property org.icepdf.core.views.page.paper.color. This property takes RRGGBB hex colours as values. eg. black=000000 or white=FFFFFFF.

Since:
2.5
See Also:
OneColumnPageView, OnePageView, TwoColumnPageView, TwoPageView, AbstractDocumentView, AbstractDocumentViewModel,

The page view takes advantage of a buffered display to speed up page scrolling and provide users with a better overall UI experiance. The size of the buffer can also be set with the system properties "org.icepdf.core.views.buffersize.vertical" and "org.icepdf.core.views.buffersize.horizontal". These system properties define the vertical and horizontal ratios in which the current viewport will be extended to define the buffer size.

, Serialized Form

Nested Class Summary
 class PageViewComponentImpl.PagePainter
           
 
Nested classes/interfaces inherited from class javax.swing.JLayeredPane
javax.swing.JLayeredPane.AccessibleJLayeredPane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.icepdf.ri.common.views.AbstractPageViewComponent
annotationComponents, currentToolHandler, documentViewController, documentViewModel, parentDocumentView, textSelectionPageHandler
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
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
PageViewComponentImpl(DocumentViewModel documentViewModel, org.icepdf.core.pobjects.PageTree pageTree, int pageNumber, javax.swing.JScrollPane parentScrollPane)
           
PageViewComponentImpl(DocumentViewModel documentViewModel, org.icepdf.core.pobjects.PageTree pageTree, int pageNumber, javax.swing.JScrollPane parentScrollPane, int width, int height)
           
 
Method Summary
 void addAnnotation(AnnotationComponent annotation)
          Adds the specified annotation to this page instance.
 void clearSelectedText()
          Clear any internal data structures that represent selected text and repaint the component.
 void clearSelectionRectangle()
           
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 void dispose()
          Called to free resources used by this component.
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 org.icepdf.core.pobjects.Page getPage()
           
 int getPageIndex()
          Gets the page index which this PageViewComponent is drawing.
 java.awt.Dimension getPreferredSize()
           
 void init()
          Called to initialize resources used by this class.
 void invalidate()
          Called to invalidate the component.
 void invalidatePage()
          Should only be called by the demo application as it triggers the current page state to be marked as uninitialized and will trigger a full parse of the page if accessed again.
 void invalidatePageBuffer()
          Invalidates the page buffer used for bufferer paints forcing a clean repaint of the pge.
 void paintComponent(java.awt.Graphics gg)
           
 void paintPage(org.icepdf.core.events.PaintPageEvent event)
           
 void removeAnnotation(AnnotationComponent annotationComp)
          Removes the specified annotation from this page component
 void setDocumentViewCallback(DocumentView parentDocumentView)
          Set the parent Document View class which is resbonsible for drawing and the general management of PageViewComponents for a particular view.
 void setSelectionRectangle(java.awt.Point cursorLocation, java.awt.Rectangle selection)
          Sets the text that is contained in the specified recttangle and the given mouse pointer.
 void validate()
           
 
Methods inherited from class org.icepdf.ri.common.views.AbstractPageViewComponent
getAnnotationComponents, getCurrentToolHandler, getTextSelectionPageHandler, isAnnotationTool, refreshAnnotationComponents, setToolMode
 
Methods inherited from class javax.swing.JLayeredPane
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, paramString, putLayer, remove, removeAll, setLayer, setLayer, setPosition
 
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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, 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, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, 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
 
Methods inherited from interface org.icepdf.ri.common.views.PageViewComponent
isShowing
 

Constructor Detail

PageViewComponentImpl

public PageViewComponentImpl(DocumentViewModel documentViewModel,
                             org.icepdf.core.pobjects.PageTree pageTree,
                             int pageNumber,
                             javax.swing.JScrollPane parentScrollPane)

PageViewComponentImpl

public PageViewComponentImpl(DocumentViewModel documentViewModel,
                             org.icepdf.core.pobjects.PageTree pageTree,
                             int pageNumber,
                             javax.swing.JScrollPane parentScrollPane,
                             int width,
                             int height)
Method Detail

addAnnotation

public void addAnnotation(AnnotationComponent annotation)
Adds the specified annotation to this page instance. The annotation is wrapped with a AnnotationComponent and added to this components layout manager.

Specified by:
addAnnotation in interface PageViewComponent
Parameters:
annotation - annotation to add to this page instance. .

removeAnnotation

public void removeAnnotation(AnnotationComponent annotationComp)
Removes the specified annotation from this page component

Specified by:
removeAnnotation in interface PageViewComponent
Parameters:
annotationComp - annotation to be removed.

init

public void init()
Description copied from interface: PageViewComponent
Called to initialize resources used by this class.

Specified by:
init in interface PageViewComponent

invalidatePage

public void invalidatePage()
Should only be called by the demo application as it triggers the current page state to be marked as uninitialized and will trigger a full parse of the page if accessed again.

Specified by:
invalidatePage in interface PageViewComponent

invalidatePageBuffer

public void invalidatePageBuffer()
Description copied from interface: PageViewComponent
Invalidates the page buffer used for bufferer paints forcing a clean repaint of the pge. .

Specified by:
invalidatePageBuffer in interface PageViewComponent

dispose

public void dispose()
Description copied from interface: PageViewComponent
Called to free resources used by this component.

Specified by:
dispose in interface PageViewComponent

getPage

public org.icepdf.core.pobjects.Page getPage()
Specified by:
getPage in class AbstractPageViewComponent

setDocumentViewCallback

public void setDocumentViewCallback(DocumentView parentDocumentView)
Description copied from interface: PageViewComponent
Set the parent Document View class which is resbonsible for drawing and the general management of PageViewComponents for a particular view.

Specified by:
setDocumentViewCallback in interface PageViewComponent
Parameters:
parentDocumentView - type of view, single page, continuous, etc.

getPageIndex

public int getPageIndex()
Description copied from interface: PageViewComponent
Gets the page index which this PageViewComponent is drawing.

Specified by:
getPageIndex in interface PageViewComponent
Returns:
zero pages page index of the page drawn by this component.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

validate

public void validate()
Overrides:
validate in class java.awt.Container

invalidate

public void invalidate()
Description copied from interface: PageViewComponent
Called to invalidate the component.

Specified by:
invalidate in interface PageViewComponent
Overrides:
invalidate in class java.awt.Container

paintComponent

public void paintComponent(java.awt.Graphics gg)
Overrides:
paintComponent in class javax.swing.JComponent

clearSelectedText

public void clearSelectedText()
Description copied from interface: PageViewComponent
Clear any internal data structures that represent selected text and repaint the component.

Specified by:
clearSelectedText in interface PageViewComponent

setSelectionRectangle

public void setSelectionRectangle(java.awt.Point cursorLocation,
                                  java.awt.Rectangle selection)
Description copied from interface: PageViewComponent
Sets the text that is contained in the specified recttangle and the given mouse pointer. The cursor and selection rectangel must be in in page space.

Specified by:
setSelectionRectangle in interface PageViewComponent
Parameters:
cursorLocation - location of cursor or mouse.
selection - rectangle of text to include in selection.

clearSelectionRectangle

public void clearSelectionRectangle()
Specified by:
clearSelectionRectangle in interface PageViewComponent

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

paintPage

public void paintPage(org.icepdf.core.events.PaintPageEvent event)
Specified by:
paintPage in interface org.icepdf.core.events.PaintPageListener