ArcGIS Runtime SDK for Java

Symbol Dictionary

Demonstrates how to search for symbol primitives within a Symbol Dictionary using the mil2525d specification and display those symbols.

How it works

How to search through a SymbolDictionary:

  1. Create a symbol dictionary with the mil2525d specification, SymbolDictionary("mil2525d")
  2. Load the dictionary asynchronously, DictionarySymbol.loadAsync()

    • this will allows the application to continue working while the dictionary loads all symbol primitives found within the mil2525d specification

  3. Create search parameters for the dictionary, StyleSymbolSearchParameters().
  4. Set the parameters to search through the dictionary.

    • Name, StyleSymbolSearchParameters.getNames().add()
    • Tag, StyleSymbolSearchParameters.getTags().add()
    • Symbol Class, StyleSymbolSearchParameters.getSymbolClasses().add()
    • Category, StyleSymbolSearchParameters.getCategories().add()
    • Key, StyleSymbolSearchParameters.getKeys().add()

  5. Search through dictionary using parameters,DictionarySymbol.searchSymbolsAsync(StyleSymbolSearchParameters).
  6. Cycle through the StyleSymbolSearchResult list that was returned and display it to screen.

    • get CimSymbol,StyleSymbolSearchResult.getSymbol(), and create an image from it, CimSymbol.createSwatchAsync()
    • use other get methods for the symbol's name, tags, symbolClass, category, and key, like StyleSymbolSearchResult.getName()

Code

/*
 * 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
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.symbology.symbol_dictionary;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class SymbolDictionarySample extends Application {

  @Override
  public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/symbol_dictionary.fxml"));
    Scene scene = new Scene(root);

    // set title, size, and add scene to stage
    stage.setTitle("Symbol Dictionary Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();
  }

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

    Application.launch(args);
  }

}


In this topic
  1. How it works
  2. Code