public class TLcdGXYViewComponentPrintable extends ALcdViewComponentPrintable implements ILcdStatusSource
Component
containing a GXY view component
.
This view component is used to avoid changing the original view.
By default, the component is scaled to fit in the imageable part of the page. If the component
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
(setCropMarks(boolean)
, setPositioningMarks(boolean)
). The methods
getPageCountX
and
getPageCountY
allow to see
how many pages will be required.
There are two ways to define the number of pages printed.
usePageCount(int, int)
method: When using this method, this
class will try to use the number of pages specified. Because the aspect ratio of the view
component does not necessarily match the aspect ratio of the printable area on the pages,
it is possible that less pages are used.useMapScale(double)
method: When using this method, this class
will make sure the map scale is preserved by adjusting the number of pages.setOrigin(Point)
).
Note that the effects of rounding to integer AWT coordinates during painting may become more
obvious in print. The component's print
method
must never overwrite the transformation of the Graphics
using the
setTransform
method. Instead, it must always use relative transformation methods, such as
scale
.NO_SUCH_PAGE, PAGE_EXISTS
Constructor and Description |
---|
TLcdGXYViewComponentPrintable(Component aComponent)
Creates a new printable for the given component.
|
Modifier and Type | Method and Description |
---|---|
TLcdPrintPreview |
createPreview(PageFormat aPageFormat)
Creates a preview panel for the given page format.
|
static Component |
createViewComponent(ILcdGXYView aView,
ILcdFilter<ILcdGXYLayer> aLayerFilter)
Creates a Component representing the given view.
|
void |
dispose()
Cleans up
|
int |
getDPI()
Returns the rasterization quality in dpi.
|
double |
getFeatureScale()
Returns the relative size of features (such as icons, labels or line widths) in a view.
|
double |
getMapScale(PageFormat aPageFormat)
Returns the map scale (e.g.
1:25.000 ). |
Point |
getOrigin()
Returns the origin of the component on the page.
|
int |
getPageCountX(PageFormat aPageFormat)
Returns the page count in the x-direction.
|
int |
getPageCountY(PageFormat aPageFormat)
Returns the page count in the y-direction.
|
Printable |
getPageDecorator()
Returns the
Printable that is used as page decorator. |
ILcdBounds |
getPrintArea(PageFormat aPageFormat)
Returns the used printing area.
|
ILcdBounds |
getPrintAreaBounds()
Returns the print area bounds.
|
boolean |
hasCropMarks()
Returns whether crop marks are drawn on multi-page prints.
|
boolean |
hasPositioningMarks()
Returns whether positioning marks are drawn on multi-page prints.
|
void |
invalidate()
Invalidates this printable.
|
boolean |
isSnapToFullPages()
Returns if snap to full pages is used.
|
int |
print(Graphics aGraphics,
PageFormat aPageFormat,
int aPageIndex) |
void |
setCropMarks(boolean aCropMarks)
Specifies whether to draw crop marks on multi-page prints.
|
void |
setDPI(int aDPI)
Sets the rasterization quality in DPI.
|
void |
setFeatureScale(double aFeatureScale)
Changes the relative size of features (such as icons, labels or line widths) in a view.
|
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 |
setPrintAreaBounds(ILcdBounds aBounds)
Sets the bounds area to use when printing the view.
|
void |
setSnapToFullPages(boolean aUseSnapToFullPages)
Specifies weather the content should fill the entire pages.
|
void |
useMapScale(double aMapScale)
Sets the map scale to use when printing.
|
void |
usePageCount(int aPageCountX,
int aPageCountY)
Sets the number of pages in the x and y direction.
|
addChangeListener, addPropertyChangeListener, addStatusListener, fireChangeEvent, firePropertyChange, fireStatusEvent, getComponent, removeChangeListener, removePropertyChangeListener, removeStatusListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addStatusListener, removeStatusListener
close
public TLcdGXYViewComponentPrintable(Component aComponent)
aComponent
- the component to print. This component should contain a
view component. If not, an
exception is thrown.
The component does not have to be partpublic void dispose()
dispose
in interface ILcdDisposable
public static Component createViewComponent(ILcdGXYView aView, ILcdFilter<ILcdGXYLayer> aLayerFilter)
ILcdGXYView
stays the
same. If for example, layers are added/removed from the given ILcdGXYView
, or
if the scale/viewOrigin/worldOrigin/... changes, the component that is created in this method
will stay unchanged. In that case it is needed to recreate this component.aView
- the view for which to create a component.aLayerFilter
- a filter that determines which layers are printed. Can be null
.public void usePageCount(int aPageCountX, int aPageCountY)
useMapScale(double)
method should be used. When calling useMapScale(double)
after this method was called, this method will have no effect.
Note that after calling this method, getPageCountX
and getPageCountY
may
differ from aPageCountX
and aPageCountY
. This is because the aspect
ratio of the view component is most likely not the same as the aspect ratio of the
pages.aPageCountX
- the page count in the x direction.aPageCountY
- the page count in the y direction.useMapScale(double)
public void useMapScale(double aMapScale)
usePageCount(int, int)
method should be used. When calling usePageCount(int,
int)
after this method was called, this method will have no effect.aMapScale
- the map scale to use when printing.public void invalidate()
getComponent()
, or when a component was resized.public ILcdBounds getPrintArea(PageFormat aPageFormat)
aPageFormat
- the page format.public int getPageCountX(PageFormat aPageFormat)
ALcdViewComponentPrintable
getPageCountX
in class ALcdViewComponentPrintable
aPageFormat
- the page formatpublic int getPageCountY(PageFormat aPageFormat)
ALcdViewComponentPrintable
getPageCountY
in class ALcdViewComponentPrintable
aPageFormat
- the page formatpublic double getMapScale(PageFormat aPageFormat)
ALcdViewComponentPrintable
1:25.000
).getMapScale
in class ALcdViewComponentPrintable
aPageFormat
- the page formatpublic void setPrintAreaBounds(ILcdBounds aBounds)
getPrintArea(PageFormat)
method.
When setting this value to null
, the view extents of the printed view area
used instead.
The default is null
.aBounds
- the print area bounds in world coordinates.getPrintAreaBounds()
,
getPrintArea(java.awt.print.PageFormat)
public ILcdBounds getPrintAreaBounds()
setPrintAreaBounds(com.luciad.shape.ILcdBounds)
,
getPrintArea(java.awt.print.PageFormat)
public void setSnapToFullPages(boolean aUseSnapToFullPages)
true
.aUseSnapToFullPages
- true
to specify that the content should fill the entire
pages.isSnapToFullPages()
public boolean isSnapToFullPages()
setSnapToFullPages(boolean)
public void setDPI(int aDPI)
144
.aDPI
- the rasterization quality in dpi.getDPI()
public int getDPI()
getDPI
in class ALcdViewComponentPrintable
setDPI(int)
public void setFeatureScale(double aFeatureScale)
Lower values will make features proportionally smaller (allowing, for instance, more labels to be placed). Higher values will make features proportionally larger (for instance, to make text more readable on very high-resolution displays).
Feature scale may also affect level-of-detail decisions, e.g. for raster layers. Lower feature scales may cause higher detail levels to be shown (and vice versa).
A possible use case is printing a complex CAD drawing, where you would like to reduce the
line widths to get a detailed print-out. Use for example 0.25
. Another use case
is to make a print-out that will be looked at from a distance. A larger value (e.g.
2.0
) makes sure the lines are still visible from a distance.
aFeatureScale
- the size factor for line widths, icons sizes, font sizes ...getFeatureScale()
public double getFeatureScale()
Lower values will make features proportionally smaller (allowing, for instance, more labels to be placed). Higher values will make features proportionally larger (for instance, to make text more readable on very high-resolution displays).
Feature scale may also affect level-of-detail decisions, e.g. for raster layers. Lower feature scales may cause higher detail levels to be shown (and vice versa).
A possible use case is printing a complex CAD drawing, where you would like to reduce the
line widths to get a detailed print-out. Use for example 0.25
. Another use case
is to make a print-out that will be looked at from a distance. A larger value (e.g.
2.0
) makes sure the lines are still visible from a distance.
getFeatureScale
in class ALcdViewComponentPrintable
setFeatureScale(double)
public void setCropMarks(boolean aCropMarks)
true
.aCropMarks
- true
to draw crop marks on multi-page prints.public boolean hasCropMarks()
public void setPositioningMarks(boolean aPositioningMarks)
true
.aPositioningMarks
- true
to draw positioning marks on multi-page prints.public boolean hasPositioningMarks()
public void setOrigin(Point aOrigin)
null
, meaning that
the component is automatically centered on the page. This setting is mostly useful when
disabling snap to full pages.aOrigin
- the origin, or null
.public Point getOrigin()
null
.setOrigin(Point)
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 int print(Graphics aGraphics, PageFormat aPageFormat, int aPageIndex) throws PrinterException
print
in interface Printable
PrinterException
public TLcdPrintPreview createPreview(PageFormat aPageFormat)
createPreview
in class ALcdViewComponentPrintable
aPageFormat
- the page format to use