How to use Flicker and NearbyPlaces command


Summary
This topic shows how to use the out-of-the-box 2D and 3D Flicker commands and the NearByPlaces command with ArcGIS Engine controls.

In this topic


Using the 2D Flicker and NearbyPlaces commands

To successfully utilize the ControlsMapFlickerCommand or ControlsNearbyPlacesCommand on a ToolbarControl buddied to a MapControl or PageLayoutControl, use the commands in conjunction with the CommandsEnvironment singleton object and the ControlsLayerListToolControl.
When a user selects a layer from the ControlsLayerListToolControl, this layer is set to the ILayerEffectProperties.setFlickerLayerByref() method on the CommandsEnvironment singleton object. The ControlsMapFlickerCommand uses the ILayerEffectProperties.getFlickerLayer() method to determine which layer to flicker.
Users can adjust the rate at which the flicker occurs using the ControlsFlickerRateToolControl, which sets the ILayerEffectProperties.setFlickerRate() method.
Similarly, failure to instantiate the CommandsEnvironment singleton object results in the ControlsMapFlickerCommand and ControlsNearbyPlacesCommand internally using its instance of the CommandsEnvironment object and appearing disabled to the user.
The following code example assumes a MapBean has been initialized in the application:
[Java]
/* Create the CommandEnvironment singleton object. 
 * The commandsEnv variable must be a class member to prevent it from going out of scope;
 * otherwise, the CommandsEnvironment singleton will be garbage collected and the tool will be disabled.
 */

private CommandsEnvironment commandsEnv;

private ToolbarBean getToolbarBean(){
    if (toolbarBean == null){
        toolbarBean = new ToolbarBean();
        try{
            toolbarBean.setBuddyControl(mapBean);
            env = new CommandsEnvironment();
            toolbarBean.addItem(ControlsOpenDocCommand.getClsid(), 0,  - 1, false, 0,
                esriCommandStyles.esriCommandStyleIconOnly);

            toolbarBean.addItem(ControlsMapFlickerCommand.getClsid(), 0,  - 1, false,
                0, esriCommandStyles.esriCommandStyleIconOnly);
            // ControlsFlickerRateToolControl can be added to the toolbar to change the flicker rate interactively during runtime.
            toolbarBean.addItem(ControlsFlickerRateToolControl.getClsid(), 0,  - 1,
                false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            toolbarBean.addItem(ControlsNearbyPlacesCommand.getClsid(), 0,  - 1,
                false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            /*
             * To set the flicker layer interactively at runtime,
             * it is essential to add the ControlsLayerListToolControl item to the toolbar. 
             */
            toolbarBean.addItem(ControlsLayerListToolControl.getClsid(), 0,  - 1,
                false, 0, esriCommandStyles.esriCommandStyleIconOnly);
        }
        catch (IOException e){
            e.printStackTrace();
        }
    }
    return toolbarBean;
}

Using the 3D Flicker commands

To successfully utilize the ControlsGlobeFlickerCommand on a ToolbarControl buddied to GlobeControl, the commands must be used in conjunction with the CommandsEnvironment singleton object and the ControlsGlobeLayerListToolControl.
When a user selects a layer from the ControlsGlobeLayerListToolControl, this layer is set to the ILayerEffectProperties.setFlickerLayerByref() method on the CommandsEnvironment singleton object. The ControlsGlobeFlickerCommand uses the ILayerEffectProperties.getFlickerLayer() method to determine which layer to flicker.
Users can adjust the rate at which the flicker occurs using the ControlsFlickerRateToolControl, which sets the ILayerEffectProperties.setFlickerRate() method.
Failure to instantiate the CommandsEnvironment singleton object results in the ControlsGlobeFlickerCommand internally using its own instance of the CommandsEnvironment object and appearing disabled to the user.
The following code example assumes a GlobeBean has been initialized in the application:
[Java]
/* 
 * Create the CommandEnvironment singleton object 
 * to support the Swipe and Transparency tool.
 * The env variable must be a class member to prevent it from going out of scope;
 * otherwise, the CommandsEnvironment singleton will be garbage collected and the tool will be disabled.
 */

private CommandsEnvironment commandsEnv;

private ToolbarBean getToolbarBean(){
    if (toolbarBean == null){
        toolbarBean = new ToolbarBean();
        try{
            toolbarBean.setBuddyControl(globeBean);
            env = new CommandsEnvironment();
            toolbarBean.addItem(ControlsGlobeOpenDocCommand.getClsid(), 0,  - 1,
                false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            toolbarBean.addItem(ControlsGlobeFlickerCommand.getClsid(), 0,  - 1,
                false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            // ControlsFlickerRateToolControl can be added to the toolbar to change the flicker rate interactively during runtime.
            toolbarBean.addItem(ControlsFlickerRateToolControl.getClsid(), 0,  - 1,
                false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            /*
             * To set the flicker layer interactively at runtime,
             *  add the ControlsGlobeLayerListToolControl item to the toolbar. 
             */
            toolbarBean.addItem(ControlsGlobeLayerListToolControl.getClsid(), 0,  -
                1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
        }
        catch (IOException e){
            e.printStackTrace();
        }
    }
    return toolbarBean;
}


See Also:

How to use Swipe tool and Transparency command
How to use the Roam tool
CommandsEnvironment class
ILayerEffectProperties interface
ControlsMapFlickerCommand class
ControlsGlobeFlickerCommand class
ControlsLayerListToolControl class
ControlsGlobeLayerListToolControl class
ControlsFlickerRateToolControl class
Singleton objects




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