Views and View Manager

Table of contents

View class

In JMap, the View class is the main GUI component responsible for displaying the map. The methods of this class allow you to control the map (zoom, pan, etc.), to refresh it, to get information on the scale, etc.

The table below shows the main methods of the View class.

Events of the View class

In JMap, a view generates events in several situations. To get these events, you must register a listener to the view. To get events generated by all open views, it is recommended to register a listener on the View Manager. Read below for more information on this subject.

To receive a view’s events, you must implement the ViewEventListener interface and register it with the view using the addViewEventListener()method, as shown in the example below.

View view = ...

view.addViewEventListener(new ViewEventListener()

{

@Override

public void viewToolChangedOccurred(ViewToolChangedEvent e)

{

}

...

});

Note that the ViewAdapter adapter can also be used to simplify the development of a listener.

The table below shows the events triggered by the View class.

For more information on events in Java, see the Java Tutorial.

ViewState class

The ViewState class contains some view properties that define its state at a given time (scale, scope, transformation, etc.). Several methods in the JMap API take an instance of ViewState as a parameter. It is possible to get the state of a view by calling the getViewState() method of the View class.

ViewManager class

The view manager (ViewManager class) is responsible for managing one or more views that are present in the application. This class has methods that allow you to perform operations on all the views of the application and to know at any time which view is active (i.e. in focus).

The table below shows the main methods of the ViewManager class.

Events of the ViewManager class

The View Manager triggers events associated with the state of its views. To get these events, you must implement the ViewManagerEventListener interface and register it with the view manager using the addViewManagerEventListener() method, as shown in the following example.

View view = ...

ViewManager viewManager = view.getLayerManager();

viewManager.addViewManagerEventListener(new ViewManagerEventListener()

{

@Override

public void viewAdded(ViewAddedEvent e)

{

}

...

});

Note that the ViewManagerAdapter adapter can also be used to simplify the development of a listener.

The table below shows the events triggered by the ViewManager class.

It is also possible to register a listener to the View Manager to get the events generated by all the views associated with the layer manager. This may be more convenient than registering a listener on each view separately. To do so, use the addViewEventListener method of the ViewManager class.

ViewUtil class

The ViewUtil class provides useful methods to work with the view.

The table below shows the mains methods of the ViewUtil class.

Dernière mise à jour

K2 Geospatial 2022