Making a selection in dynamic display on a custom layer


Summary
The custom layer manages the items and properties needed to draw the layer and implement the layer drawing. When a selection is made during dynamic display on the layer, the selected items or properties are identified and rendered with dedicated selection symbols.

Making a selection in a custom layer

The custom layer needs to supply a method that lets the application or tool set the selection geometry that specifies the selection area. Store and use this geometry in the layer's draw methods.
 
When the custom layer draws, it loops through its items and determines if it is inside or outside the selected area. Each item that is inside the selected area is identified as a selected item and will be marked as selected in the layer's internal table. Each item that is outside the selected area will be rendered using the layer's symbols. After all the nonselected items are rendered, the layer renders the selected items on top of the nonselected items, using the specific selected symbols.
 
The following code example shows how a custom layer holding vector items can implement the layer's draw method, drawing the non-selected items first, then the selected items on top:
[Java]
// The custom layer class has a boolean array of items, named items 
// to indicate whether the item is selected. 
// The custom layer class has a method that determines if an item is inside or outside
// the selected area, according to the selectedArea geometry and the item's geometry. 
// The custom layer class also has two other methods; one that draws a selected item and one
// that draws a nonselected item. 
public class SelectingOnaCustomLayer{

    private void drawItems(){
        // Set the selected flag and draw the nonselected items.
        for (int itemIndex = 0; itemIndex < items.length; itemIndex++){
            items[itemIndex] = isItemInSelectedArea(itemIndex);
            if (!items[itemIndex])
            // invoke the method to draw non-selected item

                drawItemAsNonSelected(itemIndex);
        }
        // Draw the selected items on top of the nonselected items. 
        for (int itemIndex = 0; itemIndex < items.length; itemIndex++){
            if (items[itemIndex])
            // invoke the method to draw the selected item
                drawItemAsSelected(itemIndex);
        }
    }
}


See Also:

About dynamic display
How dynamic display works
Best practices for using dynamic display
Limitations for dynamic display




Development licensingDeployment licensing
Engine Developer KitEngine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced