Global Positioning System Reference
In-Depth Information
Another use of listeners is to report changes. A client can get the decimal
view port any time by using mapScrollPane.getMapPort , but also needs to
be informed when the port changes if the user interactively (randomly)
scrolls or drags the port. The following steps need to be executed:
// 1. create listener
public interface MapPortListener extends EventListener {..}
// 2. add viewport change listener
public synchronized void
addMapPortListener( MapPortListener listener ) {..}
// 3. catch change event from Swing and propagate to listener
private class MapPort implements ChangeListener {..}
The components MapPanel , MapScalePanel , and MapScrollPane are spe-
cialized Swing components made to assist developers in visualizing posi-
tions, routes, and bounding boxes in geographical coordinates. By apply-
ing inheritance, the code used by the Swing framework can be accessed as
intended.
Again, the developer should always keep the two perspectives in mind:
the object's internal coding and its external behavior. A Swing component
perfectly describes this situation. The component's internal calculation is
visualized by the grid, and externally the component's size can be modi-
fied by the user (mouse), by Swing ( setBounds ), by the Swing application
( setBorder,setBackground ), or even by the operating system (arrange win-
dows), simultaneously. Casting components for each environment supports
a clean design. By casting the MapComponent to JComponent Swing can only
apply the methods pre-implemented in the framework.
5.8
Deploying the GPXviewer.jar
The GPX viewer is a useful application to visualize GPS information re-
trieved from GPX files. The GPXviewer.java file combines the components
MapPanel and GPSunit . The reader should go through the code to identify
the GUI features and how the components are integrated.
To support developers in visualizing GPS information, the GPX viewer
can be deployed to a stand-alone application:
TheJavaTutorial>Deployment>PackagingProgramsinJARFiles
The Java Archive (JAR) file format enables you to bundle
multiple files into a single archive file ... how to customize
manifest les to set an application's entry point.
 
Search WWH ::




Custom Search