com.miginfocom.util.print
Class PrintPainter

java.lang.Object
  extended by com.miginfocom.util.print.PrintPainter
All Implemented Interfaces:
java.lang.Comparable

public abstract class PrintPainter
extends java.lang.Object
implements java.lang.Comparable

A painter that is to be used in a printing context. Might for instance be used to decorate the DateAreaContainer with titles, footers, headers, a legend or a custom border. NOTE! If layer index is > 100 the graphics will be painted above the "printable", therwise it will be painted below and might be invisible!


Constructor Summary
protected PrintPainter()
           
protected PrintPainter(int layerIndex)
          Constructor.
 
Method Summary
 int compareTo(java.lang.Object o)
          Sorts according to layerIndex.
 int getLayerIndex()
          Property: The layerIndex that this panter will paint in.
abstract  void paint(java.awt.Graphics2D g, java.awt.print.PageFormat pf, java.awt.geom.Rectangle2D printableBounds, java.awt.Point currentPage, java.awt.Dimension pageCount)
          Called by the Printable implementation to normally "decorate" the prntable object with borders, titles, legends and such.
 void setLayerIndex(int layerIndex)
          Property: The layerIndex that this panter will paint in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintPainter

protected PrintPainter()

PrintPainter

protected PrintPainter(int layerIndex)
Constructor.

Parameters:
layerIndex - The layerIndex that this panter will paint in. Lower values are panted before (under) other layers. The "printable" will be painted in layerIndex 100. NOTE! If layer index is > 100 the graphics will be painted above the "printable", therwise it will be painted below and might be invisible!
Method Detail

getLayerIndex

public int getLayerIndex()
Property: The layerIndex that this panter will paint in. Lower values are panted before (under) other layers. The "printable" will be painted in layerIndex 100.

NOTE! If layer index is > 100 the graphics will be painted above the "printable", therwise it will be painted below and might be invisible!

Returns:
The current layer. Default is 200.

setLayerIndex

public void setLayerIndex(int layerIndex)
Property: The layerIndex that this panter will paint in. Lower values are panted before (under) other layers. The "printable" will be painted in layerIndex 100.

Parameters:
layerIndex - The new layer. Default is 200.

compareTo

public int compareTo(java.lang.Object o)
Sorts according to layerIndex.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Another PrintPainter
Returns:
getLayerIndex() - ((PrintPainter) o).getLayerIndex().

paint

public abstract void paint(java.awt.Graphics2D g,
                           java.awt.print.PageFormat pf,
                           java.awt.geom.Rectangle2D printableBounds,
                           java.awt.Point currentPage,
                           java.awt.Dimension pageCount)
Called by the Printable implementation to normally "decorate" the prntable object with borders, titles, legends and such.

Note that it is easy to get the total bounds of the whole paintable area and/or the current page's bounds from the PageFormat using pf.getImagagableX(), pf.getImagagableY(), pf.getImagagableWidth() and pf.getImagagableHeight().

Bounds for current page:
new Rectangle2D.Double(pf.getImageableX(), pf.getImageableY(), pf.getImageableWidth(), pf.getImageableHeight()

Bounds for whole imageable area:
new Rectangle2D.Double(pf.getImageableX() - p.x * pf.getImageableWidth(), pf.getImageableY() - p.y * pf.getImageableHeight(), pf.getImageableWidth() * dim.getWidth(), pf.getImageableHeight() * dim.getHeight()

Parameters:
g - The graphics object to paint in. Will have clip set to printableBounds. The coordinate system has it origin in the current page that is printed.
pf - The type of page that is printed to.
printableBounds - The bounds of the printable.
currentPage - The current page that is printed. Zero based.
pageCount - The total number of pages in both directions.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.