Map display preferences are accessible through the IlvDisplayPreferencesProperty of the manager
and its underlying IlvDisplayPreferences, which is responsible
for indicating user preferences when displaying the map.
The source code for the Map Builder demonstration, which contains
all of the code described in this section, can be found at <installdir> /jviews-maps810/samples/mapbuilder/index.html.
The display preferences are used to share:
- The preferred unit and format to use for altitudes.
- The preferred unit and format to use for distances.
- The preferred coordinate formatter to use to show earth coordinates.
- An indication of whether geodetic computation is activated or not.
Display preferences access
You can access the display preferences by
calling:
IlvDisplayPreferences pref = IlvDisplayPreferencesProperty.GetDisplayPreferences(manager);
This method creates or returns the last instance set of IlvDisplayPreferences.
Display preferences uses
The IlvJMouseCoordinateViewer bean uses
preferences to format coordinates and altitude information
whenever the mouse moves over the map.
The IlvJAutomaticScaleBar also listens to this
property in order to adapt the map distance unit to the
preferences of the application.
When creating measurements (or an IlvMapOrthodromyPath), a specific
IlvDistanceAttribute
property is attached to contain the measurement length. This
property displays itself taking into account the preferred
distance unit found in the preferences.
The IlvCoordinatePanelFactory needs to retrieve
a coordinate formatter to know how to display the coordinates
selected on the view, which can also edited by the user. You
should usually do this by retrieving the coordinate formatter of
the current preferences:
IlvDisplayPreferences prefs = IlvDisplayPreferencesProperty.GetDisplayPreferences(manager); IlvCoordinateFormatter formatter= prefs.getCoordinateFormatter(); JPanel coordPicker=new IlvCoordinatePanelFactory.CoordPointInputPanel(view,formatter);
Adding a listener to changes in display preferences
You can listen to changes in this property
(such as those triggered by the Display Preference Editor), by
adding a named property listener on the manager:
manager.addNamedPropertyListener(new NamedPropertyListener() { public void propertyChanged(NamedPropertyEvent event) { if(event.getNewValue() instanceof IlvDisplayPreferencesProperty){ IlvDisplayPreferencesProperty prop=(IlvDisplayPreferencesProperty)event.getNewValue(); IlvDisplayPreferences preferences=prop.getDisplayPreferences(); // manage the new preferences ... } } });
Geodetic computation
All data sources should use the display
preferences properties to adapt their rendering to the activation
of geodetic computation, which is an important user choice.
When geodetic computation is activated, every polygon-like map
feature is rendered, through the use of an IlvGeodeticPathComputation, into a series
of orthodromies (see orthodromy measure). Whenever a segment of
the polygon has two extremities on different sides of the screen,
the polygon is cut into many areas, separated on the screen but
representing the same map feature.