com.crionics.jpdf.viewer
Class ViewerPanel

java.lang.Object
  extended by AbstractJPanel
      extended by com.crionics.jpdf.viewer.ViewerPanel
All Implemented Interfaces:
IViewer, java.beans.PropertyChangeListener, java.util.EventListener

public class ViewerPanel
extends AbstractJPanel
implements java.beans.PropertyChangeListener, IViewer

Create a rich GUI panel which shows the RendererPanel, along with the docking framework (toolbars, bookmarks, wizards..etc) and the bottom status bar. The component is i18 compliant and has all the methods to show/hide docking windows and toolbars.


Field Summary
 
Fields inherited from interface com.crionics.jpdf.viewer.IViewer
PAGELAYOUT_1X1, PAGELAYOUT_2X1, PAGELAYOUT_2X2, PAGEZOOM_FITPAGE, PAGEZOOM_FITWIDTH
 
Constructor Summary
ViewerPanel()
          Constructor
 
Method Summary
 void addPageEventListener(IPageEvent listener)
          This method can be used to trap user click positions on a given page.
 boolean closeDocument()
          Closes the current displayed document.
 boolean getDetailPanelVisibility()
          return true if the detail panel is visible
 boolean getDrawingToolBarVisibility()
          Return the status of the drawing toolbar
 boolean getFormFieldToolBarVisibility()
          returns the status of the forms toolbar
 boolean getIOToolBarVisibility()
          Return the status of the io toolbar
 boolean getMessagesPanelVisibility()
          return true if the message panel is visible
 boolean getNavigationToolBarVisibility()
          Return the status of the navigation toolbar
 java.awt.print.PageFormat getPageFormat(int pageIndex)
          Returns the page format in page space.
 int getPageIndex()
          Returns the current displayed page index.
 int getPageLayout()
          Returns the current page layout.
 int getPageRotation()
          return the page orientation. typically, 0,90,180 or 270
 int getPageZoom()
          returns the current zoom factor applied to the page. the integer value is a percentage.
 int getPageZoomMode()
          returns the zoom mode, either PAGEZOOM_FITPAGE or PAGEZOOM_FITWIDTH
 PdfDocument getPdfDocument()
          returns the underlying PDF document, or null if none displayed
 boolean getSelectorsToolBarVisibility()
          Return the status of the selectors toolbar
 boolean getWizardPanelVisibility()
          return true if the wizard panel is visible
 boolean isDocumentLoaded()
          return true if document is loaded and displayed
 void printCurrentPage()
          Shows a dialog to print the current page.
 void printDocument()
          Shows a dialog to print the document.
 void printPageRange(int startIndex, int endIndex)
          Shows a dialog to print a page range.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Internal method used to handle GUI events.
 void setDetailPanelVisibility(boolean showPanel)
          shows or hides the detail panel.
 void setDocument(java.io.File filePath)
          Loads and Displays the given document in the rendering panel.
 void setDocument(java.io.File pathToPDF, ICredentials credentials)
          Displays the given document in the rendering panel using the given credentials.
 void setDocument(PdfDocument thedoc)
          Loads and Displays the given document in the rendering panel.
 void setDrawingToolBarVisibility(boolean showToolbar)
          Shows/Hides the Drawing Toolbar.
 void setFormFieldToolBarVisibility(boolean showToolbar)
          Shows/Hides the Form Fields Toolbar.
 void setFullScreenMode()
          Forces the viewer to fullscreen mode.
 void setIOToolBarVisibility(boolean showToolbar)
          shows/hides the IO Toolbar.
 void setMessagesPanelVisibility(boolean showPanel)
          shows or hides the message panel.
 void setNavigationToolBarVisibility(boolean showToolbar)
          Shows/Hides the Navigation Toolbar.
 void setPageIndex(int pageNumber)
          Forces the renderer to display the given page index.
 void setPageLayout(int n)
          Changes how many pages are displayed per screen.
 void setPageRotation(int rotation)
          Sets the page orientation.
 void setPageZoom(int percentage)
          Sets the zoom factor. the value is a percentage. the zoom factor interpretation is heavily dependent on the zoom mode.
 void setPageZoomMode(int mode)
          Sets the zoom mode, either PAGEZOOM_FITPAGE or PAGEZOOM_FITWIDTH.
 void setSelectorsToolBarVisibility(boolean showToolbar)
          Shows/Hides the Selectors Toolbar.
 void setWizardPanelVisibility(boolean showPanel)
          shows or hides the wizards panel.
 void setZoomTo(int pageIndex, java.awt.geom.Point2D location, int zoomFactor)
          Centers the viewer scroll panel to the given page index, point location and zoom factor.
 void setZoomToArea(int pageIndex, java.awt.geom.Point2D upperLeft, java.awt.geom.Point2D bottomRight)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewerPanel

public ViewerPanel()
Constructor

Method Detail

addPageEventListener

public void addPageEventListener(IPageEvent listener)
This method can be used to trap user click positions on a given page.

Parameters:
listener - the event listener

closeDocument

public boolean closeDocument()
Description copied from interface: IViewer
Closes the current displayed document.

Specified by:
closeDocument in interface IViewer
Returns:
the return value can be ignored - it is used internally.

getDetailPanelVisibility

public boolean getDetailPanelVisibility()
return true if the detail panel is visible

Returns:
true if the detail panel is visible

getDrawingToolBarVisibility

public boolean getDrawingToolBarVisibility()
Return the status of the drawing toolbar

Returns:
the status of the drawing toolbar

getFormFieldToolBarVisibility

public boolean getFormFieldToolBarVisibility()
returns the status of the forms toolbar

Returns:
the status of the forms toolbar

getIOToolBarVisibility

public boolean getIOToolBarVisibility()
Return the status of the io toolbar

Returns:
the status of the io toolbar

getMessagesPanelVisibility

public boolean getMessagesPanelVisibility()
return true if the message panel is visible

Returns:
true if the message panel is visible

getNavigationToolBarVisibility

public boolean getNavigationToolBarVisibility()
Return the status of the navigation toolbar

Returns:
the status of the navigation toolbar

getPageIndex

public int getPageIndex()
Description copied from interface: IViewer
Returns the current displayed page index. Note that if the matrix layout displays more then one page, the return value represents the page that is the closer to the center.

Specified by:
getPageIndex in interface IViewer
Returns:
the current displayed page index [1 to max]

getPageLayout

public int getPageLayout()
                  throws PdfException
Description copied from interface: IViewer
Returns the current page layout.

Specified by:
getPageLayout in interface IViewer
Returns:
layout 1,2 (2x1) or 4 (2x2)
Throws:
PdfException - pdf related issues

getPageRotation

public int getPageRotation()
Description copied from interface: IViewer
return the page orientation. typically, 0,90,180 or 270

Specified by:
getPageRotation in interface IViewer
Returns:
the page orientation.

getPageZoom

public int getPageZoom()
                throws PdfException
Description copied from interface: IViewer
returns the current zoom factor applied to the page. the integer value is a percentage.

Specified by:
getPageZoom in interface IViewer
Returns:
the current zoom factor
Throws:
PdfException - pdf related issues

getPageZoomMode

public int getPageZoomMode()
                    throws PdfException
Description copied from interface: IViewer
returns the zoom mode, either PAGEZOOM_FITPAGE or PAGEZOOM_FITWIDTH

Specified by:
getPageZoomMode in interface IViewer
Returns:
the zoom mode, either PAGEZOOM_FITPAGE or PAGEZOOM_FITWIDTH
Throws:
PdfException - pdf related issues

getPdfDocument

public PdfDocument getPdfDocument()
Description copied from interface: IViewer
returns the underlying PDF document, or null if none displayed

Specified by:
getPdfDocument in interface IViewer
Returns:
the underlying PDF document, or null if none displayed

getSelectorsToolBarVisibility

public boolean getSelectorsToolBarVisibility()
Return the status of the selectors toolbar

Returns:
the status of the selectors toolbar

getWizardPanelVisibility

public boolean getWizardPanelVisibility()
return true if the wizard panel is visible

Returns:
true if the wizard panel is visible

isDocumentLoaded

public boolean isDocumentLoaded()
Description copied from interface: IViewer
return true if document is loaded and displayed

Specified by:
isDocumentLoaded in interface IViewer
Returns:
true if document is loaded and displayed

setDocument

public void setDocument(PdfDocument thedoc)
Description copied from interface: IViewer
Loads and Displays the given document in the rendering panel.
IMPORTANT: the loading is ASYNCHRONOUS, please use the method isDocumentLoaded() to check when to document is completely rendered.

Specified by:
setDocument in interface IViewer

printCurrentPage

public void printCurrentPage()
                      throws PdfException
Description copied from interface: IViewer
Shows a dialog to print the current page.

Specified by:
printCurrentPage in interface IViewer
Throws:
PdfException

printDocument

public void printDocument()
Description copied from interface: IViewer
Shows a dialog to print the document. Simulates a user click on the print icon.

Specified by:
printDocument in interface IViewer

printPageRange

public void printPageRange(int startIndex,
                           int endIndex)
Description copied from interface: IViewer
Shows a dialog to print a page range.

Specified by:
printPageRange in interface IViewer
Parameters:
startIndex - start page index [1,+]
endIndex - end page index [1,+]

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Internal method used to handle GUI events.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setDetailPanelVisibility

public void setDetailPanelVisibility(boolean showPanel)
shows or hides the detail panel. The detail panel shows on the left side of the display. It shows Bookmarks, Layers, Page Preview and more.

Parameters:
showPanel - true to show the panel

setDocument

public void setDocument(java.io.File filePath)
                 throws java.io.IOException,
                        PdfException,
                        PdfAuthException
Description copied from interface: IViewer
Loads and Displays the given document in the rendering panel.
IMPORTANT: the loading is ASYNCHRONOUS, please use the method isDocumentLoaded() to check when to document is completely rendered.

Specified by:
setDocument in interface IViewer
Parameters:
filePath - path to the document
Throws:
java.io.IOException - issue related to io and caching
PdfException - issue related to PDF
PdfAuthException - issue with authentication

setDocument

public void setDocument(java.io.File pathToPDF,
                        ICredentials credentials)
                 throws java.io.IOException,
                        PdfException,
                        PdfAuthException
Description copied from interface: IViewer
Displays the given document in the rendering panel using the given credentials. Use this method to open document password or certificate protected. IMPORTANT: the loading is ASYNCHRONOUS, please use the method isDocumentLoaded() to check when to document is completely rendered.

Specified by:
setDocument in interface IViewer
Parameters:
pathToPDF - path to the document, if null - the current document is closed.
credentials - password or certificate credentials to open the document
Throws:
java.io.IOException - issue related to io and caching
PdfException - issue related to PDF
PdfAuthException - issue with authentication

setDrawingToolBarVisibility

public void setDrawingToolBarVisibility(boolean showToolbar)
Shows/Hides the Drawing Toolbar. The Drawing Toolbar contains buttons to create text and figures.

Parameters:
showToolbar - true if the toolbar is visible

setFormFieldToolBarVisibility

public void setFormFieldToolBarVisibility(boolean showToolbar)
Shows/Hides the Form Fields Toolbar. The Form Fields Toolbar contains buttons to create form fields and signatures.

Parameters:
showToolbar - true if the toolbar is visible

setFullScreenMode

public void setFullScreenMode()
Forces the viewer to fullscreen mode. In fullscreen mode, the page takes the whole screen and all controls and docking windows disapear.


setIOToolBarVisibility

public void setIOToolBarVisibility(boolean showToolbar)
shows/hides the IO Toolbar. The IO Toolbar contains buttons to open, save and print documents.

Parameters:
showToolbar - true if the toolbar is visible

setMessagesPanelVisibility

public void setMessagesPanelVisibility(boolean showPanel)
shows or hides the message panel. The message panel shows at the bottom and displays parser/renderer related messages.

Parameters:
showPanel - true to show the panel

setNavigationToolBarVisibility

public void setNavigationToolBarVisibility(boolean showToolbar)
Shows/Hides the Navigation Toolbar. The Navigation Toolbar contains buttons to browse and size the document

Parameters:
showToolbar - true if the toolbar is visible

setPageIndex

public void setPageIndex(int pageNumber)
Description copied from interface: IViewer
Forces the renderer to display the given page index.

Specified by:
setPageIndex in interface IViewer
Parameters:
pageNumber - the page index to display

setPageLayout

public void setPageLayout(int n)
                   throws PdfException
Description copied from interface: IViewer
Changes how many pages are displayed per screen. The pages are arranged per matrix of 1, 2x1 or 2x2

Specified by:
setPageLayout in interface IViewer
Parameters:
n - 1,2 (2x1) or 4 (2x2)
Throws:
PdfException - pdf related issues

setPageRotation

public void setPageRotation(int rotation)
Description copied from interface: IViewer
Sets the page orientation.

Specified by:
setPageRotation in interface IViewer
Parameters:
rotation - the page rotation is degrees, typically 0,90,180 or 270

setPageZoom

public void setPageZoom(int percentage)
Description copied from interface: IViewer
Sets the zoom factor. the value is a percentage. the zoom factor interpretation is heavily dependent on the zoom mode.

Specified by:
setPageZoom in interface IViewer
Parameters:
percentage - an integer value which represents a zoom percentage.

setPageZoomMode

public void setPageZoomMode(int mode)
                     throws PdfException
Description copied from interface: IViewer
Sets the zoom mode, either PAGEZOOM_FITPAGE or PAGEZOOM_FITWIDTH. PAGEZOOM_FITPAGE, will fit the whole page on the screen. PAGEZOOM_FITWIDTH will fit the page width.

Specified by:
setPageZoomMode in interface IViewer
Parameters:
mode - either PAGEZOOM_FITPAGE or PAGEZOOM_FITWIDTH
Throws:
PdfException - pdf related issues

setSelectorsToolBarVisibility

public void setSelectorsToolBarVisibility(boolean showToolbar)
Shows/Hides the Selectors Toolbar. The Selectors Toolbar contains buttons to switch the viewer to edition mode.

Parameters:
showToolbar - true if the toolbar is visible

setWizardPanelVisibility

public void setWizardPanelVisibility(boolean showPanel)
shows or hides the wizards panel. The Wizards Panel shows on the right side of the display and is usually hidden by default. It shows wizards actions and links to resources.

Parameters:
showPanel - true to show the panel

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws PdfException,
                                               java.io.IOException
Description copied from interface: IViewer
Returns the page format in page space.

Specified by:
getPageFormat in interface IViewer
Parameters:
pageIndex - the page index [1 to max]
Returns:
the page format in page space
Throws:
PdfException - Raised if a problem occurred while parsing the file.
java.io.IOException - Raised if a problem occurred while reading the file.

setZoomTo

public void setZoomTo(int pageIndex,
                      java.awt.geom.Point2D location,
                      int zoomFactor)
               throws PdfException,
                      java.io.IOException
Description copied from interface: IViewer
Centers the viewer scroll panel to the given page index, point location and zoom factor. The location should be expressed in page units. Please refer to the method getPageFormat()

Specified by:
setZoomTo in interface IViewer
Parameters:
pageIndex - the index of the page to zoom onto [1, max]
location - the location in PageSpace of the point to center on
zoomFactor - zoom factor to , use -1 to set unchanged
Throws:
PdfException
java.io.IOException

setZoomToArea

public void setZoomToArea(int pageIndex,
                          java.awt.geom.Point2D upperLeft,
                          java.awt.geom.Point2D bottomRight)
                   throws PdfException,
                          java.io.IOException
Specified by:
setZoomToArea in interface IViewer
Parameters:
pageIndex - the index of the page to zoom onto [1, max]
Throws:
PdfException
java.io.IOException


Copyright © 1999-2007 Crionics. All Rights Reserved.