Select to view content in your preferred language

Accessing the Stylx file in Java

456
1
02-27-2018 04:22 AM
Siva_SankaraReddy_T
Emerging Contributor

Unable access customize Stylx file by using SymbolStyle API in Java.

 SymbolStyle symbolstyle = await SymbolStyle.OpenAsync(String Path); (.Net).

But in  java not find the Open Method of SymbolStyle API. 

Tags (1)
0 Kudos
1 Reply
KwasiAsante1
Occasional Contributor

Hi Shiva, 

you may use the DictionarySymbolStyle class (DictionarySymbolStyle| arcgis-java) to achieve the same results. In using that class ensure you have the right specification type in the constructor. 

I put the below code snippet together for illustration. 

private void loadSymbolStyle(String PATH_TO_SYMBOL, String PATH_TO_A_SHAPEFILE) {
List<String> keys = new ArrayList<>();
keys.add("key1");
keys.add("key2");
ShapefileFeatureTable shapefile = new ShapefileFeatureTable(PATH_TO_A_SHAPEFILE);
FeatureLayer featureLayer = new FeatureLayer(shapefile);
featureLayer.loadAsync();

DictionarySymbolStyle dictionarySymStyle = new DictionarySymbolStyle("mil2525d", PATH_TO_SYMBOL);
dictionarySymStyle.loadAsync();
dictionarySymStyle.addDoneLoadingListener(() -> {
if (dictionarySymStyle.getLoadStatus() == LoadStatus.LOADED) {
System.out.println("Loaded!!!");
symbolFuture = dictionarySymStyle.getSymbolAsync(keys);
try {
Symbol symbol = symbolFuture.get();
featureLayer.setRenderer(new SimpleRenderer(symbol));
mapView.getMap().getOperationalLayers().add(featureLayer);  //add loaded layer to map
mapView.setViewpointGeometryAsync(featureLayer.getFullExtent(), 100); //zoom to extent

} catch (InterruptedException | ExecutionException inEx) {
System.out.println("Get Exception: " + inEx.getMessage());
}
} else {
System.out.println("Load Error: " + dictionarySymStyle.getLoadError().getAdditionalMessage()); //use this for debugging your code
}
});

}

0 Kudos