| Programming with JViews Maps > Creating a Map Application Using the API > Using the GUI Beans > The Coordinate Viewer |
The Coordinate Viewer |
INDEX
PREVIOUS
NEXT
|
The Coordinate Viewer Bean is represented by the IlvJMouseCoordinateViewer class. This Bean displays the current coordinates of the mouse when it is moved over a map view.
An example of the Coordinate Viewer is shown in Figure 3.10.
To include the Coordinate Viewer Bean in your application, write the following lines of code:
IlvJMouseCoordinateViewer coordViewer = new IlvJMouseCoordinateViewer(); coordViewer.setView(view);
You can then add this Bean to your Swing hierarchy.
panel.add(coordViewer, BorderLayout.SOUTH);
The Coordinate Viewer Bean then attaches a Mouse Motion Listener to the view and displays the information according to the properties of the manager:
IlvCoordinateSystemPropertyEditor is used to transform screen location coordinates into longitude/latitude information.
IlvAltitudeProviderProperty is used to retrieve the altitude at that longitude/latitude location, if available.
The coordinates and altitude are then transformed into human readable strings using IlvDisplayPreferencesProperty unit management and formatters.
Depending on the coordinate formatter, latitude/longitude/altitude may not be the only fields. For example, a UTM coordinate system displays the zone, zone number, easting and northing information. The Coordinate Viewer uses JLabel HTML capabilities to display the different parts of the coordinates as an HTML table.
You can configure the appearance of the Bean using, for example:
coordViewer.setHtmlTableProperties("border=1 cellpadding=0 cellspacing=0");
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |