import java.util.ArrayList; import java.util.List; /** *
* This class represents the data points for a given storm track. * Specifically it is used to generate the Javascript code representing an array * of GLatLng objects for use with the Google Maps API. *
* @author Mark Woehrer * @version 1a4 */ public class StormTrack { /** The list of points describing a storm track */ List* @return A String suitable for use with Javascript */ public String toString() { String string = new String(); string += "["; for(LatLng point : list) { string += " new GLatLng(_point_),"; string = string.replaceAll("_point_", point.toString()); } string += " ]"; return string; } /** * This is the test method for the class. * @param args */ public static void main(String[] args) { // Create a new StormTrack object StormTrack track = new StormTrack(); // Add a few test data points from Andrew 1992 track.addSample(new LatLng(10.8, -35.5)); track.addSample(new LatLng(25.6, -67.0)); track.addSample(new LatLng(29.2, -91.3)); // Test the toString() method System.out.println(track); } }