Programming with JViews Maps > Creating a Map Application Using the API > Using the GUI Beans > The Map Layer Tree

The Map Layer Tree panel Bean is represented by the IlvLayerTreePanel class. The Map Layer Tree Bean displays the layer tree, the Map Style Property Sheet Bean and a number of other Beans that are accessed from this panel.

An example of the Map Layer Tree panel is shown in Figure 3.11.

maplayertreepanel.png

Figure 3.11 Map Layer Tree Panel

This section includes the following information:

Including the Bean in an Application

To include the Map Layer Tree panel Bean in your application, write the following lines of code:

IlvLayerTreePanel  layerTreePanel = new IlvLayerTreePanel();
layerTreePanel.setView(view);

Adding the Bean to a Swing Container

You can then add this Bean to your Swing hierarchy.

panel.add(layerTreePanel, BorderLayout.WEST);

The Map Layer Tree panel Bean then attaches itself and listens to the IlvMapLayerTreeProperty property of the specified manager. Whenever a layer is added or changed in the underlying IlvMapLayerTreeModel, its name is added to the tree, and the layer style properties (such as colors or view visibilities) are made available for modification in the lower part of the panel.

The Map Layer Tree panel also attaches itself to the selection mechanism of the manager in order to select the layer when a graphical map object is selected.

The Dynamic Style Setting Panel Bean

The Dynamic Style Setting panel Bean is represented by the IlvMapDynamicStylePanel class.

An example of the Dynamic Style Setting panel is shown in Figure 3.12.

dynamstylesetpanel.png

Figure 3.12 Dynamic Style Setting Panel

The Dynamic Style Setting panel displays the different styles a layer can have at different zoom factors. The gray bar furthest to the left is the default style (used for the finer/higher zoom levels of a map) - the other dynamic style settings are represented by alternating yellow and white bars. Users can also use the panel to set the map scale by clicking on the dynamic styles bar.

Accessing and Updating the Panel

You should not need to create a Dynamic Style Setting panel directly. You can access the Style Setting panel of the Map Layer Tree panel using the getThemePanel method.

This panel is attached to the IlvMapStyleControllerProperty property of the manager (and its underlying IlvMapStyleController). It is updated when the user adds/deletes dynamic styles (using the plusbutton.png and minusbutton.png buttons, see Figure 3.12), or when you add dynamic styles with API calls such as:

IlvMapStyleController themeControl = IlvMapStyleControllerProperty.
   GetMapStyleController(view.getManager());
themeControl.addTheme(0.001,mapLayer,"new style");
themeControl.getStyle(mapLayer,0.001).setVisibleInView(true);

The Map Style Property Sheet Bean

The Map Style Property Sheet Bean is represented by the IlvMapStylePropertySheet class.

An example of the Map Style Property Sheet is shown in Figure 3.13.

mapstylepropsheet.png

Figure 3.13 Map Style Property Sheet

When a layer is selected, this property sheet is updated with a property list depending on the associated map style.

You do not need to create a Map Style Property Sheet directly. You can access the Map Style Property Sheet of the Map Layer Tree panel using the getMapStylePropertySheet method.

Note
By using IlvMapStyleBeanInfo.setAdvancedMode(false), you can limit the list of properties displayed in the Map Style Property Sheet to a restricted list, depending on the class of the map style used.

Property Editors

Most of the properties are integers, Booleans (true/false choices) or raw text. Some properties however need a more specific property editor. The editors are:

JViews Maps does not call the constructor for any of the editors. It uses the standard Java BeanInfo mapping instead. For example, the IlvMapStyle class has the property alpha and the IlvMapStyleBeanInfo class returns the list of editable properties and associates an IlvAlphaPropertyEditor for that property. The IlvMapStylePropertySheet class uses this information to create the correct editor (using Java reflection).

Alpha Property Editor

The Alpha Property Editor is represented by the IlvAlphaPropertyEditor class.

An example of the Alpha Property Editor is shown in Figure 3.14.

alphaeditor.png

Figure 3.14 Alpha Property Editor

To include the Alpha Property Editor in a new Bean, place the following lines in the associated BeanInfo class:

   ...
PropertyDescriptor alpha = new PropertyDescriptor("alpha",IlvMapStyle.class);
alpha.setPropertyEditorClass(IlvAlphaPropertyEditor.class);
   ...
Color Model Property Editor

The Color Model Property Editor is represented by the IlvColorModelPropertyEditor class. This property editor enables you to set, for example, the colors for different altitudes in a map that contains altitude data.

An example of the Color Model Property Editor is shown in Figure 3.15.

colormodel.png

Figure 3.15 Color Model Property Editor

The Color Model Property Editor is implemented in a similar way to the Alpha Property Editor and is used for IlvRasterStyle map styles.

To include the Color Model Property Editor in a new Bean, use the following lines in a BeanInfo class:

PropertyDescriptor colorModel = new PropertyDescriptor("colorModel",IlvRasterStyle.class);
...
colorModel.setPropertyEditorClass(IlvColorModelPropertyEditor.class);
...
Color Property Editor

The Color Property Editor enables you to set the color of the map outlines. An example of the Color Property Editor is shown in Figure 3.16.

coloreditor.png

Figure 3.16 Color Property Editor

The Color Property Editor Bean is implemented in a similar way to the other editors and is used in the IlvGeneralPathStyle and IlvPolylineStyle map styles.

Paint Property Editor

The Paint Property Editor enables you to set the map fill color.

An example of the Paint Property Editor is shown in Figure 3.17.

painteditor.png

Figure 3.17 Paint Property Editor

The Paint Property Editor Bean is implemented in a similar way to the other editors and is used in the IlvGeneralPathStyle and IlvPolylineStyle map styles.

Percent Property Editor

The Percent Property Editor is represented by the IlvPercentPropertyEditor class. This property editor enables you to set the brightness, saturation, and contrast of the displayed map.

An example of the Percent Property Editor is shown in Figure 3.18.

percenteditor.png

Figure 3.18 Percent Property Editor

The Percent Property Editor is implemented in a similar way to the other editors and is used in the IlvRasterStyle map styles.

To include the Percent Property Editor in a new Bean, use the following lines in a BeanInfo class:

PropertyDescriptor brightness = new PropertyDescriptor("brightness", IlvRasterStyle.class);
...
brightness.setPropertyEditorClass(IlvPercentPropertyEditor.class);

...