// ********************************************************************** // // ********************************************************************** // SimpleMap4 is modified from SimpleMap sample code from BBN Technologies // original Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/examples/simple/SimpleMap.java // SimpleMap4.java // // ********************************************************************** package com.bbn.openmap.examples.simple; import com.bbn.openmap.*; import com.bbn.openmap.gui.*; /** * This is a simple application that uses the OpenMap MapBean to show * a simple map application with a sample OMGrid layer. *

* This example shows: *

* @see RouteLayer */ public class Simple_OMGridTest { public static void main(String args[]) { // Create a Swing frame. The OpenMapFrame knows how to use // the MapHandler to locate and place certain objects. OpenMapFrame frame = new OpenMapFrame("Simple Map OMGrid Test"); // Size the frame appropriately frame.setSize(640, 480); try { // The BasicMapPanel automatically creates many // default components, including the MapBean and the // MapHandler. You can extend the BasicMapPanel class if // you like to add different functionality or different // types of objects. MapPanel mapPanel = new BasicMapPanel(); // Get the default MapHandler the BasicMapPanel created. MapHandler mapHandler = mapPanel.getMapHandler(); mapHandler.add(frame); // Get the default MapBean that the BasicMapPanel created. MapBean mapBean = mapPanel.getMapBean(); // Set the map's center mapBean.setCenter(new LatLonPoint(43.0f, -95.0f)); // Set the map's scale 1:10 million mapBean.setScale(10000000f) ; mapBean.setCenter(34.065f, -84.54f); // center for grid test layer LayerHandler layerHandler = (LayerHandler)mapHandler.get("com.bbn.openmap.LayerHandler"); //-------------- GridTestLayer ------------------------ // Create a GridTestLayer and add to map as top layer // GridTestLayer uses SimpleColorGenerator GridTestLayer gridTestLayer = new GridTestLayer(); gridTestLayer.setName("GridTest Layer"); gridTestLayer.setVisible(true); layerHandler.addLayer(gridTestLayer, 0); //------------------------------------------------------ // Display the frame frame.setVisible(true); } catch (MultipleSoloMapComponentException msmce) { // The MapHandler is only allowed to have one of certain // items. These items implement the SoloMapComponent // interface. The MapHandler can have a policy that // determines what to do when duplicate instances of the // same type of object are added - replace or ignore. // In this example, this will never happen, since we are // controlling that one MapBean, LayerHandler, // MouseDelegator, etc is being added to the MapHandler. } } }