SE-555 A4: GPS Position Observer In this assignment, you will implement the Observer pattern in a multi-threaded application that receives notifications of position updates from a (simulated) GPS device. Assignment Overview When you start your application, it should prompt the user for the name of a file containing GPS data (see the Resources section below for sample files). After the prompt, your application must create some Observers that attach to the GPS data server – the Subject. The specific function of the Observers – and the format of the data they display – will be specified by your instructor. In any case, when the Observers attach to the GPS data server, they change their displays whenever the Subject performs an update(). In the observers illustrated above, the latitude/longitude and elevation Observers are capable of subscribing and de-subscribing from the Subject via the button UI. The plotter Observer attaches to the Subject on startup in this example, but you may add the ability to subscribe and de-subscribe if you wish. Assignment Details The following class diagram illustrates the classes and interfaces that implement this application. Consider it as a general guideline for the structure of the application. You may depart from it in the details of the implementation of the concrete observer classes and GPSCoordinate class, but you must define and implement the Subject and Observer interfaces shown. If you feel you need to make major changes to this design, consult your instructor first. As a Subject, your implementation of GPSServer must be capable of accepting subscriptions from multiple Observers. The following sequence diagram illustrates the GPSClient creating a GPSServer (the Subject) and three Observers: ElevationObserver, PositionObserver, and PositionPlotter. After creating GPSServer, the GPSClient starts the GPServer. Internally, the GPSServer starts a secondary thread that periodically generates GPS data (simulated by reading it from a specified file). At the beginning, the PositionPlotter observer immediately subscribes to the GPSServer. At some later point, the user of the GPSClient application directs (via GUI interaction) the ElevationObserver and PositionObserver to subscribe (attach) to the GPSServer. Subsequent GPS data that is generated is propagated back to all subscribed Observers when the GPSServer internally calls notifyObservers(), which in turn iterates through the collection of Observers, calling each Observers’s update() method (on the secondary thread). In response, each Observer updates it’s current specific display of GPS data. Because UI updates cannot be invoked on any thread except the UI thread, the Observers have to use the SwingUtilities.invokeLater() method to invoke Swing methods. You may also want to browse through the javadoc (javadoc.zip click on index.html) corresponding to the methods in the classes above. Files and resources The GPS data files and GPSCoordinate.java can be downloaded from canvas (A4 folder). To read data from the file, you might want to use some of the following code: doubleReader = new Scanner(gpsFile); // one or more occurrences of commas, semicolons or whitespace doubleReader.useDelimiter(“[,;\s]+”); while( doubleReader.hasNextDouble() ) {// read each double recordNo++; Thread.sleep( DELAY ); //simulate delays between generation of coordinates double longitude = doubleReader.nextDouble(); double latitude = doubleReader.nextDouble(); double elev = doubleReader.nextDouble(); GPSCoordinate c = new GPSCoordinate(longitude, latitude, elev ); Printf (“%4d Lat: %10.6f, Long: %10.6f, El: %8.3f\n”, recordNo, latitude, longitude, elev); } Submission (DUE Thursday 5 pm) (Note that you do NOT need to actually plot the positions — a simple print message with coordinates values is enough) In addition to code, you are also required to create (using Enterprise Architect), a reverse-engineered UML Class diagram of your individual solution. Save the class diagram in a .pdf file and include it in your submission along with your .java files. When submitting your work, submit one zip folder per group containing ONLY: The “SRC” folder of your Eclipse Project, and the. PDF file on your ReverseEngineered UML Class Diagram. Wx: CodeHelp