package com.github.davidmoten.geo.wms.demo;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Shape;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.davidmoten.geo.Position;
import com.github.davidmoten.geo.projection.Projector;
import com.github.davidmoten.geo.wms.Layer;
import com.github.davidmoten.geo.wms.RendererUtil;
import com.github.davidmoten.geo.wms.WmsRequest;
import com.github.davidmoten.geo.wms.WmsUtil;

public class CustomLayer implements Layer {

	private static final Logger log = LoggerFactory
			.getLogger(CustomLayer.class);

	private static final String CANBERRA = "Canberra";
	private static final double CANBERRA_LAT = -35.3075;
	private static final double CANBERRA_LON = 149.1244;

	@Override
	public void render(Graphics2D g, WmsRequest request) {
		Projector projector = WmsUtil.getProjector(request);

		// draw a border around Canberra and shade it.
		List<Position> list = new ArrayList<Position>();
		list.add(Position.create(CANBERRA_LAT - 2, CANBERRA_LON - 2));
		list.add(Position.create(CANBERRA_LAT + 2, CANBERRA_LON - 2));
		list.add(Position.create(CANBERRA_LAT + 2, CANBERRA_LON + 2));
		list.add(Position.create(CANBERRA_LAT - 2, CANBERRA_LON + 2));
		Shape shape = RendererUtil.getPath(projector, list);
		g.setColor(Color.white);
		g.fill(shape);
		g.setColor(Color.BLUE);
		g.draw(shape);

		// label Canberra
		Point p = projector.toPoint(CANBERRA_LAT, CANBERRA_LON);
		g.setColor(Color.RED);
		g.setFont(g.getFont().deriveFont(24.0f).deriveFont(Font.BOLD));
		log.info("drawing string at " + p);
		g.drawString(CANBERRA, p.x + 5, p.y);

	}

	@Override
	public String getInfo(Date time, WmsRequest request, Point point,
			Format format) {
		return "<html><p>Some information about the point you clicked on</p></html>";
	}

}

@@ -1144,33 +1144,33 @@
  CANBERRA_LON - 
-2
+4
 ));%0A%09%09list.add(P
@@ -1217,17 +1217,17 @@
 A_LON - 
-2
+4
 ));%0A%09%09li
@@ -1278,25 +1278,25 @@
 BERRA_LON + 
-2
+4
 ));%0A%09%09list.a
@@ -1347,17 +1347,82 @@
 A_LON + 
-2
+4));%0A%09%09list.add(Position.create(CANBERRA_LAT - 2, CANBERRA_LON - 4
 ));%0A%09%09Sh

add fill example