| Programming with JViews Maps > Introducing the Main Classes > Map Specific Manager Properties > Map Layer Tree |
Map Layer Tree |
INDEX
PREVIOUS
NEXT
|
The IlvMapLayerTreeProperty class stores an IlvMapLayerTreeModel.
This layer tree model controls the order and style inheritance of IlvMapLayer you add into your manager. This model is also persistent data that is saved when you save the map.
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir>/jviews-maps81/samples/mapbuilder/index.html
You can access the layer tree model by calling:
IlvMapLayerTreeModel ltm = IlvMapLayerTreeProperty.GetMapLayerTreeModel(manager);
You can allow users to edit and control individual layer styles by adding an IlvLayerTree Bean in your application, see Using the GUI Beans.
Usually, applications only need to add layers with the addChild method, or remove them with the removeChild method of the layer model.
For more information about the map layer tree, see Creating Data Source Objects, Using Data Sources, and Writing a Data Source
The map tree model is a subclass of DefaultTreeModel, so you can add a TreeModelListener to your application to trap any change in the layer organization.
As the IlvMapLayerTreeProperty is also a named property of the manager, you can add a listener that is called whenever the entire tree structure is changed, for example:
manager.addNamedPropertyListener(new NamedPropertyListener() {
public void propertyChanged(NamedPropertyEvent event) {
if (event.getPropertyName().equals(IlvMapLayerTreeProperty.NAME)) {
IlvMapLayerTreeProperty p = (IlvMapLayerTreeProperty) event.getNewValue();
if (event.getType() == NamedPropertyEvent.PROPERTY_SET) {
...do something
}
}
}
});
If your application needs to apply a piece of code to all layers, whatever their depth in the tree, you should call the getEnumeration method of the tree model, such as:
Enumeration e = ltm.getEnumeration();
while(e.hasMoreElements()) {
Object o = e.nextElement();
if(o instanceof IlvMapLayerTreeNode) {
IlvMapLayer layer = (IlvMapLayer)((IlvMapLayerTreeNode)o).getUserObject();
... act on the layer
}
}
For example, the method clearAllObjects in IlvMapLayerTreeModel calls the removeAllObjects for each layer found.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |