org.icepdf.ri.common.views
Class AbstractDocumentViewModel

java.lang.Object
  extended by org.icepdf.ri.common.views.AbstractDocumentViewModel
All Implemented Interfaces:
org.icepdf.core.views.DocumentViewModel
Direct Known Subclasses:
DocumentViewModelImpl

public abstract class AbstractDocumentViewModel
extends java.lang.Object
implements org.icepdf.core.views.DocumentViewModel

The AbstractDocumentViewModel is responsible for keeping the state of the documetn view. The AbstractDocumentViewModel also stores an list of PageViewComponetnts who's state is update as the model changes. The AbstractDocumentViewModel can be swapped into different page views quickly and efficently.

Since:
2.5
See Also:
DocumentViewModelImpl

Field Summary
protected  org.icepdf.core.views.swing.AnnotationComponentImpl currentAnnotation
           
protected  org.icepdf.core.pobjects.Document currentDocument
           
protected  int currentPageIndex
           
protected static int MAX_PAGE_SIZE_READ_AHEAD
           
protected static int maxPageInitThreads
           
protected static int maxPainterThreads
           
protected  int oldPageIndex
           
protected  float oldUserRotation
           
protected  int oldUserToolModeFlag
           
protected  float oldUserZoom
           
protected  int pageBoundary
           
protected  java.util.List<org.icepdf.core.views.swing.AbstractPageViewComponent> pageComponents
           
protected  java.util.concurrent.ThreadPoolExecutor pageInitilizationThreadPool
           
protected  java.util.concurrent.ThreadPoolExecutor pagePainterThreadPool
           
protected  UndoCaretaker undoCaretaker
           
protected  float userRotation
           
protected  int userToolModeFlag
           
protected  float userZoom
           
 
Fields inherited from interface org.icepdf.core.views.DocumentViewModel
DISPLAY_TOOL_LINK_ANNOTATION, DISPLAY_TOOL_NONE, DISPLAY_TOOL_PAN, DISPLAY_TOOL_SELECTION, DISPLAY_TOOL_TEXT_SELECTION, DISPLAY_TOOL_WAIT, DISPLAY_TOOL_ZOOM_IN, DISPLAY_TOOL_ZOOM_OUT
 
Constructor Summary
AbstractDocumentViewModel(org.icepdf.core.pobjects.Document currentDocument)
           
 
Method Summary
 void addMemento(org.icepdf.core.Memento oldMementoState, org.icepdf.core.Memento newMementoState)
           
 void addSelectedPageText(org.icepdf.core.views.swing.AbstractPageViewComponent pageViewComponent)
          Adds the specified page to selected page cache.
 void clearSelectedPageText()
          Clears cache used to store which pages have selected state.
 void dispose()
           
 void executePageInitialization(java.lang.Runnable runnable)
           
 void executePagePainter(java.lang.Runnable runnable)
           
 UndoCaretaker getAnnotationCareTaker()
          Gets annotation caretaker responsible for saving states as defined by the momento pattern.
 org.icepdf.core.views.swing.AnnotationComponentImpl getCurrentAnnotation()
          Gets the currently selected annotation in the document model.
 org.icepdf.core.pobjects.Document getDocument()
           
 int getPageBoundary()
           
 java.awt.Rectangle getPageBounds(int pageIndex)
           
 java.util.List<org.icepdf.core.views.swing.AbstractPageViewComponent> getPageComponents()
           
 java.util.ArrayList<java.lang.ref.WeakReference<org.icepdf.core.views.swing.AbstractPageViewComponent>> getSelectedPageText()
          Gets the list of components that have a selected state.
 int getViewCurrentPageIndex()
           
 float getViewRotation()
          Returns the zoom factor of the page visualization.
 int getViewToolMode()
           
 float getViewZoom()
           
 void invalidate()
          Invalidate the underlying Document Page models.
 boolean isSelectAll()
          Gets the selected all state of the doucment pages view.
 boolean isViewToolModeSelected(int viewToolMode)
           
 void setCurrentAnnotation(org.icepdf.core.views.swing.AnnotationComponentImpl currentAnnotation)
          Sets the current annotation.
 void setPageBoundary(int pageBoundary)
          Sets the page boundtry used to paint a page.
 void setSelectAll(boolean selectAll)
          Sets the select all state of the text in the document.
 boolean setViewCurrentPageIndex(int pageIndex)
           
 boolean setViewRotation(float viewRotation)
           
 boolean setViewToolMode(int viewToolMode)
           
 boolean setViewZoom(float viewZoom)
          Sets the zoom factor of the page visualization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentDocument

protected org.icepdf.core.pobjects.Document currentDocument

pageComponents

protected java.util.List<org.icepdf.core.views.swing.AbstractPageViewComponent> pageComponents

undoCaretaker

protected UndoCaretaker undoCaretaker

currentAnnotation

protected org.icepdf.core.views.swing.AnnotationComponentImpl currentAnnotation

userZoom

protected float userZoom

oldUserZoom

protected float oldUserZoom

userRotation

protected float userRotation

oldUserRotation

protected float oldUserRotation

currentPageIndex

protected int currentPageIndex

oldPageIndex

protected int oldPageIndex

pageBoundary

protected int pageBoundary

userToolModeFlag

protected int userToolModeFlag

oldUserToolModeFlag

protected int oldUserToolModeFlag

pageInitilizationThreadPool

protected java.util.concurrent.ThreadPoolExecutor pageInitilizationThreadPool

pagePainterThreadPool

protected java.util.concurrent.ThreadPoolExecutor pagePainterThreadPool

MAX_PAGE_SIZE_READ_AHEAD

protected static final int MAX_PAGE_SIZE_READ_AHEAD
See Also:
Constant Field Values

maxPainterThreads

protected static int maxPainterThreads

maxPageInitThreads

protected static int maxPageInitThreads
Constructor Detail

AbstractDocumentViewModel

public AbstractDocumentViewModel(org.icepdf.core.pobjects.Document currentDocument)
Method Detail

getDocument

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

executePageInitialization

public void executePageInitialization(java.lang.Runnable runnable)
                               throws java.lang.InterruptedException
Specified by:
executePageInitialization in interface org.icepdf.core.views.DocumentViewModel
Throws:
java.lang.InterruptedException

executePagePainter

public void executePagePainter(java.lang.Runnable runnable)
                        throws java.lang.InterruptedException
Specified by:
executePagePainter in interface org.icepdf.core.views.DocumentViewModel
Throws:
java.lang.InterruptedException

getPageComponents

public java.util.List<org.icepdf.core.views.swing.AbstractPageViewComponent> getPageComponents()
Specified by:
getPageComponents in interface org.icepdf.core.views.DocumentViewModel

setViewCurrentPageIndex

public boolean setViewCurrentPageIndex(int pageIndex)
Specified by:
setViewCurrentPageIndex in interface org.icepdf.core.views.DocumentViewModel

getViewCurrentPageIndex

public int getViewCurrentPageIndex()
Specified by:
getViewCurrentPageIndex in interface org.icepdf.core.views.DocumentViewModel

getSelectedPageText

public java.util.ArrayList<java.lang.ref.WeakReference<org.icepdf.core.views.swing.AbstractPageViewComponent>> getSelectedPageText()
Gets the list of components that have a selected state. The WeakReference must be checkt o make sure the page was not disposed of for for some reason by the the memeory manager.

Specified by:
getSelectedPageText in interface org.icepdf.core.views.DocumentViewModel
Returns:
list of pages that are in a selected state.

isSelectAll

public boolean isSelectAll()
Gets the selected all state of the doucment pages view.

Specified by:
isSelectAll in interface org.icepdf.core.views.DocumentViewModel
Returns:
true if all pages are ina selected state, false otherwise.

setSelectAll

public void setSelectAll(boolean selectAll)
Sets the select all state of the text in the document. If true the document text is all selected; otherwise, false. This is only a flag and must be interpreted by the pages and page view components.

Specified by:
setSelectAll in interface org.icepdf.core.views.DocumentViewModel
Parameters:
selectAll - to to specify all text is selected, false to sepcify no text is selected

addSelectedPageText

public void addSelectedPageText(org.icepdf.core.views.swing.AbstractPageViewComponent pageViewComponent)
Adds the specified page to selected page cache. No checking is done to make sure of selected text. The caches is used as an optimization to make sure selected text can be cleared quickly.

Specified by:
addSelectedPageText in interface org.icepdf.core.views.DocumentViewModel
Parameters:
pageViewComponent - pageview component to add to list.

clearSelectedPageText

public void clearSelectedPageText()
Clears cache used to store which pages have selected state.

Specified by:
clearSelectedPageText in interface org.icepdf.core.views.DocumentViewModel

setViewZoom

public boolean setViewZoom(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:
setViewZoom in interface org.icepdf.core.views.DocumentViewModel
Parameters:
viewZoom - zoom factor
Returns:
if zoom actually changed

invalidate

public void invalidate()
Invalidate the underlying Document Page models.

Specified by:
invalidate in interface org.icepdf.core.views.DocumentViewModel

getViewZoom

public float getViewZoom()
Specified by:
getViewZoom in interface org.icepdf.core.views.DocumentViewModel

setViewRotation

public boolean setViewRotation(float viewRotation)
Specified by:
setViewRotation in interface org.icepdf.core.views.DocumentViewModel

getViewRotation

public float getViewRotation()
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:
getViewRotation in interface org.icepdf.core.views.DocumentViewModel
Returns:
zoom factor

setViewToolMode

public boolean setViewToolMode(int viewToolMode)
Specified by:
setViewToolMode in interface org.icepdf.core.views.DocumentViewModel

getViewToolMode

public int getViewToolMode()
Specified by:
getViewToolMode in interface org.icepdf.core.views.DocumentViewModel

isViewToolModeSelected

public boolean isViewToolModeSelected(int viewToolMode)
Specified by:
isViewToolModeSelected in interface org.icepdf.core.views.DocumentViewModel

setPageBoundary

public void setPageBoundary(int pageBoundary)
Sets the page boundtry used to paint a page.

Specified by:
setPageBoundary in interface org.icepdf.core.views.DocumentViewModel
Parameters:
pageBoundary - page bounds

getPageBoundary

public int getPageBoundary()
Specified by:
getPageBoundary in interface org.icepdf.core.views.DocumentViewModel

getPageBounds

public java.awt.Rectangle getPageBounds(int pageIndex)
Specified by:
getPageBounds in interface org.icepdf.core.views.DocumentViewModel

dispose

public void dispose()
Specified by:
dispose in interface org.icepdf.core.views.DocumentViewModel

getCurrentAnnotation

public org.icepdf.core.views.swing.AnnotationComponentImpl getCurrentAnnotation()
Gets the currently selected annotation in the document model.

Specified by:
getCurrentAnnotation in interface org.icepdf.core.views.DocumentViewModel
Returns:
currently selected annotation, null if there is none.

setCurrentAnnotation

public void setCurrentAnnotation(org.icepdf.core.views.swing.AnnotationComponentImpl currentAnnotation)
Sets the current annotation. This is manily called by the UI tools when editing and selecting page annotations.

Specified by:
setCurrentAnnotation in interface org.icepdf.core.views.DocumentViewModel
Parameters:
currentAnnotation - annotation to make current.

getAnnotationCareTaker

public UndoCaretaker getAnnotationCareTaker()
Gets annotation caretaker responsible for saving states as defined by the momento pattern.

Returns:
document leve annotation care taker.

addMemento

public void addMemento(org.icepdf.core.Memento oldMementoState,
                       org.icepdf.core.Memento newMementoState)
Specified by:
addMemento in interface org.icepdf.core.views.DocumentViewModel