com.jrefinery.report.preview
Class ReportPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.jrefinery.report.preview.ReportPane
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Pageable, java.awt.print.Printable, java.io.Serializable

public class ReportPane
extends javax.swing.JComponent
implements java.awt.print.Printable, java.awt.print.Pageable

A panel used to display one page of a report. Works in tandem with a ReportPreviewFrame to display a report.

The panel uses several properties to inform its listeners of state changes.

Author:
David Gilbert, Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String BORDER_PROPERTY
          Literal text for the 'borderPainted' property.
static java.lang.String ERROR_PROPERTY
          Literal text for the 'error' property.
static java.lang.String NUMBER_OF_PAGES_PROPERTY
          Literal text for the 'NumberOfPages' property.
static java.lang.String PAGENUMBER_PROPERTY
          Literal text for the 'pagenumber' property.
static java.lang.String PAGINATED_PROPERTY
          Literal text for the 'paginated' property.
static java.lang.String ZOOMFACTOR_PROPERTY
          Literal text for the 'zoomfactor' property.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ReportPane(JFreeReport report)
          Creates a report pane to display the specified report.
 
Method Summary
 void clearError()
          Clears the error state.
 void dispose()
          Free some of the used memory.
 java.lang.Exception getError()
          Queries the error state for this ReportPane.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size of the pane - used by the layout manager.
 int getNumberOfPages()
          Gets the number of pages in the report.
 java.awt.print.PageFormat getPageFormat()
          Returns the page format.
 java.awt.print.PageFormat getPageFormat(int page)
          Returns the pageFormat for this Pageable Object.
 int getPageNumber()
          Returns the currently displayed page.
protected  ReportStateList getPageStateList()
          Returns the current pageStates as a list.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the pane - used by the layout manager.
 java.awt.print.Printable getPrintable(int page)
          Returns a self-reference (this), as this object implements its own Printable-Interface.
 PageableReportProcessor getProcessor()
          Returns the report processor.
 JFreeReport getReport()
          Returns the report for this ReportPane.
 float getZoomFactory()
          Gets the currently set zoom factor.
 boolean hasError()
          Checks whether an error occurred since the last call to clearError().
 boolean isBorderPainted()
          checkes whether a black border is painted around the printable page area.
 boolean isHandleInterruptedState()
          Returns ??.
protected  boolean isPaginated()
          Returns true, if this report has a pagestate list.
 boolean isPaginating()
          Returns true, if this ReportPane is currently paginating.
 void paintComponent(java.awt.Graphics g)
          Paints the component, which means drawing the current page of the report.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
          Supports the Printable interface by drawing a report on a single page.
 void repaginate()
          Repaginates this report according to the OutputTarget given.
 void setBorderPainted(boolean b)
          Defines whether a black border is painted around the printable page area.
 void setError(java.lang.Exception error)
          sets the last error occurred.
 void setHandleInterruptedState(boolean handleInterruptedState)
          Sets the...
 void setPageFormat(java.awt.print.PageFormat pageFormat)
          Sets the page format.
 void setPageNumber(int page)
          Sets the page number to be displayed.
protected  void setPageStateList(ReportStateList list)
          Sets the current page state list after the report has been repaginated.
 void setZoomFactor(float factor)
          Sets the zoom factor for the pane.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAGINATED_PROPERTY

public static final java.lang.String PAGINATED_PROPERTY
Literal text for the 'paginated' property.

See Also:
Constant Field Values

NUMBER_OF_PAGES_PROPERTY

public static final java.lang.String NUMBER_OF_PAGES_PROPERTY
Literal text for the 'NumberOfPages' property.

See Also:
Constant Field Values

PAGENUMBER_PROPERTY

public static final java.lang.String PAGENUMBER_PROPERTY
Literal text for the 'pagenumber' property.

See Also:
Constant Field Values

ZOOMFACTOR_PROPERTY

public static final java.lang.String ZOOMFACTOR_PROPERTY
Literal text for the 'zoomfactor' property.

See Also:
Constant Field Values

ERROR_PROPERTY

public static final java.lang.String ERROR_PROPERTY
Literal text for the 'error' property.

See Also:
Constant Field Values

BORDER_PROPERTY

public static final java.lang.String BORDER_PROPERTY
Literal text for the 'borderPainted' property.

See Also:
Constant Field Values
Constructor Detail

ReportPane

public ReportPane(JFreeReport report)
           throws ReportProcessingException
Creates a report pane to display the specified report.

Parameters:
report - the report to display within the pane.
Throws:
ReportProcessingException - if there was a problem processing the report.
Method Detail

isHandleInterruptedState

public boolean isHandleInterruptedState()
Returns ??.

Returns:
A boolean.

setHandleInterruptedState

public void setHandleInterruptedState(boolean handleInterruptedState)
Sets the...

Parameters:
handleInterruptedState - the new flag value.

getPageStateList

protected ReportStateList getPageStateList()
Returns the current pageStates as a list.

Returns:
the report state list.

setPageStateList

protected void setPageStateList(ReportStateList list)
Sets the current page state list after the report has been repaginated. Fires the paginating PropertyChangeEvent after the report is paginated.

Parameters:
list - the report state list.

getPageFormat

public java.awt.print.PageFormat getPageFormat()
Returns the page format.

Returns:
The current page format;

getPageFormat

public java.awt.print.PageFormat getPageFormat(int page)
Returns the pageFormat for this Pageable Object. Currently no different pageformats are supported within a single report, so this returns alway the same as getPageFormat()

Specified by:
getPageFormat in interface java.awt.print.Pageable
Parameters:
page - the page number.
Returns:
the page format.

getPrintable

public java.awt.print.Printable getPrintable(int page)
Returns a self-reference (this), as this object implements its own Printable-Interface.

Specified by:
getPrintable in interface java.awt.print.Pageable
Parameters:
page - the page number.
Returns:
this object (as an instance of Printable).

isPaginated

protected boolean isPaginated()
Returns true, if this report has a pagestate list.

Returns:
true if the report has been paginated.

setPageFormat

public void setPageFormat(java.awt.print.PageFormat pageFormat)
Sets the page format.

Parameters:
pageFormat - The new page format;

getPageNumber

public int getPageNumber()
Returns the currently displayed page.

Returns:
the current page shown.

getNumberOfPages

public int getNumberOfPages()
Gets the number of pages in the report. If the report is not yet paginated, the pagination is done.

Specified by:
getNumberOfPages in interface java.awt.print.Pageable
Returns:
the page count for the current page settings.

isBorderPainted

public boolean isBorderPainted()
checkes whether a black border is painted around the printable page area.

Returns:
a flag indicating whether to paint the border.

setBorderPainted

public void setBorderPainted(boolean b)
Defines whether a black border is painted around the printable page area.

Parameters:
b - a flag indicating whether to paint the border.

setPageNumber

public void setPageNumber(int page)
Sets the page number to be displayed. If the page number is negaitive it is corrected to 0. A page 0 is never printed.

Parameters:
page - The new page number;

setZoomFactor

public void setZoomFactor(float factor)
Sets the zoom factor for the pane.

Parameters:
factor - The new factor;

getZoomFactory

public float getZoomFactory()
Gets the currently set zoom factor.

Returns:
the zoom factor.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the pane - used by the layout manager.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
The preferred size of the pane;

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size of the pane - used by the layout manager.

Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
The minimum size of the pane;

paintComponent

public void paintComponent(java.awt.Graphics g)
Paints the component, which means drawing the current page of the report.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphics device.

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pageIndex)
Supports the Printable interface by drawing a report on a single page.

Specified by:
print in interface java.awt.print.Printable
Parameters:
g - the graphics device.
pf - the page format.
pageIndex - the page index.
Returns:
PAGE_EXISTS if the page is rendered successfully or NO_SUCH_PAGE if pageIndex specifies a non-existent page.

isPaginating

public boolean isPaginating()
Returns true, if this ReportPane is currently paginating.

Returns:
true if the report pane is paginating.

repaginate

public void repaginate()
                throws ReportProcessingException
Repaginates this report according to the OutputTarget given. This function synchronizes on the paginateLock. While a ReportPane is paginating, no other pane may print.

Throws:
ReportProcessingException - if there is a problem processing the report.

setError

public void setError(java.lang.Exception error)
sets the last error occurred. The error can be cleared with the clearError() function.

Parameters:
error - the error.

hasError

public boolean hasError()
Checks whether an error occurred since the last call to clearError().

Returns:
a flag indicating whether or not here is an error.

getReport

public JFreeReport getReport()
Returns the report for this ReportPane.

Returns:
the report.

clearError

public void clearError()
Clears the error state.


getError

public java.lang.Exception getError()
Queries the error state for this ReportPane.

Returns:
the last error.

getProcessor

public PageableReportProcessor getProcessor()
Returns the report processor.

Returns:
the report processor.

dispose

public void dispose()
Free some of the used memory.