Class TLcyLspPrintableMapComponentFactory
java.lang.Object
com.luciad.lucy.addons.print.ALcyPrintableMapComponentFactory<ILcyLspMapComponent>
com.luciad.lucy.addons.print.lightspeed.TLcyLspPrintableMapComponentFactory
public class TLcyLspPrintableMapComponentFactory
extends ALcyPrintableMapComponentFactory<ILcyLspMapComponent>
Factory for the creation of printable
java.awt.Component
s containing a Lightspeed view.
This factory was designed so that it is easy to modify small parts of the creation process.
This can be done by subclassing this class and overriding certain methods.
The main create function createPrintableComponent
will first create all usable parts, eg. the map view, the header text, the scale icon,... using the
functions createView
and createComponent
. Then it calls
createPrintableComponentContent
, which will create the content of the printable component
using the created objects by calling getView
and getComponent
.
And finally it will create the actual TLcyPrintableMapComponent
.
ID's are used to identify different types of components that can be
created: the legend, the scale icon, the footer/header text,... All possible ID's that can be passed
to the createComponent
method all end with the same suffix "component". The
same thing goes for "view" in createView
.
As an example, imagine you want to change the behaviour of the footer text. Browsing this class learns
there is a FOOTER_TEXT_COMPONENT
constant. Because it ends with "component", this
constant can only be passed to the createComponent
method. Therefore we can override the
method createComponent
, check if the ID is FOOTER_TEXT_COMPONENT
and return a
custom component instance. Or use super.createComponent
and change some settings before
returning it. If you want to remove the component completely, you can simply return null.
The method createPrintableComponent(com.luciad.lucy.map.lightspeed.ILcyLspMapComponent, com.luciad.lucy.util.TLcyProperties)
should not be overridden
without using the super function. Changing the layout of the TLcyPrintableMapComponent
can be
done by overriding createPrintableComponentContent()
. The internal elements are already
created and should be retrieved by calling getView(id)
and getComponent(id)
.- Since:
- 2013.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The id for creating the classification componentstatic final int
The id for creating the footer text component.static final int
The id for creating the header text component.static final int
The id for creating the legend component.static final int
The id for creating the view of the current map component.static final int
The id for creating the header text component which can be altered by the user in the UI.static final int
The id for creating the view of the current map overview component.static final int
The id for creating the scale icon component.static final int
The id for creating the scale indication component.static final int
The id for creating the title text component. -
Constructor Summary
ConstructorDescriptionDefault constructor.Creates a newTLcyLspPrintableMapComponentFactory
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Component
createComponent
(int aID, ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) Creates ajava.awt.Component
for the given ID.createPrintableComponent
(ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) This function will first create all internal components usingcreateView
andcreateComponent
.protected Component
createPrintableComponentContent
(ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) Creates the content of theTLcyPrintableMapComponent
.protected ILcdView
createView
(int aID, ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) Creates anILcdView
for the given ID.protected Component
getComponent
(int aID) Returns thejava.awt.Component
for the given ID.Returns the associated lucy environment.protected ILcdView
getView
(int aID) Returns theILcdView
for the given ID.void
setLucyEnv
(ILcyLucyEnv aLucyEnv) Sets the associated lucy environment.
-
Field Details
-
MAIN_VIEW
public static final int MAIN_VIEWThe id for creating the view of the current map component. For this ID, it is not allowed to returnnull
.- See Also:
-
OVERVIEW_VIEW
public static final int OVERVIEW_VIEWThe id for creating the view of the current map overview component.- See Also:
-
LEGEND_COMPONENT
public static final int LEGEND_COMPONENTThe id for creating the legend component.- See Also:
-
SCALE_ICON_COMPONENT
public static final int SCALE_ICON_COMPONENTThe id for creating the scale icon component.- See Also:
-
SCALE_LABEL_COMPONENT
public static final int SCALE_LABEL_COMPONENTThe id for creating the scale indication component.- See Also:
-
HEADER_TEXT_COMPONENT
public static final int HEADER_TEXT_COMPONENTThe id for creating the header text component.- See Also:
-
FOOTER_TEXT_COMPONENT
public static final int FOOTER_TEXT_COMPONENTThe id for creating the footer text component.- See Also:
-
TITLE_TEXT_COMPONENT
public static final int TITLE_TEXT_COMPONENTThe id for creating the title text component.- See Also:
-
MODIFIABLE_HEADER_TEXT_COMPONENT
public static final int MODIFIABLE_HEADER_TEXT_COMPONENTThe id for creating the header text component which can be altered by the user in the UI.- Since:
- 2016.1.1
- See Also:
-
CLASSIFICATION_COMPONENT
public static final int CLASSIFICATION_COMPONENTThe id for creating the classification component- Since:
- 2016.1.1
- See Also:
-
-
Constructor Details
-
TLcyLspPrintableMapComponentFactory
public TLcyLspPrintableMapComponentFactory()Default constructor. Creates a newTLcyLspPrintableMapComponentFactory
. Note that you will have to set anILcyLucyEnv
before this instance can be used. -
TLcyLspPrintableMapComponentFactory
Creates a newTLcyLspPrintableMapComponentFactory
.- Parameters:
aLucyEnv
- The lucy environment, contextual information.
-
-
Method Details
-
getLucyEnv
Description copied from class:ALcyPrintableMapComponentFactory
Returns the associated lucy environment.- Specified by:
getLucyEnv
in classALcyPrintableMapComponentFactory<ILcyLspMapComponent>
- Returns:
- the associated lucy environment.
- See Also:
-
setLucyEnv
Description copied from class:ALcyPrintableMapComponentFactory
Sets the associated lucy environment.- Specified by:
setLucyEnv
in classALcyPrintableMapComponentFactory<ILcyLspMapComponent>
- Parameters:
aLucyEnv
- The lucy environment.- See Also:
-
createPrintableComponent
public TLcyPrintableMapComponent createPrintableComponent(ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) This function will first create all internal components usingcreateView
andcreateComponent
. Then it callscreatePrintableComponentContent
, which will create the content of the printable component using the internal components by callinggetView
andgetComponent
. And finally it will create the actualTLcyPrintableMapComponent
.Warning: Should not be overridden without calling the
super
function.- Specified by:
createPrintableComponent
in classALcyPrintableMapComponentFactory<ILcyLspMapComponent>
- Parameters:
aMapComponent
- The map component to use.aProperties
- The property node to use.- Returns:
- the created printable component.
-
createPrintableComponentContent
protected Component createPrintableComponentContent(ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) Creates the content of theTLcyPrintableMapComponent
. The methodsgetView(id)
andgetComponent(id)
are used to safely retrieve the previously created objects. The retrieved components are layed out in for example ajavax.swing.JPanel
. This function should be overridden when you want to change the layout of theTLcyPrintableMapComponent
. If you would like to put components on the map (for example a legend), aJLayeredPane
can be useful to overlay them.- Parameters:
aMapComponent
- The map component to use.aProperties
- The property node to use.- Returns:
- the created content.
-
createView
protected ILcdView createView(int aID, ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) Creates anILcdView
for the given ID. The return value for theMAIN_VIEW
constant must not be null.- Parameters:
aID
- The id describing which view to create. This is a constant that ends inVIEW
.aMapComponent
- The map component to use.aProperties
- The property node to use.- Returns:
- The newly created
ILcdView
, ornull
.null
is however not returned for theMAIN_VIEW
constant.
-
getView
Returns theILcdView
for the given ID.- Parameters:
aID
- The id describing which view to create. This is a constant that ends inVIEW
.- Returns:
- the
ILcdView
for the given ID.
-
createComponent
protected Component createComponent(int aID, ILcyLspMapComponent aMapComponent, TLcyProperties aProperties) Creates ajava.awt.Component
for the given ID. The map component is provided as contextual information, and could for example be used to build a legend. The properties can be used to tweak the component creation. For example when the legend is created (seeLEGEND_COMPONENT
), null is returned if the value ofTLcyPrintAddOn.LEGEND_VISIBLE_KEY
isfalse
. If the value ofTLcyPrintAddOn.LEGEND_SELECTED_KEY
changes (even after the component is returned), the legend will toggle its visibility. One can detect changes in the given aProperties by usingALcyProperties.addPropertyChangeListener(java.beans.PropertyChangeListener)
.- Parameters:
aID
- The id describing which component to create. This is a constant that ends inCOMPONENT
.aMapComponent
- The map component, provided as contextual information.aProperties
- The property node.- Returns:
- The newly created
java.awt.Component
, or null.
-
getComponent
Returns thejava.awt.Component
for the given ID.- Parameters:
aID
- The id describing which component to create. This is a constant that ends inCOMPONENT
.- Returns:
- the
java.awt.Component
for the given ID.
-