com.miginfocom.util.print
Class PrintSpecification

java.lang.Object
  extended by com.miginfocom.util.print.PrintSpecification
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
PrintSpecificationBean

public class PrintSpecification
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This is a specification on how to place something (a component normally) on one or more papers during printing.

There is a JavaBean implmentation of this class here: PrintSpecificationBean.

Since:
6.0
See Also:
Serialized Form

Constructor Summary
PrintSpecification()
          Empty constructor.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Transfer to addChangeListener(ChangeListener, boolean) with false for as>WeakRef.
 void addChangeListener(javax.swing.event.ChangeListener l, boolean asWeakRef)
          Add a listener that listens for any changes in the properties for this grid, as well as the GridRows it contains.
 void addPrintPainter(PrintPainter painter)
          Adds a PrintPainter that can be used to decorate the printable and/or the pages that are printed.
 java.lang.Object clone()
           
 boolean equals(java.lang.Object o)
           
 AtRefRangeNumber getAlignX()
          Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from setPlaceRectangle(com.miginfocom.util.gfx.geometry.PlaceRect).
 AtRefRangeNumber getAlignY()
          Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from setPlaceRectangle(com.miginfocom.util.gfx.geometry.PlaceRect).
 java.lang.Integer getPageCountX()
          Property: The number of horizontal pages to print over.
 java.lang.Integer getPageCountY()
          Property: The number of vertical pages to print over.
 PlaceRect getPagePlaceRectangle()
          Property: A place rect that can be used to for every page reduce the printable area.
 PlaceRect getPlaceRectangle()
          Property: Given the X by Y number of pages those pages makes out a printable area when combined and all the margins are removed.
 java.lang.Double getPrintableAspectRatio()
          Property: The forced ratio (width/height) that the printable should be scaled to fir.
 java.util.List getPrintPainters()
          Property: A List of PrintPainters that can be used to decorate the printed pages.
 boolean getStretchToFit()
          Property: If the printableAspectRatio is not set to a specific value this propery specifies if the "printable" is to be streched over the availble space.
 void invokePainters(java.awt.Graphics2D g, java.awt.print.PageFormat pf, java.awt.geom.Rectangle2D printableBounds, java.awt.Point currentPage, java.awt.Dimension pageCount, boolean isBeforePrintable)
          Helper method that is not to be used by client code!
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes the listener, if it is in the list.
 boolean removePrintPainter(PrintPainter painter)
          Removes the PrintPainter.
 void setAlignX(AtRefRangeNumber align)
          Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from setPlaceRectangle(com.miginfocom.util.gfx.geometry.PlaceRect).
 void setAlignY(AtRefRangeNumber align)
          Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from or bottom of the printable.
 void setPageCountX(java.lang.Integer count)
          Property: The number of horizontal pages to print over.
 void setPageCountY(java.lang.Integer count)
          Property: The number of vertical pages to print over.
 void setPagePlaceRectangle(PlaceRect r)
          Property: A place rect that can be used to for every page reduce the printable area.
 void setPlaceRectangle(PlaceRect r)
          Property: Given the X by Y number of pages those pages makes out a printable area when combined and all the margins are removed.
 void setPrintableAspectRatio(java.lang.Double ratio)
          Property: The forced ratio (width/height) that the printable should be scaled to fir.
 void setPrintPainters(java.util.List painters)
          Property: A List of PrintPainters that can be used to decorate the printed pages.
 void setStretchToFit(boolean b)
          Property: If the printableAspectRatio is not set to a specific value this propery specifies if the "printable" is to be streched over the availble space.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintSpecification

public PrintSpecification()
Empty constructor.

Method Detail

getStretchToFit

public boolean getStretchToFit()
Property: If the printableAspectRatio is not set to a specific value this propery specifies if the "printable" is to be streched over the availble space. If it is the aspect ratio will be set to match that of to the available space. If not the aspect ration will be the natural aspect ratio of the printable. If this property is true neither alignX nor alignY will have any meaning since it will be no extra space to place.

Returns:
If set.

setStretchToFit

public void setStretchToFit(boolean b)
Property: If the printableAspectRatio is not set to a specific value this propery specifies if the "printable" is to be streched over the availble space. If it is the aspect ration will be set to match that of to the available space. If not the aspect ration will be the natural aspect ratio of the printable. If this property is true neither alignX nor alignY will have any meaning since it will be no extra space to place.

Parameters:
b - The new value.

getPageCountX

public java.lang.Integer getPageCountX()
Property: The number of horizontal pages to print over. If null the value will be calculated from the vertical pages and the aspect ratio of the printable so that the least number of horozotal pages are used to fit the printable in the specified height.

Returns:
The current value.

setPageCountX

public void setPageCountX(java.lang.Integer count)
Property: The number of horizontal pages to print over. If null the value will be calculated from the vertical pages and the aspect ratio of the printable so that the least number of horozotal pages are used to fit the printable in the specified height.

Parameters:
count - The new value. May be null.

getPageCountY

public java.lang.Integer getPageCountY()
Property: The number of vertical pages to print over. If null the value will be calculated from the horizontal pages and the aspect ratio of the printable so that the least number of vertical pages are used to fit the printable in the specified width.

Returns:
The current value.

setPageCountY

public void setPageCountY(java.lang.Integer count)
Property: The number of vertical pages to print over. If null the value will be calculated from the horizontal pages and the aspect ratio of the printable so that the least number of vertical pages are used to fit the printable in the specified width.

Parameters:
count - The new value. May be null.

getPrintableAspectRatio

public java.lang.Double getPrintableAspectRatio()
Property: The forced ratio (width/height) that the printable should be scaled to fir. If the value is null the ration will be that of the original printable.

Returns:
The current value.

setPrintableAspectRatio

public void setPrintableAspectRatio(java.lang.Double ratio)
Property: The forced ratio (width/height) that the printable should be scaled to fir. If the value is null the ration will be that of the original printable.

Parameters:
ratio - The new value. May be null.

getPlaceRectangle

public PlaceRect getPlaceRectangle()
Property: Given the X by Y number of pages those pages makes out a printable area when combined and all the margins are removed. This PlaceRect gives a very flexible way to reduce that target area to effectively place the printable somewhere in the area.

Can for instance be used to make room for titles and/or a single header/footer.

Returns:
The current value. May be null.
See Also:
AbsRect, AspectRatioRect, AlignRect

setPlaceRectangle

public void setPlaceRectangle(PlaceRect r)
Property: Given the X by Y number of pages those pages makes out a printable area when combined and all the margins are removed. This PlaceRect gives a very flexible way to reduce that target area to effectively place the printable somewhere in the area.

Can for instance be used to make room for titles and/or a single header/footer.

Parameters:
r - The new value. May be null.
See Also:
AbsRect, AspectRatioRect, AlignRect

getPagePlaceRectangle

public PlaceRect getPagePlaceRectangle()
Property: A place rect that can be used to for every page reduce the printable area. This can for instance be used to make room for per-page headers and footers.

Another use for this is to increase or decrease the margins of the PageFormat's Paper.

Returns:
The current value. May be null.
See Also:
AbsRect, AspectRatioRect, AlignRect

setPagePlaceRectangle

public void setPagePlaceRectangle(PlaceRect r)
Property: A place rect that can be used to for every page reduce the printable area. This can for instance be used to make room for per-page headers and footers.

Another use for this is to increase or decrease the margins of the PageFormat's Paper.

Parameters:
r - The new value. May be null.
See Also:
AbsRect, AspectRatioRect, AlignRect

getAlignX

public AtRefRangeNumber getAlignX()
Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from setPlaceRectangle(com.miginfocom.util.gfx.geometry.PlaceRect). If that resulting area does not have the same aspect ratio as the printable there will be empty space to the right or bottom of the printable. This property can be used to place the printable within the resulting rectangle and thus decide where the empty space should be.

Note that this property will only be used if there are empty space to the right of the printable (e.g. the aspect ration of the printable is lower than the aspect ration of the resulting target area.

Returns:
The current value.
See Also:
AtStart, AtEnd, AtFraction

setAlignX

public void setAlignX(AtRefRangeNumber align)
Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from setPlaceRectangle(com.miginfocom.util.gfx.geometry.PlaceRect). If that resulting area does not have the same aspect ratio as the printable there will be empty space to the right or bottom of the printable. This property can be used to place the printable within the resulting rectangle and thus decide where the empty space should be.

Note that this property will only be used if there are empty space to the right of the printable (e.g. the aspect ratio of the printable is lower than the aspect ratio of the resulting target area.

Parameters:
align - The new value. May be null.
See Also:
AtStart, AtEnd, AtFraction

getAlignY

public AtRefRangeNumber getAlignY()
Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from setPlaceRectangle(com.miginfocom.util.gfx.geometry.PlaceRect). If that resulting area does not have the same aspect ratio as the printable there will be empty space to the right or bottom of the printable. This property can be used to place the printable within the resulting rectangle and thus decide where the empty space should be.

Note that this property will only be used if there are empty space to the bottom of the printable (e.g. the aspect ratio of the printable is higher than the aspect ratio of the resulting target area.

Returns:
The current value.
See Also:
AtStart, AtEnd, AtFraction

setAlignY

public void setAlignY(AtRefRangeNumber align)
Property: The "printable" will be placed in the rectangle made out by the total printable area reduced by the PlaceRect returned from or bottom of the printable. This property can be used to place the printable within the resulting rectangle and thus decide where the empty space should be.

Note that this property will only be used if there are empty space to the bottom of the printable (e.g. the aspect ratio of the printable is higher than the aspect ratio of the resulting target area.

Parameters:
align - The new value. May be null.
See Also:
AtStart, AtEnd, AtFraction

getPrintPainters

public java.util.List getPrintPainters()
Property: A List of PrintPainters that can be used to decorate the printed pages.

Returns:
The current list, cloned and never null.
See Also:
addPrintPainter(PrintPainter)

setPrintPainters

public void setPrintPainters(java.util.List painters)
Property: A List of PrintPainters that can be used to decorate the printed pages.

Parameters:
painters - A new list of PrintPainters. Will be cloned and may be null.
See Also:
addPrintPainter(PrintPainter)

addPrintPainter

public void addPrintPainter(PrintPainter painter)
Adds a PrintPainter that can be used to decorate the printable and/or the pages that are printed. They can for instance be used to paint footers, headers, borders around the printable, legends or titles.

The printable will be painted in layer index 100, so any layer index below that will be painter under the printable and may be obscured.

Parameters:
painter - The painter. Not null.

removePrintPainter

public boolean removePrintPainter(PrintPainter painter)
Removes the PrintPainter.

Parameters:
painter - The painter to remove.
Returns:
If it was found and thus removed.

invokePainters

public void invokePainters(java.awt.Graphics2D g,
                           java.awt.print.PageFormat pf,
                           java.awt.geom.Rectangle2D printableBounds,
                           java.awt.Point currentPage,
                           java.awt.Dimension pageCount,
                           boolean isBeforePrintable)
Helper method that is not to be used by client code!


equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Transfer to addChangeListener(ChangeListener, boolean) with false for as>WeakRef.

Parameters:
l - The listener.

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l,
                              boolean asWeakRef)
Add a listener that listens for any changes in the properties for this grid, as well as the GridRows it contains. The source can be checked to see if the property is from the grid or from a grid row.

Parameters:
l - The listener.
asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes the listener, if it is in the list.

Parameters:
l - The listener to remove, not null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.