- java.lang.Object
-
- org.icepdf.ri.common.views.DocumentViewControllerImpl
-
- All Implemented Interfaces:
ComponentListener,PropertyChangeListener,EventListener,DocumentViewController
public class DocumentViewControllerImpl extends Object implements DocumentViewController, ComponentListener, PropertyChangeListener
The DocumentViewControllerImpl is responsible for controlling the four default view models specified by the PDF specification. This class is used associated with the Controller, but all view specific control is passed to this class.
- Since:
- 2.5
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationCallbackannotationCallbackprotected PropertyChangeSupportchangesprotected intcursorTypeprotected Documentdocumentprotected DocumentViewdocumentViewprotected DocumentViewModeldocumentViewModelprotected JScrollPanedocumentViewScrollPanestatic intFULL_SCREEN_VIEWDisplays single page full screen view.protected intoldViewTypestatic intONE_COLUMN_VIEWDisplays all pages in a single column.static intONE_PAGE_VIEWDisplays a one page at a time.static floatROTATION_FACTORRotation factor multiplier when rotating document.protected SecurityCallbacksecurityCallbackprotected SignatureAppearanceCallbacksignatureAppearanceCallbackstatic intTWO_COLUMN_LEFT_VIEWDisplays the pages in two columns, with odd-numbered pages on the left.static intTWO_COLUMN_RIGHT_VIEWDisplays the pages in two columns, with odd-numbered pages on the right.static intTWO_PAGE_LEFT_VIEWDisplays the pages two at a time, with odd-numbered pages on the left.static intTWO_PAGE_RIGHT_VIEWDisplays the pages two at a time, with odd-numbered pages on the right.static intUSE_ATTACHMENTS_VIEWDisplays document using the attachment view, showing thumbnails for each child document.protected SwingControllerviewerControllerprotected intviewportFitModeprotected intviewTypestatic floatZOOM_FACTORZoom factor multiplier 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
Constructors Constructor Description DocumentViewControllerImpl(SwingController viewerController)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNewAnnotation(AnnotationComponent annotationComponent)voidaddNewDestination(Destination destination)voidaddPropertyChangeListener(PropertyChangeListener l)voidassignSelectedAnnotation(AnnotationComponent annotationComponent)voidclearHighlightedText()Clear highlighted text in all pages that make up the current documentvoidclearSelectedAnnotations()voidclearSelectedText()Clear selected text in all pages that make up the current documentvoidcloseDocument()voidcomponentHidden(ComponentEvent e)Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulationvoidcomponentMoved(ComponentEvent e)Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulationvoidcomponentResized(ComponentEvent e)Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulationvoidcomponentShown(ComponentEvent e)Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulationprotected voidcreateDocumentView(int viewType)Creates the specified view type used by the setVieType() call.protected DocumentViewModelcreateDocumentViewMode(Document document)Initialize a DocumentViewModel implementation.voiddeleteAnnotation(AnnotationComponent annotationComponent)voiddeleteAnnotations(Collection<AnnotationComponent> annotations)voiddeleteCurrentAnnotation()voiddeleteDestination(Destination destination)voiddispose()voidfirePropertyChange(String event, int oldValue, int newValue)voidfirePropertyChange(String event, Object oldValue, 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 created, currently only for new link annotationsAnnotationCallbackgetAnnotationCallback()Gets the annotation callback.intgetCurrentPageDisplayValue()intgetCurrentPageIndex()DocumentgetDocument()DocumentViewgetDocumentView()DocumentViewModelgetDocumentViewModel()intgetFitMode()StringgetFlatSelectedText()AdjustablegetHorizontalScrollBar()ControllergetParentController()floatgetRotation()Returns the zoom factor of the page visualization.SecurityCallbackgetSecurityCallback()Gets the security callback.StringgetSelectedText()SignatureAppearanceCallbackgetSignatureAppearanceCallback()Gets the SignatureAppearanceCallback used to generate a signature annotation's appearance streamintgetToolMode()AdjustablegetVerticalScrollBar()ContainergetViewContainer()The controller will own the scrollpane and will insert different views into it.intgetViewCursor()CursorgetViewCursor(int cursorType)intgetViewMode()JViewportgetViewPort()floatgetZoom()The Page being shown may be zoomed in or out, to show more detail, or provide an overview.float[]getZoomLevels()booleanisToolModeSelected(int viewToolMode)voidpropertyChange(PropertyChangeEvent evt)voidredo()voidremovePropertyChangeListener(PropertyChangeListener l)voidrequestViewFocusInWindow()voidrevertViewType()Revert to the previously set view type.voidselectAllText()Sets the selectAll status flag as true.voidsetAnnotationCallback(AnnotationCallback annotationCallback)Set a SignatureAppearanceCallback callback.voidsetComponentTarget(PageViewComponent pageComponent, Component component)booleansetCurrentPageIndex(int pageIndex)intsetCurrentPageNext()intsetCurrentPagePrevious()voidsetDestinationTarget(Destination destination)voidsetDocument(Document newDocument)voidsetDocumentViewType(int documentView, int fitMode)booleansetFitMode(int fitMode)floatsetRotateLeft()floatsetRotateRight()booleansetRotation(float viewRotation)voidsetSecurityCallback(SecurityCallback securityCallback)voidsetSignatureAppearanceCallback(SignatureAppearanceCallback signatureAppearanceCallback)Set a SignatureAppearanceCallback callback.booleansetToolMode(int viewToolMode)voidsetViewCursor(int cursorType)voidsetViewKeyListener(KeyListener l)protected voidsetViewType()Sets the view type, one column, two column, single page etc.voidsetViewType(int documentViewType)View Builder for known doc view typesbooleansetZoom(float viewZoom)Sets the zoom factor of the page visualization.booleansetZoomCentered(float zoom, Point centeringPoint, boolean becauseOfValidFitMode)Zoom to a new zoom level, centered at a specific point.booleansetZoomIn()booleansetZoomIn(Point p)Increases the current page visualization zoom factor by 20%.voidsetZoomLevels(float[] zoomLevels)booleansetZoomOut()booleansetZoomOut(Point p)Decreases the current page visualization zoom factor by 20%.booleansetZoomToViewPort(float zoom, 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.voidundo()voidupdateAnnotation(AnnotationComponent annotationComponent)voidupdateDestination(Destination oldDestination, Destination destination)voidupdatedSummaryAnnotation(AnnotationComponent annotationComponent)
-
-
-
Field Detail
-
ONE_PAGE_VIEW
public static final int ONE_PAGE_VIEW
Displays a one page at a time.- See Also:
- Constant Field Values
-
ONE_COLUMN_VIEW
public static final int ONE_COLUMN_VIEW
Displays all pages in a single 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 odd-numbered pages on the right.- See Also:
- Constant Field Values
-
TWO_COLUMN_RIGHT_VIEW
public static final int TWO_COLUMN_RIGHT_VIEW
Displays the pages in two columns, with odd-numbered pages on the right.- See Also:
- Constant Field Values
-
USE_ATTACHMENTS_VIEW
public static final int USE_ATTACHMENTS_VIEW
Displays document using the attachment view, showing thumbnails for each child document.- See Also:
- Constant Field Values
-
FULL_SCREEN_VIEW
public static final int FULL_SCREEN_VIEW
Displays single page full screen view.- See Also:
- Constant Field Values
-
ZOOM_FACTOR
public static final float ZOOM_FACTOR
Zoom factor multiplier when zooming in or out.- See Also:
- Constant Field Values
-
ROTATION_FACTOR
public static final float ROTATION_FACTOR
Rotation factor multiplier when rotating document.- See Also:
- Constant Field Values
-
zoomLevels
protected float[] zoomLevels
-
document
protected Document document
-
documentViewModel
protected DocumentViewModel documentViewModel
-
documentView
protected DocumentView documentView
-
documentViewScrollPane
protected final JScrollPane documentViewScrollPane
-
viewType
protected int viewType
-
oldViewType
protected int oldViewType
-
viewportFitMode
protected int viewportFitMode
-
cursorType
protected int cursorType
-
viewerController
protected final SwingController viewerController
-
annotationCallback
protected AnnotationCallback annotationCallback
-
signatureAppearanceCallback
protected SignatureAppearanceCallback signatureAppearanceCallback
-
securityCallback
protected SecurityCallback securityCallback
-
changes
protected final PropertyChangeSupport changes
-
-
Constructor Detail
-
DocumentViewControllerImpl
public DocumentViewControllerImpl(SwingController viewerController)
-
-
Method Detail
-
getDocument
public Document getDocument()
- Specified by:
getDocumentin interfaceDocumentViewController
-
setDocument
public void setDocument(Document newDocument)
- Specified by:
setDocumentin interfaceDocumentViewController
-
createDocumentViewMode
protected DocumentViewModel createDocumentViewMode(Document document)
Initialize a DocumentViewModel implementation. Can be over ridden to provide custom DocumentViewModel implementation.- Parameters:
document- document that will be opened- Returns:
- DocumentViewModel for this view.
-
closeDocument
public void closeDocument()
- Specified by:
closeDocumentin interfaceDocumentViewController
-
getHorizontalScrollBar
public Adjustable getHorizontalScrollBar()
- Specified by:
getHorizontalScrollBarin interfaceDocumentViewController
-
getVerticalScrollBar
public Adjustable getVerticalScrollBar()
- Specified by:
getVerticalScrollBarin interfaceDocumentViewController
-
getViewPort
public JViewport getViewPort()
- Specified by:
getViewPortin interfaceDocumentViewController
-
setAnnotationCallback
public void setAnnotationCallback(AnnotationCallback annotationCallback)
Set a SignatureAppearanceCallback callback. Allows setting up a custom signature appearance stream- Specified by:
setAnnotationCallbackin interfaceDocumentViewController- Parameters:
annotationCallback- annotation callback associated with this document view.
-
setSecurityCallback
public void setSecurityCallback(SecurityCallback securityCallback)
- Specified by:
setSecurityCallbackin interfaceDocumentViewController
-
clearSelectedAnnotations
public void clearSelectedAnnotations()
- Specified by:
clearSelectedAnnotationsin interfaceDocumentViewController
-
assignSelectedAnnotation
public void assignSelectedAnnotation(AnnotationComponent annotationComponent)
- Specified by:
assignSelectedAnnotationin interfaceDocumentViewController
-
clearSelectedText
public void clearSelectedText()
Clear selected text in all pages that make up the current document- Specified by:
clearSelectedTextin interfaceDocumentViewController
-
clearHighlightedText
public void clearHighlightedText()
Clear highlighted text in all pages that make up the current document- Specified by:
clearHighlightedTextin interfaceDocumentViewController
-
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:
selectAllTextin interfaceDocumentViewController
-
getFlatSelectedText
public String getFlatSelectedText()
-
getSelectedText
public String getSelectedText()
- Specified by:
getSelectedTextin interfaceDocumentViewController
-
getAnnotationCallback
public AnnotationCallback getAnnotationCallback()
Gets the annotation callback.- Specified by:
getAnnotationCallbackin interfaceDocumentViewController- Returns:
- annotation callback associated with this document.
-
getSignatureAppearanceCallback
public SignatureAppearanceCallback getSignatureAppearanceCallback()
Gets the SignatureAppearanceCallback used to generate a signature annotation's appearance stream- Specified by:
getSignatureAppearanceCallbackin interfaceDocumentViewController- Returns:
- assigned callback
-
setSignatureAppearanceCallback
public void setSignatureAppearanceCallback(SignatureAppearanceCallback signatureAppearanceCallback)
Set a SignatureAppearanceCallback callback. Allows setting up a custom signature appearance stream- Specified by:
setSignatureAppearanceCallbackin interfaceDocumentViewController
-
getSecurityCallback
public SecurityCallback getSecurityCallback()
Gets the security callback.- Specified by:
getSecurityCallbackin interfaceDocumentViewController- Returns:
- security callback associated with this document.
-
getDocumentView
public DocumentView getDocumentView()
- Specified by:
getDocumentViewin interfaceDocumentViewController
-
setViewKeyListener
public void setViewKeyListener(KeyListener l)
- Specified by:
setViewKeyListenerin interfaceDocumentViewController
-
setComponentTarget
public void setComponentTarget(PageViewComponent pageComponent, Component component)
- Specified by:
setComponentTargetin interfaceDocumentViewController
-
setDestinationTarget
public void setDestinationTarget(Destination destination)
- Specified by:
setDestinationTargetin interfaceDocumentViewController
-
dispose
public void dispose()
- Specified by:
disposein interfaceDocumentViewController
-
getViewContainer
public Container getViewContainer()
The controller will own the scrollpane and will insert different views into it.- Specified by:
getViewContainerin interfaceDocumentViewController
-
getParentController
public Controller getParentController()
- Specified by:
getParentControllerin interfaceDocumentViewController
-
getViewMode
public int getViewMode()
- Specified by:
getViewModein interfaceDocumentViewController
-
setViewType
public void setViewType(int documentViewType)
View Builder for known doc view types- Specified by:
setViewTypein interfaceDocumentViewController- Parameters:
documentViewType- view type,
-
revertViewType
public void revertViewType()
Revert to the previously set view type.- Specified by:
revertViewTypein interfaceDocumentViewController
-
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(PropertyChangeEvent evt)
- Specified by:
propertyChangein interfacePropertyChangeListener
-
setFitMode
public boolean setFitMode(int fitMode)
- Specified by:
setFitModein interfaceDocumentViewController
-
getFitMode
public int getFitMode()
- Specified by:
getFitModein interfaceDocumentViewController
-
setDocumentViewType
public void setDocumentViewType(int documentView, int fitMode)- Specified by:
setDocumentViewTypein interfaceDocumentViewController
-
setCurrentPageIndex
public boolean setCurrentPageIndex(int pageIndex)
- Specified by:
setCurrentPageIndexin interfaceDocumentViewController
-
setCurrentPageNext
public int setCurrentPageNext()
- Specified by:
setCurrentPageNextin interfaceDocumentViewController
-
setCurrentPagePrevious
public int setCurrentPagePrevious()
- Specified by:
setCurrentPagePreviousin interfaceDocumentViewController
-
getCurrentPageIndex
public int getCurrentPageIndex()
- Specified by:
getCurrentPageIndexin interfaceDocumentViewController
-
getCurrentPageDisplayValue
public int getCurrentPageDisplayValue()
- Specified by:
getCurrentPageDisplayValuein interfaceDocumentViewController
-
getZoomLevels
public float[] getZoomLevels()
- Specified by:
getZoomLevelsin interfaceDocumentViewController
-
setZoomLevels
public void setZoomLevels(float[] zoomLevels)
- Specified by:
setZoomLevelsin interfaceDocumentViewController
-
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:
setZoomin interfaceDocumentViewController- Parameters:
viewZoom- zoom factor- Returns:
- if zoom actually changed
-
setZoomIn
public boolean setZoomIn()
- Specified by:
setZoomInin interfaceDocumentViewController
-
setZoomOut
public boolean setZoomOut()
- Specified by:
setZoomOutin interfaceDocumentViewController
-
getZoom
public float getZoom()
Description copied from interface:DocumentViewControllerThe Page being shown may be zoomed in or out, to show more detail, or provide an overview.- Specified by:
getZoomin interfaceDocumentViewController- Returns:
- The user's requested zoom
-
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:
getRotationin interfaceDocumentViewController- Returns:
- zoom factor
-
setRotateRight
public float setRotateRight()
- Specified by:
setRotateRightin interfaceDocumentViewController
-
setRotateLeft
public float setRotateLeft()
- Specified by:
setRotateLeftin interfaceDocumentViewController
-
setRotation
public boolean setRotation(float viewRotation)
- Specified by:
setRotationin interfaceDocumentViewController
-
setToolMode
public boolean setToolMode(int viewToolMode)
- Specified by:
setToolModein interfaceDocumentViewController
-
isToolModeSelected
public boolean isToolModeSelected(int viewToolMode)
- Specified by:
isToolModeSelectedin interfaceDocumentViewController
-
getToolMode
public int getToolMode()
- Specified by:
getToolModein interfaceDocumentViewController
-
setViewCursor
public void setViewCursor(int cursorType)
- Specified by:
setViewCursorin interfaceDocumentViewController
-
getViewCursor
public int getViewCursor()
- Specified by:
getViewCursorin interfaceDocumentViewController
-
getViewCursor
public Cursor getViewCursor(int cursorType)
- Specified by:
getViewCursorin interfaceDocumentViewController
-
requestViewFocusInWindow
public void requestViewFocusInWindow()
- Specified by:
requestViewFocusInWindowin interfaceDocumentViewController
-
setZoomIn
public boolean setZoomIn(Point p)
Increases the current page visualization zoom factor by 20%.- Specified by:
setZoomInin interfaceDocumentViewController- Parameters:
p- Recenter the scrollPane here
-
setZoomOut
public boolean setZoomOut(Point p)
Decreases the current page visualization zoom factor by 20%.- Specified by:
setZoomOutin interfaceDocumentViewController- Parameters:
p- Recenter the scrollPane here
-
setZoomCentered
public boolean setZoomCentered(float zoom, Point centeringPoint, boolean becauseOfValidFitMode)Zoom to a new zoom level, centered at a specific point.- Specified by:
setZoomCenteredin interfaceDocumentViewController- Parameters:
zoom- zoom level which should be in the range of zoomLevels arraybecauseOfValidFitMode- 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, 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:
setZoomToViewPortin interfaceDocumentViewController- Parameters:
zoom- zoom level which should be in the range of zoomLevels arraybecauseOfValidFitMode- true will update ui elements with zoom state.zoomPointDelta- point to set viewport position.pageIndex- page to zoom in on.- Returns:
- true if the zoom level changed, false otherwise.
-
getDocumentViewModel
public DocumentViewModel getDocumentViewModel()
- Specified by:
getDocumentViewModelin interfaceDocumentViewController
-
componentHidden
public void componentHidden(ComponentEvent e)
Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation- Specified by:
componentHiddenin interfaceComponentListener
-
componentMoved
public void componentMoved(ComponentEvent e)
Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation- Specified by:
componentMovedin interfaceComponentListener
-
componentResized
public void componentResized(ComponentEvent e)
Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation- Specified by:
componentResizedin interfaceComponentListener
-
componentShown
public void componentShown(ComponentEvent e)
Controller takes AWT/Swing events, and maps them to its own events related to PDF Document manipulation- Specified by:
componentShownin interfaceComponentListener
-
firePropertyChange
public void firePropertyChange(String event, int oldValue, int newValue)
- Specified by:
firePropertyChangein interfaceDocumentViewController
-
firePropertyChange
public void firePropertyChange(String event, Object oldValue, 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 created, currently only for new link annotations
- Specified by:
firePropertyChangein interfaceDocumentViewController- Parameters:
event- property being changesoldValue- old value, null if no old valuenewValue- new annotation value.
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
-
deleteCurrentAnnotation
public void deleteCurrentAnnotation()
- Specified by:
deleteCurrentAnnotationin interfaceDocumentViewController
-
addNewAnnotation
public void addNewAnnotation(AnnotationComponent annotationComponent)
- Specified by:
addNewAnnotationin interfaceDocumentViewController
-
updateAnnotation
public void updateAnnotation(AnnotationComponent annotationComponent)
- Specified by:
updateAnnotationin interfaceDocumentViewController
-
updatedSummaryAnnotation
public void updatedSummaryAnnotation(AnnotationComponent annotationComponent)
- Specified by:
updatedSummaryAnnotationin interfaceDocumentViewController
-
deleteAnnotation
public void deleteAnnotation(AnnotationComponent annotationComponent)
- Specified by:
deleteAnnotationin interfaceDocumentViewController
-
deleteAnnotations
public void deleteAnnotations(Collection<AnnotationComponent> annotations)
- Specified by:
deleteAnnotationsin interfaceDocumentViewController
-
addNewDestination
public void addNewDestination(Destination destination)
- Specified by:
addNewDestinationin interfaceDocumentViewController
-
updateDestination
public void updateDestination(Destination oldDestination, Destination destination)
- Specified by:
updateDestinationin interfaceDocumentViewController
-
deleteDestination
public void deleteDestination(Destination destination)
- Specified by:
deleteDestinationin interfaceDocumentViewController
-
undo
public void undo()
- Specified by:
undoin interfaceDocumentViewController
-
redo
public void redo()
- Specified by:
redoin interfaceDocumentViewController
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
-
-