// **********************************************************************
//
//
* 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);
}
}