Tuesday, January 15, 2008

How to use nice windows to select maps, layers, etc in JGrass

In JGrass with the need to often select raster and vector maps from within windows, dialogs and so on, and because of the need to have particular informations about Locations and Mapset given to the executed algoritms, we decided to create a set of widgets to do so.

They are really easy to call and give back the list of the selected resource:


JGRasterChooserDialog tree = new JGRasterChooserDialog();
tree.open(elevationGroup.getShell(), SWT.SINGLE);
JGrassMapGeoResource selected = tree.getSelectedResources().get(0);
String layerName =selected.getTypeNames()[0];



Which looks like the following two images, depending on whether you want to pick up the resource from the loaded layers in the project or also from the resources loaded in the catalog:

Here I loaded I GRASS raster map,


and here all the maps in the locations that is loaded in the catalog are seen.



The same applies for the featuresources:


FeatureChooserDialog tree = new FeatureChooserDialog();
tree.open(reachShapeGroup.getShell(), SWT.SINGLE);
DataStore selected = tree.getSelectedResources().get(0);
String layerName =selected.getTypeNames()[0];




and catalog.




Fairly easy, isn't it? :)
Post a Comment