Programming with JViews Maps > Introducing the Main Classes > Map Specific Manager Properties > Display Preferences

This section describes:

The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir>/jviews-maps81/samples/mapbuilder/index.html

The Display Preferences Property

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.

Accessing the Display Preferences

You can access these preferences by calling:

IlvDisplayPreferences pref = IlvDisplayPreferencesProperty.GetDisplayPreferences(manager);

This method creates or returns the last instance set of IlvDisplayPreferences.

The display preferences are used to share:

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. 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.