lt.monarch.print
Class AbstractPrintable

java.lang.Object
  extended by lt.monarch.print.AbstractPrintable
All Implemented Interfaces:
java.awt.print.Printable, PrintableConstants
Direct Known Subclasses:
ChartPrintable, ComponentPrintable

public abstract class AbstractPrintable
extends java.lang.Object
implements java.awt.print.Printable, PrintableConstants

Base class for implementations of Printable. Provides public methods and protected variables for managing scaling and alignment of printout.


Field Summary
Modifier and Type Field and Description
protected  HeaderFooterRenderer headerFooterRenderer
          Stores reference to header/footer renderer.
protected  int horizontalAlignment
          Stores value of horizontal alignment property.
protected  int lastValidPageIndex
          Last valid index of print page.
protected  double scaligFactorSpecified
          Stores specified scaling factor.
protected  int scalingFitToPagesGridCols
          Stores specified number of columns of grid of pages used for fitting.
protected  int scalingFitToPagesGridRows
          Stores specified number of rows of grid of pages used for fitting.
protected  int scalingMode
          Stores value of scaling mode property.
protected  int verticalAlignment
          Stores value of vertical alignment property.
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface lt.monarch.print.PrintableConstants
ALIGNMENT_BOTTOM, ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP, SCALING_FACTOR_SPECIFIED, SCALING_FIT_TO_PAGES
 
Constructor Summary
Constructor and Description
AbstractPrintable()
           
 
Method Summary
Modifier and Type Method and Description
 void dispose()
          This method must be invoked after printing is finished and instance of subclass of AbstractPrintable is not necessary anymore.
 HeaderFooterRenderer getHeaderFooterRenderer()
          Returns assigned renderer of headers and footers.
 void setHeaderFooterRenderer(HeaderFooterRenderer headerFooterRenderer)
          Assigns the renderer of headers and footers.
 void setHorizontalAlignment(int alignment)
          Sets horizontal alignment of printout in printable area of page or grid of pages.
 void setScalingFactorSpecified(double factor)
          The printout will be scaled using specified scaling factor, if the scaling mode is set as PrintableConstants.SCALING_FACTOR_SPECIFIED (using the setScalingMode(int) method).
 void setScalingFitToPagesGrid(int rows, int cols)
          Defines number of rows and columns in the grid of pages, which is used, if the scaling mode is set as PrintableConstants.SCALING_FIT_TO_PAGES (using the setScalingMode(int) method).
 void setScalingMode(int mode)
          Defines which scaling mode should be used for printing.
 void setVerticalAlignment(int alignment)
          Sets vertical alignment of printout in printable area of page or grid of pages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.print.Printable
print
 

Field Detail

scalingMode

protected int scalingMode
Stores value of scaling mode property.


scaligFactorSpecified

protected double scaligFactorSpecified
Stores specified scaling factor.


scalingFitToPagesGridRows

protected int scalingFitToPagesGridRows
Stores specified number of rows of grid of pages used for fitting.


scalingFitToPagesGridCols

protected int scalingFitToPagesGridCols
Stores specified number of columns of grid of pages used for fitting.


horizontalAlignment

protected int horizontalAlignment
Stores value of horizontal alignment property.


verticalAlignment

protected int verticalAlignment
Stores value of vertical alignment property.


lastValidPageIndex

protected int lastValidPageIndex
Last valid index of print page. Initially set to 0. Intended to be used and recalculated in implementation of print method.


headerFooterRenderer

protected HeaderFooterRenderer headerFooterRenderer
Stores reference to header/footer renderer.

Constructor Detail

AbstractPrintable

public AbstractPrintable()
Method Detail

setScalingMode

public void setScalingMode(int mode)
Defines which scaling mode should be used for printing. See descriptions of PrintableConstants.SCALING_XXX constants.

Parameters:
mode - the constant indicating scaling mode. Possible values are:
  • PrintableConstants.SCALING_FACTOR_SPECIFIED (default),
  • PrintableConstants.SCALING_FIT_TO_PAGES.

setScalingFactorSpecified

public void setScalingFactorSpecified(double factor)
The printout will be scaled using specified scaling factor, if the scaling mode is set as PrintableConstants.SCALING_FACTOR_SPECIFIED (using the setScalingMode(int) method). Default value of user-specified scaling factor is 1.0d and view is printed at 100% normal size.

Parameters:
factor - desired scaling factor.

setScalingFitToPagesGrid

public void setScalingFitToPagesGrid(int rows,
                                     int cols)
Defines number of rows and columns in the grid of pages, which is used, if the scaling mode is set as PrintableConstants.SCALING_FIT_TO_PAGES (using the setScalingMode(int) method). In this case the printout is scaled to fit printable area of [rows x cols] pages layouted in a grid. By default [1 x 1] grid of pages (i.e. one page) is used.

Parameters:
rows - positive non-zero value meaning number of rows in grid of pages.
cols - positive non-zero value meaning number of columns in grid of pages.

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Sets horizontal alignment of printout in printable area of page or grid of pages.

Parameters:
alignment - constant indicating horizontal alignment. Possible values are:
  • PrintableConstants.ALIGNMENT_LEFT (default),
  • PrintableConstants.ALIGNMENT_CENTER,
  • PrintableConstants.ALIGNMENT_RIGHT.

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Sets vertical alignment of printout in printable area of page or grid of pages.

Parameters:
alignment - constant indicating vertical alignment. Possible values are:
  • PrintableConstants.ALIGNMENT_TOP (default),
  • PrintableConstants.ALIGNMENT_CENTER,
  • PrintableConstants.ALIGNMENT_BOTTOM.

setHeaderFooterRenderer

public void setHeaderFooterRenderer(HeaderFooterRenderer headerFooterRenderer)
Assigns the renderer of headers and footers.

Parameters:
headerFooterRenderer - renderer of headers and footers.

getHeaderFooterRenderer

public HeaderFooterRenderer getHeaderFooterRenderer()
Returns assigned renderer of headers and footers.

Returns:
renderer of headers and footers.

dispose

public void dispose()
This method must be invoked after printing is finished and instance of subclass of AbstractPrintable is not necessary anymore. Subclasses should override this method to add functionality if necessary.