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

import static com.github.davidmoten.grumpy.core.Position.position;

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 com.github.davidmoten.grumpy.core.Position;
import com.github.davidmoten.grumpy.projection.Projector;
import com.github.davidmoten.grumpy.wms.Layer;
import com.github.davidmoten.grumpy.wms.RendererUtil;
import com.github.davidmoten.grumpy.wms.WmsRequest;
import com.github.davidmoten.grumpy.wms.WmsUtil;

public class CustomLayer implements Layer {

	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) {

		RendererUtil.useAntialiasing(g);

		Projector projector = WmsUtil.getProjector(request);
		{
			// draw a border around Canberra and shade it.
			List<Position> list = new ArrayList<Position>();
			list.add(position(CANBERRA_LAT - 2, CANBERRA_LON - 4));
			list.add(position(CANBERRA_LAT + 2, CANBERRA_LON - 4));
			list.add(position(CANBERRA_LAT + 2, CANBERRA_LON + 4));
			list.add(position(CANBERRA_LAT - 2, CANBERRA_LON + 4));
			list.add(position(CANBERRA_LAT - 2, CANBERRA_LON - 4));

			// join the positions using great circle paths
			Shape shape = RendererUtil.getPath(projector, list);
			g.setColor(Color.white);

			// fill the box with white
			g.fill(shape);

			// draw border in blue
			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));
		g.drawString(CANBERRA, p.x + 5, p.y);

	}

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

}

@@ -981,13 +981,8 @@
 t);%0A
-%09%09%7B%0A%09
 %09%09//
@@ -1028,17 +1028,16 @@
 e it.%0A%09%09
-%09
 List%3CPos
@@ -1077,17 +1077,16 @@
 ion%3E();%0A
-%09
 %09%09list.a
@@ -1127,33 +1127,32 @@
 ERRA_LON - 4));%0A
-%09
 %09%09list.add(posit
@@ -1187,33 +1187,32 @@
 RA_LON - 4));%0A%09%09
-%09
 list.add(positio
@@ -1243,33 +1243,32 @@
 ERRA_LON + 4));%0A
-%09
 %09%09list.add(posit
@@ -1311,17 +1311,16 @@
  4));%0A%09%09
-%09
 list.add
@@ -1370,17 +1370,16 @@
 4));%0A%0A%09%09
-%09
 // join 
@@ -1417,17 +1417,16 @@
 e paths%0A
-%09
 %09%09Shape 
@@ -1474,17 +1474,16 @@
 ist);%0A%09%09
-%09
 g.setCol
@@ -1496,25 +1496,24 @@
 or.white);%0A%0A
-%09
 %09%09// fill th
@@ -1530,16 +1530,73 @@
  white%0A%09
+%09// transparency is deferred to the wms client framework%0A
 %09%09g.fill
@@ -1605,17 +1605,16 @@
 hape);%0A%0A
-%09
 %09%09// dra
@@ -1632,17 +1632,16 @@
  blue%0A%09%09
-%09
 g.setCol
@@ -1656,17 +1656,16 @@
 .blue);%0A
-%09
 %09%09g.draw
@@ -1676,12 +1676,8 @@
 pe);
-%0A%09%09%7D
 %0A%0A%09%09

update readme remove nz box