com.wildcrest.j2printerworks
Class J2TablePrinter

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.wildcrest.j2printerworks.J2Pageable
                  extended bycom.wildcrest.j2printerworks.J2TablePrinter
All Implemented Interfaces:
Flowable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Pageable, java.io.Serializable

public class J2TablePrinter
extends J2Pageable

A Java 2 component for multi-page printing of any JTable or JTable subclass as either a Pageable or a Flowable, breaking pages on table row and column boundaries (or, optionally, on a specified color such as table.getGridColor()).

The JTable can have variable row heights and/or column widths. Column and/or row headers can be printed replicated at the top/left of each page, or only on the top/left pages, or not at all. You can also specify the print area (row/column subset) to be printed. The JTable will be printed "WYSIWYG", including any fonts, colors, intercell spacing, gridline values, and/or custom cell renderers you have specified. The table can be left, right, or center justified horizontally, or top, bottom, or center justified vertically on the page.

There is separate control of horizontal and vertical pagination, with several modes of pagination are supported for each. The BREAK_ON_ROWS and BREAK_ON_COLUMNS modes will calculate exact row heights (or column widths) to determine table break boundaries. BREAK_ON_COLOR mode is an alternative that will find table boundaries whose pixel values most closely approximate a specified horizontal break color (or vertical break color). Specifying a color such as table.getGridColor() will break on row (column) boundaries and will work in certain cases where BREAK_ON_ROWS or BREAK_ON_COLUMNS does not, such as nested JTables. BREAK_ON_COLOR can be slow for large tables, but there are methods (see setAutomaticRecalculation and setBreakOnColorIncrement) which can be used to optimize the process. Finally, SHRINK_TO_FIT mode will shrink the table to fit the width (or height) of a page.

In addition, all the standard J2Pageable features are also available when printing J2TablePrinter as a Pageable, including control of headers, footers, margins, orientation, and scale.

(C) Copyright 2009, Wildcrest Associates (http://www.wildcrest.com). All rights reserved.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ALL_PAGES
          Specifies that column or row headers are to be printed on all pages.
static int BREAK_ON_COLOR
          Used in setHorizontalPageRule and setVerticalPageRule to indicate break-on-color mode
static int BREAK_ON_COLUMNS
          Used in setHorizontalPageRule to indicate break-on-columns mode
static int BREAK_ON_ROWS
          Used in setVerticalPageRule to indicate break-on-rows mode
static int LEFT_PAGES
          Specifies that row headers are to be printed on the left page(s) only.
static int NO_PAGES
          Specifies that no column or row headers are to be printed.
static int SHRINK_TO_FIT
          Used in setHorizontalPageRule and setVerticalPageRule to indicate shrink-to-fit mode
static int TOP_PAGES
          Specifies that column headers are to be printed on the top page(s) only.
 
Fields inherited from class com.wildcrest.j2printerworks.J2Pageable
BOTTOM, BOX, CENTER, FIRST, GLOBAL, LANDSCAPE, LEFT, LINE, NONE, PORTRAIT, PPI72, REST, REVERSE_LANDSCAPE, RIGHT, TOP
 
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.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
J2TablePrinter()
          Construct a JTablePageable object (no JTable specified)
J2TablePrinter(javax.swing.JTable table)
          Construct a JTablePageable object for a given JTable
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener for this component
 void dispose()
          Release all heap objects held by this J2TablePrinter object, must not call until printing completes.
 boolean doneX()
          Returns whether there is no more of this Flowable object to print horizontally.
 boolean doneY()
          Returns whether there is no more of this Flowable object to print vertically.
 int getBreakOnColorIncrement()
          Returns the evaluation increment in pixels for BREAK_ON_COLOR mode.
 int getColumnHeaderPrinting()
          Returns current value of columnHeaderPrinting property.
 int getHorizontalAlignment()
          Returns horizontal alignment (LEFT, CENTER, RIGHT) of this JTable on page.
 java.awt.Color getHorizontalBreakColor()
          Returns the Color used as break color for BREAK_ON_COLOR pagination mode when breaking horizontally.
 int getHorizontalPageRule()
          Returns current value of pageRule property (SHRINK_TO_FIT, BREAK_ON_COLUMNS, or BREAK_ON_COLOR).
 double getMaximumPaginationGap()
          Returns largest acceptable pagination gap as a percentage of the full body height/width.
 java.awt.Rectangle getPrintArea()
          Get the print area values set in the most recent setPrintArea call
 int getRowHeaderPrinting()
          Returns current value of rowHeaderPrinting property.
 javax.swing.JTable getTable()
          Returns the JTable containing the document that will be printed.
 int getVerticalAlignment()
          Returns vertical alignment (TOP, CENTER, BOTTOM) of this JTable on page.
 java.awt.Color getVerticalBreakColor()
          Returns the Color used as break color for BREAK_ON_COLOR pagination mode when breaking vertically.
 int getVerticalPageRule()
          Returns current value of pageRule property (SHRINK_TO_FIT, BREAK_ON_ROWS, or BREAK_ON_COLOR).
 boolean isAutomaticRecalculation()
          Returns whether BREAK_ON_ROWS (or COLUMNS) and BREAK_ON_COLOR internal data tables recompute automatically every time you print or print preview this JTable.
 boolean isOutsideLines()
          Returns whether to print outside gridlines around the JTable.
 boolean isOverlap()
          Returns whether to repeat the last pixel row and column again on the next page when paginating, which ensures that gridlines are drawn on all sides of the JTable rows and columns printed on each page.
 void prepareRenderer()
          Utility method that calls prepareRenderer method for all cells in the current JTable.
 void printFlowable(java.awt.Graphics g, int availableWidth, int availableHeight, int nextFullPageWidth, int nextFullPageHeight)
          Print the next sequential section of this Flowable object that fits into the next incremental area.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener for this component
 void resetFlowable()
          Reset the Flowable object so that it starts printing from the beginning.
 void setAutomaticRecalculation(boolean automaticRecalculation)
          Sets whether the BREAK_ON_ROWS (and BREAK_ON_COLUMNS) or BREAK_ON_COLOR internal data tables recompute automatically every time you print or print preview this JTable.
 void setBreakOnColorIncrement(int breakOnColorIncrement)
          Sets the evaluation increment in pixels for BREAK_ON_COLOR mode.
 void setColumnHeaderPrinting(int columnHeaderPrinting)
          Sets whether column headers printed on all pages, top pages, or no pages.
 void setHorizontalAlignment(int horizontalAlignment)
          Sets the horizontal alignment (LEFT, CENTER, RIGHT) for printing the JTable on the page.
 void setHorizontalBreakColor(java.awt.Color horizontalBreakColor)
          Sets the break color to be used for BREAK_ON_COLOR pagination mode when breaking horizontally.
 void setHorizontalPageRule(int horizontalPageRule)
          Sets the page rule for paginating the JTable horizontally, either SHRINK_TO_FIT, BREAK_ON_COLUMNS (default), or BREAK_ON_COLOR.
 void setMaximumPaginationGap(double maximumPaginationGap)
          Sets the largest acceptable pagination gap as a percentage of the full body height/width.
 void setOutsideLines(boolean showOutsideLines)
          Sets whether to print outside gridlines around the JTable.
 void setOverlap(boolean overlapEnabled)
          Sets whether to repeat the last pixel row and column again on the next page when paginating.
 void setPrintArea(int startColumnIndex, int startRowIndex, int numberOfPrintColumns, int numberOfPrintRows)
          Set the print area to be printed.
 void setPrintArea(java.awt.Rectangle rect)
          Set the print area to be printed using a Rectangle.
 void setRowHeaderPrinting(int rowHeaderPrinting)
          Sets whether row headers printed on all pages, left pages, or no pages.
 void setTable(javax.swing.JTable table)
          Specifies the JTable that will be printed.
 void setVerticalAlignment(int verticalAlignment)
          Sets the vertical alignment (TOP, CENTER, BOTTOM) for printing the JTable on the page.
 void setVerticalBreakColor(java.awt.Color verticalBreakColor)
          Sets the break color to be used for BREAK_ON_COLOR pagination mode when breaking vertically.
 void setVerticalPageRule(int verticalPageRule)
          Sets the page rule for paginating the JTable vertically, either SHRINK_TO_FIT, BREAK_ON_ROWS (default), or BREAK_ON_COLOR.
 int usedX()
          Returns the amount this Flowable object was able to advance horizontally in the last printFlowable call.
 int usedY()
          Returns the amount this Flowable object was able to advance vertically in the last printFlowable call.
 
Methods inherited from class com.wildcrest.j2printerworks.J2Pageable
clearFooters, clearFooters, clearHeaders, clearHeaders, getBodyHeight, getBodyWidth, getBottomMargin, getCenterFooter, getCenterFooter, getCenterHeader, getCenterHeader, getFooterFont, getFooterFont, getFooterStyle, getFooterStyle, getGapAboveFooter, getGapBelowHeader, getHeaderFont, getHeaderFont, getHeaderStyle, getHeaderStyle, getLeftFooter, getLeftFooter, getLeftHeader, getLeftHeader, getLeftMargin, getMaximumSize, getMinimumSize, getNumberOfPages, getNumberOfPagesHigh, getNumberOfPagesWide, getOrientation, getPageFormat, getPageFormat, getPreferredSize, getPrintable, getRightFooter, getRightFooter, getRightHeader, getRightHeader, getRightMargin, getScale, getTopMargin, paint, setBottomMargin, setCenterFooter, setCenterFooter, setCenterHeader, setCenterHeader, setFooterFont, setFooterFont, setFooterStyle, setFooterStyle, setGapAboveFooter, setGapBelowHeader, setHeaderFont, setHeaderFont, setHeaderStyle, setHeaderStyle, setLeftFooter, setLeftFooter, setLeftHeader, setLeftHeader, setLeftMargin, setLocale, setMaximumPages, setOrientation, setPageFormat, setParam, setRightFooter, setRightFooter, setRightHeader, setRightHeader, setRightMargin, setScale, setTopMargin
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, 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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, 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

SHRINK_TO_FIT

public static final int SHRINK_TO_FIT
Used in setHorizontalPageRule and setVerticalPageRule to indicate shrink-to-fit mode

See Also:
Constant Field Values

BREAK_ON_ROWS

public static final int BREAK_ON_ROWS
Used in setVerticalPageRule to indicate break-on-rows mode

See Also:
Constant Field Values

BREAK_ON_COLUMNS

public static final int BREAK_ON_COLUMNS
Used in setHorizontalPageRule to indicate break-on-columns mode

See Also:
Constant Field Values

BREAK_ON_COLOR

public static final int BREAK_ON_COLOR
Used in setHorizontalPageRule and setVerticalPageRule to indicate break-on-color mode

See Also:
Constant Field Values

NO_PAGES

public static final int NO_PAGES
Specifies that no column or row headers are to be printed.

See Also:
Constant Field Values

TOP_PAGES

public static final int TOP_PAGES
Specifies that column headers are to be printed on the top page(s) only.

See Also:
Constant Field Values

LEFT_PAGES

public static final int LEFT_PAGES
Specifies that row headers are to be printed on the left page(s) only.

See Also:
Constant Field Values

ALL_PAGES

public static final int ALL_PAGES
Specifies that column or row headers are to be printed on all pages.

See Also:
Constant Field Values
Constructor Detail

J2TablePrinter

public J2TablePrinter()
Construct a JTablePageable object (no JTable specified)


J2TablePrinter

public J2TablePrinter(javax.swing.JTable table)
Construct a JTablePageable object for a given JTable

Method Detail

dispose

public void dispose()
Release all heap objects held by this J2TablePrinter object, must not call until printing completes.

Overrides:
dispose in class J2Pageable

printFlowable

public void printFlowable(java.awt.Graphics g,
                          int availableWidth,
                          int availableHeight,
                          int nextFullPageWidth,
                          int nextFullPageHeight)
Description copied from interface: Flowable
Print the next sequential section of this Flowable object that fits into the next incremental area.

Parameters:
g - context into which the page is to be drawn (null means advance but don't actually print)
availableWidth - horizontal amount into which the next sequential amount of this Flowable is to be printed.
availableHeight - vertical amount into which the next sequential amount of this Flowable is to be printed.
nextFullPageWidth - horizontal size of next full page (lets Flowables decide whether to opt for next page).
nextFullPageHeight - vertical size of next full page (lets Flowables decide whether to opt for next page).

The above parameters specify a rectangular area of size width by height (height = down the page) in pixels (72 dpi printing "points"). A Flowable object is assumed to print in "raster" order (over then down). Assumes upon entry that translation and scale are already set up so that 0,0 is the upper left corner to print and width and height are already increased by the overall printer scale. Flowable object must return Graphics context translation and scale to values at entry if changed during printing. Upon return from printFlowable, the doneX, doneY, usedX, and usedY methods describe the resulting state of the Flowable, based on its ability to make progress. Return values of usedX and usedY are to be specified in same scale as availableWidth and availableHeight were given.


usedX

public int usedX()
Description copied from interface: Flowable
Returns the amount this Flowable object was able to advance horizontally in the last printFlowable call.


usedY

public int usedY()
Description copied from interface: Flowable
Returns the amount this Flowable object was able to advance vertically in the last printFlowable call.


doneX

public boolean doneX()
Description copied from interface: Flowable
Returns whether there is no more of this Flowable object to print horizontally.


doneY

public boolean doneY()
Description copied from interface: Flowable
Returns whether there is no more of this Flowable object to print vertically.


resetFlowable

public void resetFlowable()
Description copied from interface: Flowable
Reset the Flowable object so that it starts printing from the beginning.


prepareRenderer

public void prepareRenderer()
Utility method that calls prepareRenderer method for all cells in the current JTable. Call this method if you are using a custom TableCellRenderer and do not have your JTable displayed on the screen in order to ensure that cell dimensions are computed properly.


setTable

public void setTable(javax.swing.JTable table)
Specifies the JTable that will be printed.

Parameters:
table - the JTable that will be printed

getTable

public javax.swing.JTable getTable()
Returns the JTable containing the document that will be printed.


setColumnHeaderPrinting

public void setColumnHeaderPrinting(int columnHeaderPrinting)
Sets whether column headers printed on all pages, top pages, or no pages.

Parameters:
columnHeaderPrinting - J2TablePrinter.ALL_PAGES (default), TOP_PAGES, or NO_PAGES

getColumnHeaderPrinting

public int getColumnHeaderPrinting()
Returns current value of columnHeaderPrinting property.


setRowHeaderPrinting

public void setRowHeaderPrinting(int rowHeaderPrinting)
Sets whether row headers printed on all pages, left pages, or no pages.

Parameters:
rowHeaderPrinting - J2TablePrinter.ALL_PAGES (default), LEFT_PAGES, or NO_PAGES

getRowHeaderPrinting

public int getRowHeaderPrinting()
Returns current value of rowHeaderPrinting property.


setHorizontalAlignment

public void setHorizontalAlignment(int horizontalAlignment)
Sets the horizontal alignment (LEFT, CENTER, RIGHT) for printing the JTable on the page.

Parameters:
horizontalAlignment - J2TablePrinter.LEFT, .CENTER, or .RIGHT (default: CENTER)

getHorizontalAlignment

public int getHorizontalAlignment()
Returns horizontal alignment (LEFT, CENTER, RIGHT) of this JTable on page.


setVerticalAlignment

public void setVerticalAlignment(int verticalAlignment)
Sets the vertical alignment (TOP, CENTER, BOTTOM) for printing the JTable on the page.

Parameters:
verticalAlignment - J2TablePrinter.TOP, .CENTER, or .BOTTOM (default: TOP)

getVerticalAlignment

public int getVerticalAlignment()
Returns vertical alignment (TOP, CENTER, BOTTOM) of this JTable on page.


setOutsideLines

public void setOutsideLines(boolean showOutsideLines)
Sets whether to print outside gridlines around the JTable. This feature is necessary since by default, a Java JTable does not have leftmost or topmost gridlines. NOTE: to ensure that gridlines are drawn on all sides of the JTable subareas printed on each page, you also need to call setOverlap(true), which is the default.

Parameters:
showOutsideLines - true means print outside gridlines, false if not (default: true)

isOutsideLines

public boolean isOutsideLines()
Returns whether to print outside gridlines around the JTable.


setPrintArea

public void setPrintArea(int startColumnIndex,
                         int startRowIndex,
                         int numberOfPrintColumns,
                         int numberOfPrintRows)
Set the print area to be printed.

Parameters:
startColumnIndex - leftmost column (0...n-1) to print (if <=0 or past last col, use column 0).
startRowIndex - topmost row (0...n-1) to print (if <=0 or past last row, use row 0).
numberOfPrintColumns - number of columns to print (if <=0 or past last col, use rest of columns).
numberOfPrintRows - number of rows to print (if <=0 or past last row, use rest of rows).

setPrintArea

public void setPrintArea(java.awt.Rectangle rect)
Set the print area to be printed using a Rectangle.

Parameters:
rect - leftmost column (0...n-1), topmost row (0...n-1), number of columns, and number of rows that will be printed (if <0, use 0; if past last row/col, use last row/col).

getPrintArea

public java.awt.Rectangle getPrintArea()
Get the print area values set in the most recent setPrintArea call


setHorizontalPageRule

public void setHorizontalPageRule(int horizontalPageRule)
Sets the page rule for paginating the JTable horizontally, either SHRINK_TO_FIT, BREAK_ON_COLUMNS (default), or BREAK_ON_COLOR.

Parameters:
horizontalPageRule - desired page rule, recognized values are: J2TablePrinter.SHRINK_TO_FIT, .BREAK_ON_COLUMNS (the default), or .BREAK_ON_COLOR.

SHRINK_TO_FIT means shrink the JTable to fit within the remaining width left on the current page.

BREAK_ON_COLUMNS means determine the width of each JTable column and break the JTable on the rightmost column boundary that fits on the page.

BREAK_ON_COLOR means analyze the JTable to determine the rightmost boundary that fits the width of the page and whose pixel color values most closely match the specified horizontal break color. For example, break on table.getGridColor() is typical for printing tables.

For all pagination modes, MaximumPaginationGap determines when to start on a new page.

getHorizontalPageRule

public int getHorizontalPageRule()
Returns current value of pageRule property (SHRINK_TO_FIT, BREAK_ON_COLUMNS, or BREAK_ON_COLOR).


setVerticalPageRule

public void setVerticalPageRule(int verticalPageRule)
Sets the page rule for paginating the JTable vertically, either SHRINK_TO_FIT, BREAK_ON_ROWS (default), or BREAK_ON_COLOR.

Parameters:
verticalPageRule - desired page rule, recognized values are: J2TablePrinter.SHRINK_TO_FIT, .BREAK_ON_ROWS (the default), or .BREAK_ON_COLOR.

SHRINK_TO_FIT means shrink the JTable to fit within the remaining height left on the current page.

BREAK_ON_ROWS means determine the height of each JTable row and break the JTable on the bottommost row boundary that fits on the page.

BREAK_ON_COLOR means analyze the JTable to determine the bottommost boundary that fits the height of the page and whose pixel color values most closely match the specified vertical break color. For example, break on table.getGridColor() is typical for printing tables.

For all pagination modes, MaximumPaginationGap determines when to start on a new page.

getVerticalPageRule

public int getVerticalPageRule()
Returns current value of pageRule property (SHRINK_TO_FIT, BREAK_ON_ROWS, or BREAK_ON_COLOR).


setOverlap

public void setOverlap(boolean overlapEnabled)
Sets whether to repeat the last pixel row and column again on the next page when paginating. This is necessary to ensure that gridlines are drawn on all sides of the JTable rows and columns printed on each page.

Parameters:
overlapEnabled - true means print last pixel row and column again on next page when paginating (default: true)

isOverlap

public boolean isOverlap()
Returns whether to repeat the last pixel row and column again on the next page when paginating, which ensures that gridlines are drawn on all sides of the JTable rows and columns printed on each page.


setHorizontalBreakColor

public void setHorizontalBreakColor(java.awt.Color horizontalBreakColor)
Sets the break color to be used for BREAK_ON_COLOR pagination mode when breaking horizontally.


getHorizontalBreakColor

public java.awt.Color getHorizontalBreakColor()
Returns the Color used as break color for BREAK_ON_COLOR pagination mode when breaking horizontally.


setVerticalBreakColor

public void setVerticalBreakColor(java.awt.Color verticalBreakColor)
Sets the break color to be used for BREAK_ON_COLOR pagination mode when breaking vertically.


getVerticalBreakColor

public java.awt.Color getVerticalBreakColor()
Returns the Color used as break color for BREAK_ON_COLOR pagination mode when breaking vertically.


setMaximumPaginationGap

public void setMaximumPaginationGap(double maximumPaginationGap)
Sets the largest acceptable pagination gap as a percentage of the full body height/width. When a JTable row (column) is so large that it won't fit in the remaining space on a page, then skip to the next page if the remaining space is less than this value, otherwise split the row (column) over the page boundary.

Parameters:
maximumPaginationGap - The largest acceptable pagination gap as a percentage of the full body height/width. Must be less than 1.0 (will be set to 0.99 if a value 1.0 or greater is requested). A value of 0.0 means always split, never waste a pixel, close to 1.0 means OK to skip most of a page to keep content intact (default: 0.2).

getMaximumPaginationGap

public double getMaximumPaginationGap()
Returns largest acceptable pagination gap as a percentage of the full body height/width.


setAutomaticRecalculation

public void setAutomaticRecalculation(boolean automaticRecalculation)
Sets whether the BREAK_ON_ROWS (and BREAK_ON_COLUMNS) or BREAK_ON_COLOR internal data tables recompute automatically every time you print or print preview this JTable. These calcuations can be slow for large, multi-page JTables. By default, J2TablePrinter recalculates these tables automatically every time you display or print the JTable to take into account any properties of the JTable or its underlying TableModel that might have changed. By setting this value to false, this calculation will be performed only once when setTable is called. If you set this value to false, it becomes your obligation to call setTable every time your JTable or its underlying data changes.

Parameters:
automaticRecalculation - true means recalculate automatically every time you display or print this JTable, false means recalculate only once when setTable is called (default: true)

isAutomaticRecalculation

public boolean isAutomaticRecalculation()
Returns whether BREAK_ON_ROWS (or COLUMNS) and BREAK_ON_COLOR internal data tables recompute automatically every time you print or print preview this JTable.


setBreakOnColorIncrement

public void setBreakOnColorIncrement(int breakOnColorIncrement)
Sets the evaluation increment in pixels for BREAK_ON_COLOR mode. By default, the BREAK_ON_COLOR image analysis evaluates color values at every pixel, which ensures accurate pagination but can be slow for large multi-page JTables. Increasing this value to, for example, one in 10 pixels will result in much faster processing and will still generally produce accurate results, though raising it too high increases the risk of inaccurate pagination depending upon the exact contents of the JTable.

Parameters:
breakOnColorIncrement - causes BREAK_ON_COLOR to sample one in every breakOnColorIncrement pixels (default: 1)

getBreakOnColorIncrement

public int getBreakOnColorIncrement()
Returns the evaluation increment in pixels for BREAK_ON_COLOR mode.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener for this component

Overrides:
addPropertyChangeListener in class J2Pageable

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a PropertyChangeListener for this component

Overrides:
removePropertyChangeListener in class J2Pageable