com.jasperassistant.designer.viewer
Interface IReportViewer

All Known Implementing Classes:
ReportViewer

public interface IReportViewer

The report viewer interface. A report viewer is capable of displaying JasperPrint documents and its state changes are observable through a listener mechanism.

Author:
Peter Severin (peter_p_s@users.sourceforge.net)

Field Summary
static int ZOOM_MODE_ACTUAL_SIZE
          The zoom mode that instructs the viewer to display report pages at their actual size.
static int ZOOM_MODE_FIT_HEIGHT
          The zoom mode that instructs the viewer to display report pages so that they fit the available height.
static int ZOOM_MODE_FIT_PAGE
          The zoom mode that instructs the viewer to display report pages so that they fit the available width and height.
static int ZOOM_MODE_FIT_WIDTH
          The zoom mode that instructs the viewer to display report pages so that they fit the available width.
static int ZOOM_MODE_NONE
          The zoom mode constant that stands for "no zoom"
 
Method Summary
 void addHyperlinkListener(net.sf.jasperreports.view.JRHyperlinkListener listener)
          Registers a hyperlink click listener that will be notified when user clicks a hyperlink.
 void addReportViewerListener(IReportViewerListener listener)
          Register a report viewer listener that will observe the viewer state changes
 boolean canChangeZoom()
          Checks the necessary preconditions for zoom changing
 boolean canGotoFirstPage()
          Checks the preconditions for first page positioning
 boolean canGotoLastPage()
          Checks the preconditions for last page positioning
 boolean canGotoNextPage()
          Checks the preconditions for next page positioning
 boolean canGotoPreviousPage()
          Checks the preconditions for previous page positioning
 boolean canReload()
          Checks whether the document can be reloaded.
 boolean canZoomIn()
          Checks the zoom-in operation preconditions
 boolean canZoomOut()
          Checks the zoom in preconditions
 net.sf.jasperreports.engine.JasperPrint getDocument()
          Returns the jasper print document
 net.sf.jasperreports.view.JRHyperlinkListener[] getHyperlinkListeners()
          Returns registered hyperlink listeners
 int getPageIndex()
          Returns the current page index.
 java.lang.String getReason()
          Returns the message that explains the reason that the document is missing.
 double getZoom()
          Returns the current zoom level
 double[] getZoomLevels()
          Returns an array with available zoom levels
 int getZoomMode()
          Returns the current zoom mode
 void gotoFirstPage()
          Positions the viewer on the first page in the document
 void gotoLastPage()
          Positions the viewer on the last page in the document
 void gotoNextPage()
          Positions the viewer on the next page in the document
 void gotoPreviousPage()
          Positions the viewer on the previous page in the document
 boolean hasDocument()
          Returns true if there is a jasper print document set
 void loadDocument(java.lang.String fileName, boolean xml)
          Loads the document from the given file.
 void reload()
          Reloads the report.
 void removeHyperlinkListener(net.sf.jasperreports.view.JRHyperlinkListener listener)
          Removes a previously registered hyperlink click listener
 void removeReportViewerListener(IReportViewerListener listener)
          Removes a previously registered report viewer listener
 void setDocument(net.sf.jasperreports.engine.JasperPrint document)
          Sets the jasper print document
 void setPageIndex(int pageIndex)
          Sets the current page index.
 void setZoom(double zoom)
          Sets the zoom level
 void setZoomLevels(double[] zoomLevels)
          Sets the available zoom levels
 void setZoomMode(int zoomMode)
          Sets the zoom mode.
 void unsetDocument(java.lang.String reason)
          Sets to null the currently set document.
 void zoomIn()
          Zooms in the viewer
 void zoomOut()
          Zooms out the viewer
 

Field Detail

ZOOM_MODE_NONE

public static final int ZOOM_MODE_NONE
The zoom mode constant that stands for "no zoom"

See Also:
Constant Field Values

ZOOM_MODE_ACTUAL_SIZE

public static final int ZOOM_MODE_ACTUAL_SIZE
The zoom mode that instructs the viewer to display report pages at their actual size.

See Also:
Constant Field Values

ZOOM_MODE_FIT_WIDTH

public static final int ZOOM_MODE_FIT_WIDTH
The zoom mode that instructs the viewer to display report pages so that they fit the available width.

See Also:
Constant Field Values

ZOOM_MODE_FIT_HEIGHT

public static final int ZOOM_MODE_FIT_HEIGHT
The zoom mode that instructs the viewer to display report pages so that they fit the available height.

See Also:
Constant Field Values

ZOOM_MODE_FIT_PAGE

public static final int ZOOM_MODE_FIT_PAGE
The zoom mode that instructs the viewer to display report pages so that they fit the available width and height.

See Also:
Constant Field Values
Method Detail

loadDocument

public void loadDocument(java.lang.String fileName,
                         boolean xml)
Loads the document from the given file. The file can contain either a serialized JasperPrint object or a jrprint xml document. The format is controlled by the xml boolean parameter.

Parameters:
fileName - the file name
xml - flag that indicates the type of file type. If true, the file contains an xml and a serialized object otherwise.

setDocument

public void setDocument(net.sf.jasperreports.engine.JasperPrint document)
Sets the jasper print document

Parameters:
document - document to set. Must be not null.

getDocument

public net.sf.jasperreports.engine.JasperPrint getDocument()
Returns the jasper print document

Returns:
the jasper print docuemnt or null if none

hasDocument

public boolean hasDocument()
Returns true if there is a jasper print document set

Returns:
true if the document is set

unsetDocument

public void unsetDocument(java.lang.String reason)
Sets to null the currently set document.

Parameters:
reason - the reason for the missing document. Can be null.

getReason

public java.lang.String getReason()
Returns the message that explains the reason that the document is missing.

Returns:
the reason or null if none.

addReportViewerListener

public void addReportViewerListener(IReportViewerListener listener)
Register a report viewer listener that will observe the viewer state changes

Parameters:
listener - the listener

removeReportViewerListener

public void removeReportViewerListener(IReportViewerListener listener)
Removes a previously registered report viewer listener

Parameters:
listener - the listener

reload

public void reload()
Reloads the report. The reload will be performed if only the report was loaded through the loadDocument method.

See Also:
loadDocument(String, boolean)

canReload

public boolean canReload()
Checks whether the document can be reloaded.

Returns:
true if the current document can be reloaded

getPageIndex

public int getPageIndex()
Returns the current page index.

Returns:
the page index

setPageIndex

public void setPageIndex(int pageIndex)
Sets the current page index.

Parameters:
pageIndex - the page index

gotoNextPage

public void gotoNextPage()
Positions the viewer on the next page in the document


canGotoNextPage

public boolean canGotoNextPage()
Checks the preconditions for next page positioning

Returns:
true if the viewer can be positioned to the next page.

gotoPreviousPage

public void gotoPreviousPage()
Positions the viewer on the previous page in the document


canGotoPreviousPage

public boolean canGotoPreviousPage()
Checks the preconditions for previous page positioning

Returns:
true if the viewer can be positioned to the previous page.

gotoLastPage

public void gotoLastPage()
Positions the viewer on the last page in the document


canGotoLastPage

public boolean canGotoLastPage()
Checks the preconditions for last page positioning

Returns:
true if the viewer can be positioned to the last page.

gotoFirstPage

public void gotoFirstPage()
Positions the viewer on the first page in the document


canGotoFirstPage

public boolean canGotoFirstPage()
Checks the preconditions for first page positioning

Returns:
true if the viewer can be positioned to the first page.

setZoom

public void setZoom(double zoom)
Sets the zoom level

Parameters:
zoom - zoom level

getZoom

public double getZoom()
Returns the current zoom level

Returns:
the zoom level

canChangeZoom

public boolean canChangeZoom()
Checks the necessary preconditions for zoom changing

Returns:
true if the zoom level and mode can be changed

setZoomMode

public void setZoomMode(int zoomMode)
Sets the zoom mode. One of the predefined ZOOM_MODE constants must be used.

Parameters:
zoomMode - the zoom mode

getZoomMode

public int getZoomMode()
Returns the current zoom mode

Returns:
the zoom mode

getZoomLevels

public double[] getZoomLevels()
Returns an array with available zoom levels

Returns:
a non-empty array of configured zoom levels

setZoomLevels

public void setZoomLevels(double[] zoomLevels)
Sets the available zoom levels

Parameters:
zoomLevels - a non-null and non-empty array of zoom levels

zoomIn

public void zoomIn()
Zooms in the viewer


canZoomIn

public boolean canZoomIn()
Checks the zoom-in operation preconditions

Returns:
true if the viewer can be zoomed in

zoomOut

public void zoomOut()
Zooms out the viewer


canZoomOut

public boolean canZoomOut()
Checks the zoom in preconditions

Returns:
true if the viewer can be zoomed out

addHyperlinkListener

public void addHyperlinkListener(net.sf.jasperreports.view.JRHyperlinkListener listener)
Registers a hyperlink click listener that will be notified when user clicks a hyperlink.

Parameters:
listener - the listener to add

removeHyperlinkListener

public void removeHyperlinkListener(net.sf.jasperreports.view.JRHyperlinkListener listener)
Removes a previously registered hyperlink click listener

Parameters:
listener - the listener to remove

getHyperlinkListeners

public net.sf.jasperreports.view.JRHyperlinkListener[] getHyperlinkListeners()
Returns registered hyperlink listeners

Returns:
a non-null array of listeners