How to use the DictionaryRenderer
Use the DictionaryRenderer to change label visibility
The following code sample takes a MessageGroupLayer and loops through all of the graphics layers to toggle the visibility of the labels. The ChildLayers method is used to return the graphics layers in the MessageGroupLayer:
for (Layer lyr : msgGroupLayer.getLayers())
{
//get the graphics layer
GraphicsLayer grLyr = (GraphicsLayer) lyr;
//get the dictionary renderer
dictionaryRenderer = (DictionaryRenderer) grLyr.getRenderer();
//toggle visibility
if (dictionaryRenderer.getLabelsVisible() == true){
dictionaryRenderer.setLabelsVisible(false);
}
else{
dictionaryRenderer.setLabelsVisible(true);
}
//apply dictionary renderer back to graphics layer
grLyr.setRenderer(dictionaryRenderer);
}
2/7/2013