// ********************************************************************** // // // // BBN Technologies, a Verizon Company // 10 Moulton Street // Cambridge, MA 02138 // (617) 873-8000 // // Copyright (C) BBNT Solutions LLC. All rights reserved. // // // ********************************************************************** // // $Source: /cvs/distapps/openmap/com/bbn/openmap/examples/crew/RouteLayer.java,v $ // $RCSfile: RouteLayer.java,v $ // $Revision: 1.12.2.1 $ // $Date: 2002/10/25 17:52:16 $ // $Author: dietrick $ // // ********************************************************************** package nr.tms.ymat.tmat; import java.awt.Color; import java.awt.Graphics; import java.awt.event.MouseEvent; import com.bbn.openmap.Layer; import com.bbn.openmap.omGraphics.*; import com.bbn.openmap.proj.Projection; import com.bbn.openmap.event.MapMouseListener; import com.bbn.openmap.event.ProjectionEvent; import com.bbn.openmap.event.SelectMouseMode; import com.bbn.openmap.event.NullMouseMode; /** * A sample Layer implementation. It demonstrates * how to write a Layer that can be added to the MapBean. *

* The key elements are the paint and * projectionChanged methods. *

* paint renders the Layer on the map. *

* projectionChanged is called whenever the map's * projection changes. The Layer should update its internal * state to reflect the new map view. This may mean acquiring * new data from a data source, such as a database, or it may * be as simple as re-projecting existing graphics. The * RouteLayer does the latter. A Layer that simply * displays a legend on top of the map might not do anything in * the projectionChanged method since its display * may be independent of the current projection. */ public class RouteLayer extends Layer { /** A list of graphics to be painted on the map. */ public OMGraphicList omgraphics; /** The current projection. */ private Projection projection; /** The currently selected graphic. */ private OMGraphic selectedGraphic; /** * Construct a default route layer. Initializes omgraphics to * a new OMGraphicList, and invokes createGraphics to create * the canned list of routes. */ public RouteLayer() { omgraphics = new OMGraphicList(); createGraphics(omgraphics); } public OMPoint createPoint(float lat1, float lng1, int radius, Color color, Color selColor) { OMPoint point = new OMPoint(lat1, lng1, radius); point.setLinePaint(color); point.setFillPaint(color); point.setSelectPaint(selColor); return point; } public OMGraphicList createGraphics(OMGraphicList graphics) { graphics.clear(); graphics.add(createPoint(-37.8f, 144.9f, 2, Color.red, Color.green)); return graphics; } public void projectionChanged(ProjectionEvent e) { projection =(Projection)e.getProjection().makeClone(); omgraphics.generate(projection); repaint(); } public void paint(Graphics g) { omgraphics.render(g); } }