com.icesoft.pdf.ri.common.views
Class AbstractDocumentViewModel

java.lang.Object
  extended bycom.icesoft.pdf.ri.common.views.AbstractDocumentViewModel
All Implemented Interfaces:
DocumentViewModel
Direct Known Subclasses:
DocumentViewModelImpl

public abstract class AbstractDocumentViewModel
extends Object
implements 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  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  Vector pageComponents
           
protected static PooledExecutor pageInitilizationThreadPool
           
protected static PooledExecutor pagePainterThreadPool
           
protected  float userRotation
           
protected  int userToolModeFlag
           
protected  float userZoom
           
 
Fields inherited from interface com.icesoft.pdf.views.DocumentViewModel
DISPLAY_TOOL_NONE, DISPLAY_TOOL_PAN, DISPLAY_TOOL_WAIT, DISPLAY_TOOL_ZOOM_IN, DISPLAY_TOOL_ZOOM_OUT
 
Constructor Summary
AbstractDocumentViewModel(Document currentDocument)
           
 
Method Summary
 void dispose()
          Free resources associated with this model.
 void executePageInitialization(Runnable runnable)
           
 void executePagePainter(Runnable runnable)
           
 Document getDocument()
          Gets the PDF document object associated with this views.
 Rectangle getPageBounds(int pageIndex)
          Gets the page bound of the specified page Index.
 Vector getPageComponents()
          Gets the page components associated with this view model.
 int getViewCurrentPageIndex()
          Gets the current page index represented in this model.
 float getViewRotation()
          Returns the zoom factor of the page visualization.
 int getViewToolMode()
          Gets the tool mode.
 float getViewZoom()
          Gets the view model zoom level.
 boolean isViewToolModeSelected(int viewToolMode)
          Checks if the specified tool mode is set in the view model.
 boolean setViewCurrentPageIndex(int pageIndex)
          Sets the view model current page index.
 boolean setViewRotation(float viewRotation)
          Sets the view rotaiton of this model.
 boolean setViewToolMode(int viewToolMode)
          Sets the view tool mode.
 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 Document currentDocument

pageComponents

protected Vector pageComponents

userZoom

protected float userZoom

oldUserZoom

protected float oldUserZoom

userRotation

protected float userRotation

oldUserRotation

protected float oldUserRotation

currentPageIndex

protected int currentPageIndex

oldPageIndex

protected int oldPageIndex

userToolModeFlag

protected int userToolModeFlag

oldUserToolModeFlag

protected int oldUserToolModeFlag

pageInitilizationThreadPool

protected static PooledExecutor pageInitilizationThreadPool

pagePainterThreadPool

protected static PooledExecutor 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(Document currentDocument)
Method Detail

getDocument

public Document getDocument()
Description copied from interface: DocumentViewModel
Gets the PDF document object associated with this views.

Specified by:
getDocument in interface DocumentViewModel
Returns:
PDF document which is associated with this view.

executePageInitialization

public void executePageInitialization(Runnable runnable)
                               throws InterruptedException
Specified by:
executePageInitialization in interface DocumentViewModel
Throws:
InterruptedException

executePagePainter

public void executePagePainter(Runnable runnable)
                        throws InterruptedException
Specified by:
executePagePainter in interface DocumentViewModel
Throws:
InterruptedException

getPageComponents

public Vector getPageComponents()
Description copied from interface: DocumentViewModel
Gets the page components associated with this view model.

Specified by:
getPageComponents in interface DocumentViewModel
Returns:
vector of page components.

setViewCurrentPageIndex

public boolean setViewCurrentPageIndex(int pageIndex)
Description copied from interface: DocumentViewModel
Sets the view model current page index.

Specified by:
setViewCurrentPageIndex in interface DocumentViewModel
Parameters:
pageIndex - zero based current pages page index of the document.
Returns:
true if the page index could be set, false otherwise.

getViewCurrentPageIndex

public int getViewCurrentPageIndex()
Description copied from interface: DocumentViewModel
Gets the current page index represented in this model.

Specified by:
getViewCurrentPageIndex in interface DocumentViewModel
Returns:
zero based page page index.

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 DocumentViewModel
Parameters:
viewZoom - zoom factor
Returns:
if zoom actually changed

getViewZoom

public float getViewZoom()
Description copied from interface: DocumentViewModel
Gets the view model zoom level.

Specified by:
getViewZoom in interface DocumentViewModel
Returns:
zoom level of this view model

setViewRotation

public boolean setViewRotation(float viewRotation)
Description copied from interface: DocumentViewModel
Sets the view rotaiton of this model.

Specified by:
setViewRotation in interface DocumentViewModel
Parameters:
viewRotation -
Returns:
true if the view rotation was set correctly, otherwise false.

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 DocumentViewModel
Returns:
zoom factor

setViewToolMode

public boolean setViewToolMode(int viewToolMode)
Description copied from interface: DocumentViewModel
Sets the view tool mode.

Specified by:
setViewToolMode in interface DocumentViewModel
Parameters:
viewToolMode -
Returns:
true if the view tool was set correctly, false otherwise.

getViewToolMode

public int getViewToolMode()
Description copied from interface: DocumentViewModel
Gets the tool mode.

Specified by:
getViewToolMode in interface DocumentViewModel
Returns:
tool mode.

isViewToolModeSelected

public boolean isViewToolModeSelected(int viewToolMode)
Description copied from interface: DocumentViewModel
Checks if the specified tool mode is set in the view model.

Specified by:
isViewToolModeSelected in interface DocumentViewModel
Parameters:
viewToolMode - tool model to check if selected.
Returns:
true if specified tool mode is selected, otherwise false.

getPageBounds

public Rectangle getPageBounds(int pageIndex)
Description copied from interface: DocumentViewModel
Gets the page bound of the specified page Index.

Specified by:
getPageBounds in interface DocumentViewModel
Parameters:
pageIndex - zero based page index.
Returns:
bounds of specified page. If page index. is not valid, null is returned.

dispose

public void dispose()
Description copied from interface: DocumentViewModel
Free resources associated with this model.

Specified by:
dispose in interface DocumentViewModel