ArcGIS Runtime SDK for Java

Feature Layer Dictionary Renderer

Demonstrates how to apply a dictionary renderer to a feature layer and display mil2525d graphics. The dictionary renderer creates these graphics using a mil2525d style file and the attributes attached to each feature within the geodatabase.

How it works

To apply a DictionaryRenderer and display mil2525d graphics:

  1. Create a Geodatabase(geodatabasePath).

    • geodatabasePath, local path to geodatabase

  2. Load the geodatabase asynchronously, Geodatabase.loadAsync().

    • this will allows the application to continue working while the geodatabase loads in all feature tables

  3. Create a SymbolDicitonary, SymbolDictionary(specificationType).

    • specificationType, this will be the mil2525d.stylx file
    • load asynchronouly, DictionarySymbol.loadAsync()

  4. Wait for geodatabase to completely load,Geodatabase.addDoneLoadingListener().
  5. Cycle through each GeodatabaseFeatureTable from geodatabase, Geodatabase.getGeodatabaseFeatureTables().
  6. Create a FeatureLayer from each table within the geodatabase, FeatureLayer(GeodatabaseFeatureTable).

    • load asynchronously, FeatureLayer.loadAsync()

  7. Wait for each layer to load, FeatureLayer.addDoneLoadingListener.
  8. Check if layer is last layer to load and create Envelope from each layer.

    • set this envelope to be the Viewpoint of the map view, MapView.setViewpoint(new Viewpoint(Envelope))

  9. Add feature layer to map, Map.getOperationalLayers().add(FeatureLayer).
  10. Create DictionaryRenderer(SymbolDictionary) and attach to feature layer, FeatureLayer.setRenderer(DictionaryRenderer).


 * Copyright 2017 Esri.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.

package com.esri.samples.featurelayers.feature_layer_dictionary_renderer;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.loadable.LoadStatus;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.DictionaryRenderer;
import com.esri.arcgisruntime.symbology.DictionarySymbolStyle;

public class FeatureLayerDictionaryRendererSample extends Application {

  private MapView mapView;

  public void start(Stage stage) {

    mapView = new MapView();
    StackPane appWindow = new StackPane(mapView);
    Scene scene = new Scene(appWindow);

    // set title, size, and add scene to stage
    stage.setTitle("Feature Layer Dictionary Renderer Sample");

    ArcGISMap map = new ArcGISMap(Basemap.createTopographic());

    // load geo-database from local location
    Geodatabase geodatabase = new Geodatabase("./samples-data/dictionary/militaryoverlay.geodatabase");

    // render tells layer what symbols to apply to what features
    DictionarySymbolStyle symbolDictionary = new DictionarySymbolStyle("mil2525d");

    geodatabase.addDoneLoadingListener(() -> {
      if (geodatabase.getLoadStatus() == LoadStatus.LOADED) {
        geodatabase.getGeodatabaseFeatureTables().forEach(table -> {
          // add each layer to map
          FeatureLayer featureLayer = new FeatureLayer(table);
          // Features no longer show after this scale

          // displays features from layer using mil2525d symbols
          DictionaryRenderer dictionaryRenderer = new DictionaryRenderer(symbolDictionary);

          featureLayer.addDoneLoadingListener(() -> {
            if (featureLayer.getLoadStatus() == LoadStatus.LOADED) {
              // initial viewpoint to encompass all graphics displayed on the map view 
            } else {
              Alert alert = new Alert(Alert.AlertType.ERROR, "Feature Layer Failed to Load!");
      } else {
        Alert alert = new Alert(Alert.AlertType.ERROR, "Geodatabase Failed to Load!");;

   * Stops and releases all resources used in application.
  public void stop() {

    if (mapView != null) {

   * Opens and runs application.
   * @param args arguments passed to this application
  public static void main(String[] args) {


In this topic
  1. How it works
  2. Code