org.icepdf.ri.common.views
Class DocumentViewControllerImpl

java.lang.Object
  extended by org.icepdf.ri.common.views.DocumentViewControllerImpl
All Implemented Interfaces:
java.awt.event.ComponentListener, java.beans.PropertyChangeListener, java.util.EventListener, DocumentViewController

public class DocumentViewControllerImpl
extends java.lang.Object
implements DocumentViewController, java.awt.event.ComponentListener, java.beans.PropertyChangeListener

The DocumentViewControllerImpl is responsible for controlling the four default view models specified by the PDF specification. This class is used associated with the SwingController, but all view specific control is passed to this class.

Since:
2.5

Field Summary
protected  AnnotationCallback annotationCallback
           
protected  java.beans.PropertyChangeSupport changes
           
protected  int cursorType
           
protected  org.icepdf.core.pobjects.Document document
           
protected  AbstractDocumentView documentView
           
protected  DocumentViewModel documentViewModel
           
protected  javax.swing.JScrollPane documentViewScrollPane
           
protected  int oldViewportFitMode
           
protected  int oldViewportHeight
           
protected  int oldViewportWidth
           
protected  int oldViewType
           
static int ONE_COLUMN_VIEW
          Displays a the pages in one column.
static int ONE_PAGE_VIEW
          Displays a one page at a time view.
static float ROTATION_FACTOR
          Rotation factor used with rotating document.
protected  org.icepdf.core.SecurityCallback securityCallback
           
static int TWO_COLUMN_LEFT_VIEW
          Displays the pages in two columns, with odd-numbered pages on the left.
static int TWO_COLUMN_RIGHT_VIEW
          Displays the pages in two columns, with even-numbered pages on the left.
static int TWO_PAGE_LEFT_VIEW
          Displays the pages two at a time, with odd-numbered pages on the left.
static int TWO_PAGE_RIGHT_VIEW
          Displays the pages two at a time, with event-numbered pages on the left.
static int USE_ATTACHMENTS_VIEW
          Displays the pages in two columns, with even-numbered pages on the left.
protected  SwingController viewerController
           
protected  int viewportFitMode
           
protected  int viewportHeight
           
protected  int viewportWidth
           
protected  int viewType
           
static float ZOOM_FACTOR
          Zoom factor used when zooming in or out.
protected  float[] zoomLevels
           
 
Fields inherited from interface org.icepdf.ri.common.views.DocumentViewController
CURSOR_CROSSHAIR, CURSOR_DEFAULT, CURSOR_HAND_ANNOTATION, CURSOR_HAND_CLOSE, CURSOR_HAND_OPEN, CURSOR_MAGNIFY, CURSOR_SELECT, CURSOR_TEXT_SELECTION, CURSOR_WAIT, CURSOR_ZOOM_IN, CURSOR_ZOOM_OUT, PAGE_FIT_ACTUAL_SIZE, PAGE_FIT_NONE, PAGE_FIT_WINDOW_HEIGHT, PAGE_FIT_WINDOW_WIDTH
 
Constructor Summary
DocumentViewControllerImpl(SwingController viewerController)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void assignSelectedAnnotation(AnnotationComponent annotationComponent)
           
 void clearHighlightedText()
          Clear highlighted text in all pages that make up the current document
 void clearSelectedAnnotations()
           
 void clearSelectedText()
          Clear selected text in all pages that make up the current document
 void closeDocument()
           
 void componentHidden(java.awt.event.ComponentEvent e)
          SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation
 void componentMoved(java.awt.event.ComponentEvent e)
          SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation
 void componentResized(java.awt.event.ComponentEvent e)
          SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation
 void componentShown(java.awt.event.ComponentEvent e)
          SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation
protected  void createDocumentView(int viewType)
          Creates the specified view type used by the setVieType() call.
protected  DocumentViewModel createDocumentViewMode(org.icepdf.core.pobjects.Document document, javax.swing.JScrollPane documentViewScrollPane)
          Initialize a DocumentViewModel implementation.
 void deleteAnnotation(AnnotationComponent annotationComponent)
           
 void deleteCurrentAnnotation()
           
 void dispose()
           
 void firePropertyChange(java.lang.String event, int oldValue, int newValue)
           
 void firePropertyChange(java.lang.String event, java.lang.Object oldValue, java.lang.Object newValue)
          Fires property change events for Page view UI changes such as: focus gained/lost annotation state change such as move or resize new annotation crreated, currently only for new link annotations
 AnnotationCallback getAnnotationCallback()
          Gets the annotation callback.
 int getCurrentPageDisplayValue()
           
 int getCurrentPageIndex()
           
 org.icepdf.core.pobjects.Document getDocument()
           
 DocumentView getDocumentView()
           
 DocumentViewModel getDocumentViewModel()
           
 int getFitMode()
           
 java.awt.Adjustable getHorizontalScrollBar()
           
 Controller getParentController()
           
 float getRotation()
          Returns the zoom factor of the page visualization.
 org.icepdf.core.SecurityCallback getSecurityCallback()
          Gets the security callback.
 java.lang.String getSelectedText()
           
 int getToolMode()
           
 java.awt.Adjustable getVerticalScrollBar()
           
 java.awt.Container getViewContainer()
          The controller will own the scrollpane and will insert different views into it.
 int getViewCursor()
           
 java.awt.Cursor getViewCursor(int currsorType)
           
 int getViewMode()
           
 javax.swing.JViewport getViewPort()
           
 float getZoom()
           
 float[] getZoomLevels()
           
 boolean isToolModeSelected(int viewToolMode)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void redo()
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void requestViewFocusInWindow()
           
 void revertViewType()
          Revert to the previously set view type.
 void selectAllText()
          Sets the selectAll status flag as true.
 void setAnnotationCallback(AnnotationCallback annotationCallback)
          Set an annotation callback.
 boolean setCurrentPageIndex(int pageIndex)
           
 int setCurrentPageNext()
           
 int setCurrentPagePrevious()
           
 void setDestinationTarget(org.icepdf.core.pobjects.Destination destination)
           
 void setDocument(org.icepdf.core.pobjects.Document newDocument)
           
 void setDocumentViewType(int documentView, int fitMode)
           
 boolean setFitMode(int fitMode)
           
 float setRotateLeft()
           
 float setRotateRight()
           
 boolean setRotation(float viewRotation)
           
 void setSecurityCallback(org.icepdf.core.SecurityCallback securityCallback)
           
 boolean setToolMode(int viewToolMode)
           
 void setViewCursor(int cursorType)
           
 void setViewKeyListener(java.awt.event.KeyListener l)
           
protected  void setViewType()
          Sets the view type, one column, two column, single page etc.
 void setViewType(int documentViewType)
          View Builder for known doc view types
 boolean setZoom(float viewZoom)
          Sets the zoom factor of the page visualization.
 boolean setZoomCentered(float zoom, java.awt.Point centeringPoint, boolean becauseOfValidFitMode)
          Zoom to a new zoom level, centered at a specific point.
 boolean setZoomIn()
           
 boolean setZoomIn(java.awt.Point p)
          Increases the current page visualization zoom factor by 20%.
 void setZoomLevels(float[] zoomLevels)
           
 boolean setZoomOut()
           
 boolean setZoomOut(java.awt.Point p)
          Decreases the current page visualization zoom factor by 20%.
 boolean setZoomToViewPort(float zoom, java.awt.Point zoomPointDelta, int pageIndex, boolean becauseOfValidFitMode)
          Zoom to a new zoom level, the viewPort position is set by the addition of the zoomPointDelta to the page bounds as defined by the view.
 void undo()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE_PAGE_VIEW

public static final int ONE_PAGE_VIEW
Displays a one page at a time view.

See Also:
Constant Field Values

ONE_COLUMN_VIEW

public static final int ONE_COLUMN_VIEW
Displays a the pages in one column.

See Also:
Constant Field Values

TWO_PAGE_LEFT_VIEW

public static final int TWO_PAGE_LEFT_VIEW
Displays the pages two at a time, with odd-numbered pages on the left.

See Also:
Constant Field Values

TWO_COLUMN_LEFT_VIEW

public static final int TWO_COLUMN_LEFT_VIEW
Displays the pages in two columns, with odd-numbered pages on the left.

See Also:
Constant Field Values

TWO_PAGE_RIGHT_VIEW

public static final int TWO_PAGE_RIGHT_VIEW
Displays the pages two at a time, with event-numbered pages on the left.

See Also:
Constant Field Values

TWO_COLUMN_RIGHT_VIEW

public static final int TWO_COLUMN_RIGHT_VIEW
Displays the pages in two columns, with even-numbered pages on the left.

See Also:
Constant Field Values

USE_ATTACHMENTS_VIEW

public static final int USE_ATTACHMENTS_VIEW
Displays the pages in two columns, with even-numbered pages on the left.

See Also:
Constant Field Values

ZOOM_FACTOR

public static final float ZOOM_FACTOR
Zoom factor used when zooming in or out.

See Also:
Constant Field Values

ROTATION_FACTOR

public static final float ROTATION_FACTOR
Rotation factor used with rotating document.

See Also:
Constant Field Values

zoomLevels

protected float[] zoomLevels

document

protected org.icepdf.core.pobjects.Document document

documentViewModel

protected DocumentViewModel documentViewModel

documentView

protected AbstractDocumentView documentView

documentViewScrollPane

protected javax.swing.JScrollPane documentViewScrollPane

viewportWidth

protected int viewportWidth

oldViewportWidth

protected int oldViewportWidth

viewportHeight

protected int viewportHeight

oldViewportHeight

protected int oldViewportHeight

viewType

protected int viewType

oldViewType

protected int oldViewType

viewportFitMode

protected int viewportFitMode

oldViewportFitMode

protected int oldViewportFitMode

cursorType

protected int cursorType

viewerController

protected SwingController viewerController

annotationCallback

protected AnnotationCallback annotationCallback

securityCallback

protected org.icepdf.core.SecurityCallback securityCallback

changes

protected java.beans.PropertyChangeSupport changes
Constructor Detail

DocumentViewControllerImpl

public DocumentViewControllerImpl(SwingController viewerController)
Method Detail

getDocument

public org.icepdf.core.pobjects.Document getDocument()
Specified by:
getDocument in interface DocumentViewController

setDocument

public void setDocument(org.icepdf.core.pobjects.Document newDocument)
Specified by:
setDocument in interface DocumentViewController

createDocumentViewMode

protected DocumentViewModel createDocumentViewMode(org.icepdf.core.pobjects.Document document,
                                                   javax.swing.JScrollPane documentViewScrollPane)
Initialize a DocumentViewModel implementation. Can be over ridden to provide custom DocumentViewModel implementation.

Parameters:
document - document that will be opened
documentViewScrollPane - parent scrollPane of view.
Returns:
DocumentViewModel for this view.

closeDocument

public void closeDocument()
Specified by:
closeDocument in interface DocumentViewController

getHorizontalScrollBar

public java.awt.Adjustable getHorizontalScrollBar()
Specified by:
getHorizontalScrollBar in interface DocumentViewController

getVerticalScrollBar

public java.awt.Adjustable getVerticalScrollBar()
Specified by:
getVerticalScrollBar in interface DocumentViewController

getViewPort

public javax.swing.JViewport getViewPort()
Specified by:
getViewPort in interface DocumentViewController

setAnnotationCallback

public void setAnnotationCallback(AnnotationCallback annotationCallback)
Set an annotation callback.

Specified by:
setAnnotationCallback in interface DocumentViewController
Parameters:
annotationCallback - annotation callback associated with this document view.

setSecurityCallback

public void setSecurityCallback(org.icepdf.core.SecurityCallback securityCallback)
Specified by:
setSecurityCallback in interface DocumentViewController

clearSelectedAnnotations

public void clearSelectedAnnotations()
Specified by:
clearSelectedAnnotations in interface DocumentViewController

assignSelectedAnnotation

public void assignSelectedAnnotation(AnnotationComponent annotationComponent)
Specified by:
assignSelectedAnnotation in interface DocumentViewController

clearSelectedText

public void clearSelectedText()
Clear selected text in all pages that make up the current document

Specified by:
clearSelectedText in interface DocumentViewController

clearHighlightedText

public void clearHighlightedText()
Clear highlighted text in all pages that make up the current document

Specified by:
clearHighlightedText in interface DocumentViewController

selectAllText

public void selectAllText()
Sets the selectAll status flag as true. Text selection requires that a pages content has been parsed and can be quite expensive for long documents. The page component will pick up on this plag and paint the selected state. If the content is copied to the clipboard we go thought he motion of parsing every page.

Specified by:
selectAllText in interface DocumentViewController

getSelectedText

public java.lang.String getSelectedText()
Specified by:
getSelectedText in interface DocumentViewController

getAnnotationCallback

public AnnotationCallback getAnnotationCallback()
Gets the annotation callback.

Specified by:
getAnnotationCallback in interface DocumentViewController
Returns:
annotation callback associated with this document.

getSecurityCallback

public org.icepdf.core.SecurityCallback getSecurityCallback()
Gets the security callback.

Specified by:
getSecurityCallback in interface DocumentViewController
Returns:
security callback associated with this document.

getDocumentView

public DocumentView getDocumentView()
Specified by:
getDocumentView in interface DocumentViewController

setViewKeyListener

public void setViewKeyListener(java.awt.event.KeyListener l)
Specified by:
setViewKeyListener in interface DocumentViewController

setDestinationTarget

public void setDestinationTarget(org.icepdf.core.pobjects.Destination destination)
Specified by:
setDestinationTarget in interface DocumentViewController

dispose

public void dispose()
Specified by:
dispose in interface DocumentViewController

getViewContainer

public java.awt.Container getViewContainer()
The controller will own the scrollpane and will insert different views into it.

Specified by:
getViewContainer in interface DocumentViewController

getParentController

public Controller getParentController()
Specified by:
getParentController in interface DocumentViewController

getViewMode

public int getViewMode()
Specified by:
getViewMode in interface DocumentViewController

setViewType

public void setViewType(int documentViewType)
View Builder for known doc view types

Specified by:
setViewType in interface DocumentViewController
Parameters:
documentViewType - view type,

revertViewType

public void revertViewType()
Revert to the previously set view type.


setViewType

protected void setViewType()
Sets the view type, one column, two column, single page etc.


createDocumentView

protected void createDocumentView(int viewType)
Creates the specified view type used by the setVieType() call. Can be over ridden to create new or custom views.

Parameters:
viewType - view type constant

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setFitMode

public boolean setFitMode(int fitMode)
Specified by:
setFitMode in interface DocumentViewController

getFitMode

public int getFitMode()
Specified by:
getFitMode in interface DocumentViewController

setDocumentViewType

public void setDocumentViewType(int documentView,
                                int fitMode)
Specified by:
setDocumentViewType in interface DocumentViewController

setCurrentPageIndex

public boolean setCurrentPageIndex(int pageIndex)
Specified by:
setCurrentPageIndex in interface DocumentViewController

setCurrentPageNext

public int setCurrentPageNext()
Specified by:
setCurrentPageNext in interface DocumentViewController

setCurrentPagePrevious

public int setCurrentPagePrevious()
Specified by:
setCurrentPagePrevious in interface DocumentViewController

getCurrentPageIndex

public int getCurrentPageIndex()
Specified by:
getCurrentPageIndex in interface DocumentViewController

getCurrentPageDisplayValue

public int getCurrentPageDisplayValue()
Specified by:
getCurrentPageDisplayValue in interface DocumentViewController

getZoomLevels

public float[] getZoomLevels()
Specified by:
getZoomLevels in interface DocumentViewController

setZoomLevels

public void setZoomLevels(float[] zoomLevels)
Specified by:
setZoomLevels in interface DocumentViewController

setZoom

public boolean setZoom(float viewZoom)
Sets the zoom factor of the page visualization. A zoom factor of 1.0f is equal to 100% or actual size. A zoom factor of 0.5f is equal to 50% of the original size.

Specified by:
setZoom in interface DocumentViewController
Parameters:
viewZoom - zoom factor
Returns:
if zoom actually changed

setZoomIn

public boolean setZoomIn()
Specified by:
setZoomIn in interface DocumentViewController

setZoomOut

public boolean setZoomOut()
Specified by:
setZoomOut in interface DocumentViewController

getZoom

public float getZoom()
Specified by:
getZoom in interface DocumentViewController

getRotation

public float getRotation()
Returns the zoom factor of the page visualization. A zoom factor of 1.0f is equal to 100% or actual size. A zoom factor of 0.5f is equal to 50% of the original size.

Specified by:
getRotation in interface DocumentViewController
Returns:
zoom factor

setRotateRight

public float setRotateRight()
Specified by:
setRotateRight in interface DocumentViewController

setRotateLeft

public float setRotateLeft()
Specified by:
setRotateLeft in interface DocumentViewController

setRotation

public boolean setRotation(float viewRotation)
Specified by:
setRotation in interface DocumentViewController

setToolMode

public boolean setToolMode(int viewToolMode)
Specified by:
setToolMode in interface DocumentViewController

isToolModeSelected

public boolean isToolModeSelected(int viewToolMode)
Specified by:
isToolModeSelected in interface DocumentViewController

getToolMode

public int getToolMode()
Specified by:
getToolMode in interface DocumentViewController

setViewCursor

public void setViewCursor(int cursorType)
Specified by:
setViewCursor in interface DocumentViewController

getViewCursor

public int getViewCursor()
Specified by:
getViewCursor in interface DocumentViewController

getViewCursor

public java.awt.Cursor getViewCursor(int currsorType)
Specified by:
getViewCursor in interface DocumentViewController

requestViewFocusInWindow

public void requestViewFocusInWindow()
Specified by:
requestViewFocusInWindow in interface DocumentViewController

setZoomIn

public boolean setZoomIn(java.awt.Point p)
Increases the current page visualization zoom factor by 20%.

Specified by:
setZoomIn in interface DocumentViewController
Parameters:
p - Recenter the scrollPane here

setZoomOut

public boolean setZoomOut(java.awt.Point p)
Decreases the current page visualization zoom factor by 20%.

Specified by:
setZoomOut in interface DocumentViewController
Parameters:
p - Recenter the scrollPane here

setZoomCentered

public boolean setZoomCentered(float zoom,
                               java.awt.Point centeringPoint,
                               boolean becauseOfValidFitMode)
Zoom to a new zoom level, centered at a specific point.

Specified by:
setZoomCentered in interface DocumentViewController
Parameters:
zoom - zoom level which should be in the range of zoomLevels array
becauseOfValidFitMode - true will update ui elements with zoom state.
centeringPoint - point to center on.
Returns:
true if the zoom level changed, false otherwise.

setZoomToViewPort

public boolean setZoomToViewPort(float zoom,
                                 java.awt.Point zoomPointDelta,
                                 int pageIndex,
                                 boolean becauseOfValidFitMode)
Zoom to a new zoom level, the viewPort position is set by the addition of the zoomPointDelta to the page bounds as defined by the view.

Specified by:
setZoomToViewPort in interface DocumentViewController
Parameters:
zoom - zoom level which should be in the range of zoomLevels array
becauseOfValidFitMode - true will update ui elements with zoom state.
zoomPointDelta - point to center on.
pageIndex - page to zoom in on.
Returns:
true if the zoom level changed, false otherwise.

getDocumentViewModel

public DocumentViewModel getDocumentViewModel()
Specified by:
getDocumentViewModel in interface DocumentViewController

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation

Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation

Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation

Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
SwingController takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation

Specified by:
componentShown in interface java.awt.event.ComponentListener

firePropertyChange

public void firePropertyChange(java.lang.String event,
                               int oldValue,
                               int newValue)
Specified by:
firePropertyChange in interface DocumentViewController

firePropertyChange

public void firePropertyChange(java.lang.String event,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
Fires property change events for Page view UI changes such as:
  • focus gained/lost
  • annotation state change such as move or resize
  • new annotation crreated, currently only for new link annotations
  • Specified by:
    firePropertyChange in interface DocumentViewController
    Parameters:
    event - property being changes
    oldValue - old value, null if no old value
    newValue - new annotation value.

    addPropertyChangeListener

    public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

    deleteCurrentAnnotation

    public void deleteCurrentAnnotation()
    Specified by:
    deleteCurrentAnnotation in interface DocumentViewController

    deleteAnnotation

    public void deleteAnnotation(AnnotationComponent annotationComponent)
    Specified by:
    deleteAnnotation in interface DocumentViewController

    undo

    public void undo()
    Specified by:
    undo in interface DocumentViewController

    redo

    public void redo()
    Specified by:
    redo in interface DocumentViewController

    removePropertyChangeListener

    public void removePropertyChangeListener(java.beans.PropertyChangeListener l)