Class TLcdGXYViewComponentPrintable
- All Implemented Interfaces:
ILcdChangeSource
,ILcdDisposable
,ILcdStatusSource
,Printable
,AutoCloseable
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.
- By calling the
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. - By calling the
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
.- Since:
- 2013.0
-
Field Summary
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
Constructor Summary
ConstructorDescriptionTLcdGXYViewComponentPrintable
(Component aComponent) Creates a new printable for the given component. -
Method Summary
Modifier and TypeMethodDescriptioncreatePreview
(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 upint
getDPI()
Returns the rasterization quality in dpi.double
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
).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.Returns thePrintable
that is used as page decorator.getPrintArea
(PageFormat aPageFormat) Returns the used printing area.Returns the print area bounds.boolean
Returns whether crop marks are drawn on multi-page prints.boolean
Returns whether positioning marks are drawn on multi-page prints.void
Invalidates this printable.boolean
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
Sets the origin of the component on the page.void
setPageDecorator
(Printable aPageDecorator) Sets aPrintable
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.Methods inherited from class com.luciad.view.swing.ALcdViewComponentPrintable
addChangeListener, addPropertyChangeListener, addStatusListener, fireChangeEvent, firePropertyChange, fireStatusEvent, getComponent, removeChangeListener, removePropertyChangeListener, removeStatusListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdDisposable
close
Methods inherited from interface com.luciad.util.ILcdStatusSource
addStatusListener, removeStatusListener
-
Constructor Details
-
TLcdGXYViewComponentPrintable
Creates a new printable for the given component.- Parameters:
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 part
-
-
Method Details
-
dispose
public void dispose()Cleans up- Specified by:
dispose
in interfaceILcdDisposable
-
createViewComponent
public static Component createViewComponent(ILcdGXYView aView, ILcdFilter<ILcdGXYLayer> aLayerFilter) Creates a Component representing the given view. The component passed to the constructor of this class should either be, or contain this component. The component can be laid out, along with other components, and passed to this class. Note that this component only stays valid when the givenILcdGXYView
stays the same. If for example, layers are added/removed from the givenILcdGXYView
, 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.- Parameters:
aView
- the view for which to create a component.aLayerFilter
- a filter that determines which layers are printed. Can benull
.- Returns:
- a component for the view.
-
usePageCount
public void usePageCount(int aPageCountX, int aPageCountY) Sets the number of pages in the x and y direction. Note that either this method or theuseMapScale(double)
method should be used. When callinguseMapScale(double)
after this method was called, this method will have no effect. Note that after calling this method,getPageCountX
andgetPageCountY
may differ fromaPageCountX
andaPageCountY
. This is because the aspect ratio of the view component is most likely not the same as the aspect ratio of the pages.- Parameters:
aPageCountX
- the page count in the x direction.aPageCountY
- the page count in the y direction.- See Also:
-
useMapScale
public void useMapScale(double aMapScale) Sets the map scale to use when printing. Note that either this method or theusePageCount(int, int)
method should be used. When callingusePageCount(int, int)
after this method was called, this method will have no effect.- Parameters:
aMapScale
- a ratio that represents 1 / denominator. For example: a MapScale of 1:50000 can be created using 0.00002 (=1.0/50_000) as value.
-
invalidate
public void invalidate()Invalidates this printable. This is for example needed when a component was added or removed fromgetComponent()
, or when a component was resized. -
getPrintArea
Returns the used printing area.- Parameters:
aPageFormat
- the page format.- Returns:
- the used printing area.
-
getPageCountX
Description copied from class:ALcdViewComponentPrintable
Returns the page count in the x-direction.- Specified by:
getPageCountX
in classALcdViewComponentPrintable
- Parameters:
aPageFormat
- the page format- Returns:
- the page count in the x-direction.
-
getPageCountY
Description copied from class:ALcdViewComponentPrintable
Returns the page count in the y-direction.- Specified by:
getPageCountY
in classALcdViewComponentPrintable
- Parameters:
aPageFormat
- the page format- Returns:
- the page count in the y-direction.
-
getMapScale
Description copied from class:ALcdViewComponentPrintable
Returns the map scale (e.g.1:25.000
).- Specified by:
getMapScale
in classALcdViewComponentPrintable
- Parameters:
aPageFormat
- the page format- Returns:
- the map scale.
-
setPrintAreaBounds
Sets the bounds area to use when printing the view. The given bounds should be defined in the world reference of the printed view. Since the aspect ratio of the given area may be modified during printing, the actual print area can be queried using thegetPrintArea(PageFormat)
method. When setting this value tonull
, the view extents of the printed view area used instead. The default isnull
.- Parameters:
aBounds
- the print area bounds in world coordinates.- See Also:
-
getPrintAreaBounds
Returns the print area bounds.- Returns:
- the print area bounds.
- See Also:
-
setSnapToFullPages
public void setSnapToFullPages(boolean aUseSnapToFullPages) Specifies weather the content should fill the entire pages. By default this value istrue
.- Parameters:
aUseSnapToFullPages
-true
to specify that the content should fill the entire pages.- See Also:
-
isSnapToFullPages
public boolean isSnapToFullPages()Returns if snap to full pages is used.- Returns:
- if snap to full pages is used.
- See Also:
-
setDPI
public void setDPI(int aDPI) Sets the rasterization quality in DPI. The default is144
.- Parameters:
aDPI
- the rasterization quality in dpi.- See Also:
-
getDPI
public int getDPI()Returns the rasterization quality in dpi.- Specified by:
getDPI
in classALcdViewComponentPrintable
- Returns:
- the rasterization quality in dpi.
- See Also:
-
setFeatureScale
public void setFeatureScale(double aFeatureScale) Changes the relative size of features (such as icons, labels or line widths) in a view. The default value is 1.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.- Parameters:
aFeatureScale
- the size factor for line widths, icons sizes, font sizes ...- See Also:
-
getFeatureScale
public double getFeatureScale()Returns the relative size of features (such as icons, labels or line widths) in a view. The default value is 1.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.- Specified by:
getFeatureScale
in classALcdViewComponentPrintable
- Returns:
- the used feature scale.
- See Also:
-
setCropMarks
public void setCropMarks(boolean aCropMarks) Specifies whether to draw crop marks on multi-page prints. The default istrue
.- Parameters:
aCropMarks
-true
to draw crop marks on multi-page prints.
-
hasCropMarks
public boolean hasCropMarks()Returns whether crop marks are drawn on multi-page prints.- Returns:
- whether crop marks are drawn on multi-page prints.
-
setPositioningMarks
public void setPositioningMarks(boolean aPositioningMarks) Specifies whether to draw positioning marks on multi-page prints. The default istrue
.- Parameters:
aPositioningMarks
-true
to draw positioning marks on multi-page prints.
-
hasPositioningMarks
public boolean hasPositioningMarks()Returns whether positioning marks are drawn on multi-page prints.- Returns:
- whether positioning marks are drawn on multi-page prints.
-
setOrigin
Sets the origin of the component on the page. The default isnull
, meaning that the component is automatically centered on the page. This setting is mostly useful when disabling snap to full pages.- Parameters:
aOrigin
- the origin, ornull
.
-
getOrigin
Returns the origin of the component on the page.- Returns:
- the origin of the component on the page, or
null
. - See Also:
-
setPageDecorator
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.- Parameters:
aPageDecorator
- the page decorator.
-
getPageDecorator
Returns thePrintable
that is used as page decorator.- Returns:
- the
Printable
that is used as page decorator.
-
print
public int print(Graphics aGraphics, PageFormat aPageFormat, int aPageIndex) throws PrinterException - Specified by:
print
in interfacePrintable
- Throws:
PrinterException
-
createPreview
Creates a preview panel for the given page format.- Specified by:
createPreview
in classALcdViewComponentPrintable
- Parameters:
aPageFormat
- the page format to use- Returns:
- a panel visualizing the component
-