Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEOT-7109] Swt Module review and update #3921

Merged
merged 8 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file removed docs/user/images/gtswt_rcp_01.png
Binary file not shown.
Binary file removed docs/user/images/gtswt_rcp_02.png
Binary file not shown.
Binary file modified docs/user/images/gtswt_standalone_01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/gtswt_standalone_02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/user/unsupported/swt/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ in a future extraction of common interfaces for GUI modules.
:maxdepth: 1

swtmapframe
rcp
216 changes: 0 additions & 216 deletions docs/user/unsupported/swt/rcp.rst

This file was deleted.

69 changes: 39 additions & 30 deletions docs/user/unsupported/swt/swtmapframe.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
SWTMapFrame
-----------

The following is a tutorial that explains how to use the ``gt-swt`` module in standalone mode and inside
an RCP environment. The tutorial assumes the user is already confident with
GeoTools development/build and already an basic RCP developer.
The following is a tutorial that explains how to use the ``gt-swt`` module in standalone mode.
The tutorial assumes the user is already confident with GeoTools development.

Example
^^^^^^^
Expand All @@ -14,41 +13,51 @@ Using the standalone ``gt-swt`` module is fairly easy.

public class Main {
public static void main( String[] args ) throws Exception {
// create a default mapcontext
MapContext context = new DefaultMapContext();
// set the title
context.setTitle("The SWT Map is in the game");
// add a shapefile if you like
File shapeFile = new File("/home/moovida/data/world_adm0/countries.shp");
ShapefileDataStore store = new ShapefileDataStore(shapeFile.toURI().toURL());
SimpleFeatureSource featureSource = store.getFeatureSource();
SimpleFeatureCollection shapefile = featureSource.getFeatures();
context.addLayer(shapefile, null);

// and show the map viewer
SwtMapFrame.showMap(context);
// create a default mapcontext
MapContent context = new MapContent();
// set the title
context.setTitle("The SWT Map is in the game");
// and show the map viewer
SwtMapFrame.showMap(context, null);
}
}

Which results in:

.. image:: /images/gtswt_standalone_01.png

2. It is possible to tweak some of the window settings, like ``statusbar``, ``layers panel`` and
``toolbars/menus``. For this use we have to move beyond our call to ``SwtMapFrame.showMap(context)``

The result is equally easy. Again a code snippet is the best way.
2. It is possible to supply to the mapframe an actionhandler that allows to add actions to the file and
navigation menus. For example the following code snippet shows how to add an add-OSM-layer action to
the file menu (in addition to the default entries)::

In the following case we decide that we want to get rid of the layers panel::

boolean showMenu = true;
boolean showToolBar = true;
boolean showStatusBar = true;
boolean showLayerTable = false;
final SwtMapFrame frame = new SwtMapFrame(showMenu, showToolBar, showStatusBar, showLayerTable, context);
frame.setBlockOnOpen(true);
frame.open();
public static void main( String[] args ) throws Exception {
// create a default mapcontext
MapContent context = new MapContent();
// set the title
context.setTitle("The SWT Map is in the game");

// create an action handler with the selected MapActions
SwtActionsHandler actionsHandler = new SwtActionsHandler(){
private OpenShapefileAction openShapefileAction = new OpenShapefileAction();
private OpenGeotiffAction openGeotiffAction = new OpenGeotiffAction();
private AddOsmAction addOsmAction = new AddOsmAction();

@Override
public MapAction[] getFileMenuActions() {
return new MapAction[]{openShapefileAction, openGeotiffAction, addOsmAction};
}

@Override
public MapAction[] getFileNavigationMenuActions() {
return new MapAction[0];
}

};

// and show the map viewer
SwtMapFrame.showMap(context, actionsHandler);
}

Which results in:

.. image:: /images/gtswt_standalone_01.png
.. image:: /images/gtswt_standalone_02.png