package edu.calpoly.csc480.Entomo.Tile.OdorTile;

import java.awt.*;

import com.bcurry.www.awt.*;

import edu.calpoly.csc480.Entomo.Ant.*;
import edu.calpoly.csc480.Entomo.Tile.*;

public class OdorTileView extends TileView {
	public OdorTileView() {
	}

	public void setDocument(Tile tile)	{
		super.setDocument(tile);
		this.tile = (OdorTile)tile;
	}

	public void updateScheme() {
		if (tile != null) {
			if (tile.getOdor() == 0) {
				scheme = emptyScheme;
				text = null;
			}
			else {
				scheme = scentSchemes[tile.getOdor() / odorPerScheme];
			}
		}
	}

	public void paintIcon(Component c, Graphics draw, int x, int y) {
		super.paintIcon(c, draw, x, y);

		if (tile.getMeans() != null) {
			tile.getMeans().getAnt().getView().paintIcon(c, draw, x, y);
		}
	}

	protected static ColorScheme emptyScheme =
	 new ColorScheme(BasicColor.lightGray);

	protected static ColorScheme scentSchemes[];
	protected static int odorPerScheme;

	protected OdorTile tile;

	static {
		int numSchemes = 20;

		scentSchemes = new ColorScheme[numSchemes];
		odorPerScheme = (OdorTile.maxOdor+1) / numSchemes;
		
		for (
		 int scheme = 0, odor = 0;
		 scheme < numSchemes;
		 scheme++, odor += odorPerScheme
		) {
			scentSchemes[scheme] = new ColorScheme(BasicColor.renew(
			 BasicColor.magenta, 1.0F - (float)odor / OdorTile.maxOdor)
			);
		}
	}
}