public class TLcdComponentPrintable extends Object implements Printable, ILcdChangeSource
Component
.Component
containing an ILcdView
, consider using an ALcdViewComponentPrintable
.
By default, the component is scaled to fit in the imageable part of the page.
Alternatively, the scale of the component on the printer graphics can be
specified explicitly (
). If the
component then no longer fits on a single page, a multi-page print is
created, with optional crop marks and positioning marks indicating where and
how the pages should be joined (setScale(double)
,
setCropMarks(boolean)
). The method setPositioningMarks(boolean)
pageCount(PageFormat)
allows to see how many pages will be required.
By default, the component is centered on the page or the set of pages.
Alternatively, its position can also be set explicitly
(
).
setOrigin(Point)
By default, a border is drawn around the component, but this can be switched
off (setBorder(boolean)
).
This class offers a regular printing mode, a rasterized printing mode, and a layered printing mode:
setRasterizedLayerQualityFactor(double)
),
and using strips whose maximum size can be configured
(see setRasterizedLayerMaximumStripSize(int)
). The size of the
strips provides a way to trade off the memory and the processing time
that are required by the print method. Smaller strips require less memory,
while larger strips require fewer painting passes and therefore less
processing time.
setRasterizedRendering(boolean)
and
setLayeredRendering(boolean)
).
Note that the effects of rounding to integer AWT coordinates during
painting may become more obvious in print. The component's
method must never overwrite the
transformation of the print
Graphics
using the
method.
Instead, it must always use relative transformation methods, such as
setTransform
.
scale
Notes:
NO_SUCH_PAGE, PAGE_EXISTS
Constructor and Description |
---|
TLcdComponentPrintable(Component aComponent)
Creates a new TLcdComponentPrintable for printing the given Component.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ILcdChangeListener aListener)
Registers the given listener so it will receive change events from this source.
|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Add a PropertyChangeListener to the listener list.
|
TLcdPrintPreview |
createPreview(PageFormat aPageFormat)
Creates a preview panel for the given page format.
|
protected void |
fireChangeEvent(TLcdChangeEvent aEvent)
Fire an existing TLcdChangeEvent to any registered listeners.
|
protected void |
firePropertyChange(PropertyChangeEvent aEvent)
Fire an existing PropertyChangeEvent to any registered listeners.
|
boolean |
getBorder()
Returns whether a border is drawn around the component.
|
Component |
getComponent()
Returns the component to be printed.
|
boolean |
getCropMarks()
Returns whether crop marks are drawn on multi-page prints.
|
boolean |
getForceLayeredRendering()
Returns whether layered rendering is forced.
|
boolean |
getLayeredRendering()
Returns whether layered rendering is enabled.
|
Point |
getOrigin()
Returns the origin of the component on the page.
|
Printable |
getPageDecorator()
Returns the
Printable that is used as page decorator. |
boolean |
getPositioningMarks()
Returns whether positioning marks are drawn on multi-page prints.
|
int |
getRasterizedLayerMaximumStripSize()
Returns the maximum number of pixels in a strip of the rasterized layer.
|
double |
getRasterizedLayerQualityFactor()
Returns the quality factor for the rasterized layer.
|
boolean |
getRasterizedRendering()
Returns whether rasterized rendering is enabled.
|
double |
getScale()
Returns the scale of the component on the page.
|
Point |
pageCount(PageFormat aPageFormat)
Returns the number of pages in the x direction and y direction, if the
component is printed with the current settings on the given page format.
|
int |
print(Graphics aGraphics,
PageFormat aPageFormat,
int aPageIndex) |
void |
removeChangeListener(ILcdChangeListener aListener)
Removes the specified listener so it is no longer notified.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
Remove a PropertyChangeListener from the listener list.
|
void |
setBorder(boolean aBorder)
Specifies whether to draw a border around the component.
|
void |
setComponent(Component aComponent)
Sets the component to be printed.
|
void |
setCropMarks(boolean aCropMarks)
Specifies whether to draw crop marks on multi-page prints.
|
void |
setForceLayeredRendering(boolean aForceLayeredRendering)
Specifies whether to force layered rendering, rather than only using it
when necessary.
|
void |
setLayeredRendering(boolean aLayeredRendering)
Specifies whether to use layered rendering, when necessary.
|
void |
setOrigin(Point aOrigin)
Sets the origin of the component on the page.
|
void |
setPageDecorator(Printable aPageDecorator)
Sets a
Printable that can be used to decorate each page. |
void |
setPositioningMarks(boolean aPositioningMarks)
Specifies whether to draw positioning marks on multi-page prints.
|
void |
setRasterizedLayerMaximumStripSize(int aRasterizedLayerMaximumStripSize)
Sets the maximum number of pixels in a strip of the rasterized layer.
|
void |
setRasterizedLayerQualityFactor(double aRasterizedLayerQualityFactor)
Sets the quality factor for the rasterized layer.
|
void |
setRasterizedRendering(boolean aRasterizedRendering)
Specifies whether to use rasterized rendering, when necessary.
|
void |
setScale(double aScale)
Sets the scale of the component on the page.
|
public TLcdComponentPrintable(Component aComponent)
aComponent
- the component for which to create a Printable
public void addPropertyChangeListener(PropertyChangeListener aListener)
aListener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(PropertyChangeListener aListener)
aListener
- The PropertyChangeListener to be removedprotected void firePropertyChange(PropertyChangeEvent aEvent)
aEvent
- The PropertyChangeEvent object.public void addChangeListener(ILcdChangeListener aListener)
ILcdChangeSource
Registers the given listener so it will receive change events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source,
you can use a ALcdWeakChangeListener
instance as change listener.
addChangeListener
in interface ILcdChangeSource
aListener
- The listener to be notified when a change has happened.ILcdChangeSource.removeChangeListener(ILcdChangeListener)
,
ALcdWeakChangeListener
public void removeChangeListener(ILcdChangeListener aListener)
ILcdChangeSource
removeChangeListener
in interface ILcdChangeSource
aListener
- The listener to remove.protected void fireChangeEvent(TLcdChangeEvent aEvent)
aEvent
- The TLcdChangeEvent object.public void setComponent(Component aComponent)
aComponent
- the component to be printed.public Component getComponent()
setComponent(Component)
public void setOrigin(Point aOrigin)
null
, meaning that the component is automatically centered
on the page.aOrigin
- the origin of the component on the page.public Point getOrigin()
setOrigin(Point)
public void setScale(double aScale)
aScale
- the scale of the component on the page.public double getScale()
setScale(double)
public void setBorder(boolean aBorder)
true
.aBorder
- true
to draw a border around the component.public boolean getBorder()
public void setCropMarks(boolean aCropMarks)
true
.aCropMarks
- true
to draw crop marks on multi-page prints.public boolean getCropMarks()
public void setPositioningMarks(boolean aPositioningMarks)
true
.aPositioningMarks
- true
to draw positioning marks on multi-page prints.public boolean getPositioningMarks()
public void setRasterizedRendering(boolean aRasterizedRendering)
aRasterizedRendering
- true
to use rasterized rendering.public boolean getRasterizedRendering()
setRasterizedRendering(boolean)
public void setLayeredRendering(boolean aLayeredRendering)
aLayeredRendering
- true
to use layered rendering.public boolean getLayeredRendering()
setLayeredRendering(boolean)
public void setForceLayeredRendering(boolean aForceLayeredRendering)
aForceLayeredRendering
- true
to force layered rendering.public boolean getForceLayeredRendering()
setForceLayeredRendering(boolean)
public void setRasterizedLayerQualityFactor(double aRasterizedLayerQualityFactor)
aRasterizedLayerQualityFactor
- the quality factor for the rasterized layer.public double getRasterizedLayerQualityFactor()
setRasterizedLayerQualityFactor(double)
public void setRasterizedLayerMaximumStripSize(int aRasterizedLayerMaximumStripSize)
aRasterizedLayerMaximumStripSize
- the maximum number of pixels in a strip of the rasterized layer.public int getRasterizedLayerMaximumStripSize()
setRasterizedLayerMaximumStripSize(int)
public void setPageDecorator(Printable aPageDecorator)
Sets a Printable
that can be used to decorate each page. It is for example
possible to add a watermark to each page using this method.
The default is null
, meaning that no decorations are added.
aPageDecorator
- the page decorator.public Printable getPageDecorator()
Printable
that is used as page decorator.Printable
that is used as page decorator.public Point pageCount(PageFormat aPageFormat)
aPageFormat
- the page format for which the page count is calculatedpublic TLcdPrintPreview createPreview(PageFormat aPageFormat)
aPageFormat
- the page format to usepublic int print(Graphics aGraphics, PageFormat aPageFormat, int aPageIndex)