// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   Chart2D.java

package lt.monarch.chart.chart2D;

import java.awt.*;
import lt.monarch.chart.*;

// Referenced classes of package lt.monarch.chart.chart2D:
//			Axis2DX, Axis2DY, Projector2D

public class Chart2D extends AbstractChart
{

	protected final int border = 10;
	protected Projector2D projector;
	protected ChartObject objects[];
	protected Axis2DX axisB;
	protected Axis2DY axisL;
	protected Axis2DY axisR;

	public Chart2D()
	{
		projector = new Projector2D();
	}

	public void enableAspectRatio11()
	{
		projector = new Projector2D();
	}

	public void paint(Graphics g)
	{
		super.paint(g);
		if(objects == null)
			return;
		for(int i = 0; i < objects.length; i++)
			objects[i].draw(g);

	}

	protected void prepareChart(Graphics g)
	{
		if(axisB != null)
			axisB.prepare();
		if(axisL != null)
			axisL.prepare();
		if(axisR != null)
			axisR.prepare();
		int i = axisR == null ? 0 : axisR.width(g);
		int j = axisL == null ? 0 : axisL.width(g);
		int k = axisB == null ? 0 : axisB.height(g);
		Rectangle rectangle = new Rectangle(super.area.x + 10 + j, super.area.y + 10, super.area.width - j - i - 20, super.area.height - k - 20);
		projector.setProjectionArea(rectangle);
	}

	public Projector projector()
	{
		return projector;
	}

	public void reset()
	{
		if(objects != null)
		{
			for(int i = 0; i < objects.length; i++)
				objects[i].setChart(null);

		}
		objects = null;
		requestPreparation();
	}

	public void setLAxis(Axis2DY axis2dy)
	{
		axisL = axis2dy;
		axisL.alignRight = false;
		requestPreparation();
	}

	public void setObjects(ChartObject achartobject[])
	{
		reset();
		objects = achartobject;
		for(int i = 0; i < objects.length; i++)
			objects[i].setChart(this);

	}

	public void setRAxis(Axis2DY axis2dy)
	{
		axisR = axis2dy;
		axisR.alignRight = true;
		requestPreparation();
	}

	public void setXAxis(Axis2DX axis2dx)
	{
		axisB = axis2dx;
		requestPreparation();
	}

	public String tipAt(Point point)
	{
		String s = null;
		for(int i = objects.length - 1; i >= 0 && s == null; i--)
			s = objects[i].tipAt(point);

		return s;
	}
}
