public class TLcyLspPrintableMapComponentFactory extends ALcyPrintableMapComponentFactory<ILcyLspMapComponent>
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)
.Modifier and Type | Field and Description |
---|---|
static int |
CLASSIFICATION_COMPONENT
The id for creating the classification component
|
static int |
FOOTER_TEXT_COMPONENT
The id for creating the footer text component.
|
static int |
HEADER_TEXT_COMPONENT
The id for creating the header text component.
|
static int |
LEGEND_COMPONENT
The id for creating the legend component.
|
static int |
MAIN_VIEW
The id for creating the view of the current map component.
|
static int |
MODIFIABLE_HEADER_TEXT_COMPONENT
The id for creating the header text component which can be altered by the user in the UI.
|
static int |
OVERVIEW_VIEW
The id for creating the view of the current map overview component.
|
static int |
SCALE_ICON_COMPONENT
The id for creating the scale icon component.
|
static int |
SCALE_LABEL_COMPONENT
The id for creating the scale indication component.
|
static int |
TITLE_TEXT_COMPONENT
The id for creating the title text component.
|
Constructor and Description |
---|
TLcyLspPrintableMapComponentFactory()
Default constructor.
|
TLcyLspPrintableMapComponentFactory(ILcyLucyEnv aLucyEnv)
Creates a new
TLcyLspPrintableMapComponentFactory . |
Modifier and Type | Method and Description |
---|---|
protected Component |
createComponent(int aID,
ILcyLspMapComponent aMapComponent,
TLcyProperties aProperties)
Creates a
java.awt.Component for the given ID. |
TLcyPrintableMapComponent |
createPrintableComponent(ILcyLspMapComponent aMapComponent,
TLcyProperties aProperties)
This function will first create all internal components using
createView
and createComponent . |
protected Component |
createPrintableComponentContent(ILcyLspMapComponent aMapComponent,
TLcyProperties aProperties)
Creates the content of the
TLcyPrintableMapComponent . |
protected ILcdView |
createView(int aID,
ILcyLspMapComponent aMapComponent,
TLcyProperties aProperties)
Creates an
ILcdView for the given ID.
The return value for the MAIN_VIEW constant must not be null. |
protected Component |
getComponent(int aID)
Returns the
java.awt.Component for the given ID. |
ILcyLucyEnv |
getLucyEnv()
Returns the associated lucy environment.
|
protected ILcdView |
getView(int aID)
Returns the
ILcdView for the given ID. |
void |
setLucyEnv(ILcyLucyEnv aLucyEnv)
Sets the associated lucy environment.
|
public static final int MAIN_VIEW
null
.public static final int OVERVIEW_VIEW
public static final int LEGEND_COMPONENT
public static final int SCALE_ICON_COMPONENT
public static final int SCALE_LABEL_COMPONENT
public static final int HEADER_TEXT_COMPONENT
public static final int FOOTER_TEXT_COMPONENT
public static final int TITLE_TEXT_COMPONENT
public static final int MODIFIABLE_HEADER_TEXT_COMPONENT
public static final int CLASSIFICATION_COMPONENT
public TLcyLspPrintableMapComponentFactory()
TLcyLspPrintableMapComponentFactory
. Note
that you will have to set an ILcyLucyEnv
before this instance can be used.public TLcyLspPrintableMapComponentFactory(ILcyLucyEnv aLucyEnv)
TLcyLspPrintableMapComponentFactory
.aLucyEnv
- The lucy environment, contextual information.public ILcyLucyEnv getLucyEnv()
ALcyPrintableMapComponentFactory
getLucyEnv
in class ALcyPrintableMapComponentFactory<ILcyLspMapComponent>
ALcyPrintableMapComponentFactory.setLucyEnv(com.luciad.lucy.ILcyLucyEnv)
public void setLucyEnv(ILcyLucyEnv aLucyEnv)
ALcyPrintableMapComponentFactory
setLucyEnv
in class ALcyPrintableMapComponentFactory<ILcyLspMapComponent>
aLucyEnv
- The lucy environment.ALcyPrintableMapComponentFactory.getLucyEnv()
public TLcyPrintableMapComponent createPrintableComponent(ILcyLspMapComponent aMapComponent, TLcyProperties aProperties)
createView
and createComponent
. Then it calls createPrintableComponentContent
, which will create the content of the printable component using
the internal components by calling getView
and getComponent
.
And finally it will create the actual TLcyPrintableMapComponent
.
Warning: Should not be overridden without calling the super
function.
createPrintableComponent
in class ALcyPrintableMapComponentFactory<ILcyLspMapComponent>
aMapComponent
- The map component to use.aProperties
- The property node to use.protected Component createPrintableComponentContent(ILcyLspMapComponent aMapComponent, TLcyProperties aProperties)
TLcyPrintableMapComponent
. The methods getView(id)
and getComponent(id)
are used to safely retrieve the previously created objects. The
retrieved components are layed out in for example a javax.swing.JPanel
. This function should be
overridden when you want to change the layout of the TLcyPrintableMapComponent
.
If you would like to put components on the map (for example a legend), a
JLayeredPane
can be useful to overlay them.aMapComponent
- The map component to use.aProperties
- The property node to use.protected ILcdView createView(int aID, ILcyLspMapComponent aMapComponent, TLcyProperties aProperties)
ILcdView
for the given ID.
The return value for the MAIN_VIEW
constant must not be null.aID
- The id describing which view to create. This is a constant
that ends in VIEW
.aMapComponent
- The map component to use.aProperties
- The property node to use.ILcdView
, or null
. null
is
however not returned for the MAIN_VIEW
constant.protected ILcdView getView(int aID)
ILcdView
for the given ID.aID
- The id describing which view to create. This is a constant that ends in VIEW
.ILcdView
for the given ID.protected Component createComponent(int aID, ILcyLspMapComponent aMapComponent, TLcyProperties aProperties)
java.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 (see LEGEND_COMPONENT
), null is returned
if the value of TLcyPrintAddOn.LEGEND_VISIBLE_KEY
is false
. If the
value of TLcyPrintAddOn.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 using ALcyProperties.addPropertyChangeListener(java.beans.PropertyChangeListener)
.aID
- The id describing which component to create. This is a constant that ends in
COMPONENT
.aMapComponent
- The map component, provided as contextual information.aProperties
- The property node.java.awt.Component
, or null.protected Component getComponent(int aID)
java.awt.Component
for the given ID.aID
- The id describing which component to create. This is a constant that ends in COMPONENT
.java.awt.Component
for the given ID.