What are map components?
A map component is a visual component that contains an ILcdView
, surrounded by additional widgets, such as a tool bar. It is merely a container for a map, tool bar, popup menu, status bar,
layer control, and so on. You typically build it with a factory. For more information, see ILcyGenericMapComponent<S extends ILcdView, T extends ILcdLayer>
.
Map components need to be integrated with the back-end of the Lucy application. To do so, you must register the map component with one of the available map managers, as explained in Managing map components with a map manager. The map manager allows you to obtain references to previously registered map components.
Managing map components with a map manager
You can retrieve the maps present in Lucy to perform various operations on it, such as adding information in the form of a
new layer, retrieving data from it or even extending the map component visually. The different maps in the Lucy environment
are managed by a TLcyGenericMapManager<S extends ILcdView, T extends ILcdLayer>
. This map manager offers the functionality to add and remove maps and to retrieve all existing maps. It also fires events
when a map is added or removed. For those purposes, it contains the following methods:
-
addMapComponent
: adds a new map component. -
removeMapComponent
: removes an existing map component. -
getMapComponent
: retrieves the map component at a given index. -
getMapComponentCount
:returns the number of existing map components. -
addMapManagerListener
andremoveMapManagerListener
add or remove aILcyGenericMapManagerListener<? super S, ? super T>
that listens for addition or removal of map components.
Lucy contains several map managers:
-
A map manager for the 2D map components
-
A map manager for the map overview components
-
A map manager for the Lightspeed map components
The map managers for both the 2D and Lightspeed map components are registered with the TLcyCombinedMapManager
, which is the central access point to those map managers. You can retrieve the TLcyCombinedMapManager
from the Lucy back-end by calling ILcyLucyEnv.getCombinedMapManager()
.
The combined map manager allows you to:
-
Listen for the addition and removal of map components in any of its registered map managers
-
Listen for the addition and removal of map managers in the combined map manager
-
Get all registered map managers
-
Get all map components, registered to all map managers
Retrieving the active map component
Every TLcyGenericMapManager
keeps track of its active map component. By default, the active map component of a map manager is the last of the registered
map components with which the user interacted. The map manager fires a PropertyChangeEvent
whenever this active map component changes.
As a convenience, the TLcyCombinedMapManager
keeps track of an active map component as well. In this case, it is the last map component with which the user interacted,
regardless of the TLcyGenericMapManager
with which this map component was registered. You can see it as an application-wide active map component. The TLcyCombinedMapManager
fires an event when its active map component changes.
The application-wide map component is used as an active context. For more information about active contexts, see the reference guide.
Customizing map components
You can visually extend existing map components, to add an extra button to the tool bar for instance.
You can do that by interacting with the ILcyGenericMapComponent
interface.
After retrieving the appropriate map as explained in Managing map components with a map manager, you can obtain the following items:
-
The map menu bar, which can be retrieved with the method
getMenuBar()
. You can add extra menu items in here that are specific to the corresponding map. Always check if a menu bar is available first with the methodisMenuBarCapable()
. -
The map tool bar, accessible through the method
getToolbar()
.Always check if a tool bar is available with theisToolBarCapable()
method. -
The map layer control, which you can retrieve with the
getLayerControl()
. You can add extra actions to the action bar of the layer control. Always call the methodisLayerControlCapable()
to check if a layer control is available. -
Several extra containers for adding interface components to the map. Using the methods
getNorthPanel()
,getEastPanel()
,getSouthPanel()
andgetWestPanel()
, you can access thesejava.awt.Container
instances and add extra components to them.
There is another mechanism available that allows you to alter the map components in a more fundamental way at the time of
their creation.
This is illustrated in samples.lucy.gxy.custommapui.Main
(GXY maps) and samples.lucy.lightspeed.map.guifactory.Main
(Lightspeed views).