// 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:   JChartPanel.java

package lt.monarch.swing;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.*;
import lt.monarch.chart.Chart;
import lt.monarch.chart.ChartContainer;

public class JChartPanel extends JPanel
	implements ChartContainer
{

	protected Chart chart;

	private void updateChartSize()
	{
		Insets insets = getInsets();
		Dimension dimension = getSize();
		chart.setContainer(this, new Rectangle(insets.left, insets.top, dimension.width - insets.right - insets.left, dimension.height - insets.bottom - insets.top));
	}

	public Component getComponent()
	{
		return (Component)this;
	}

	public String getToolTipText(MouseEvent mouseevent)
	{
		return chart.tipAt(mouseevent.getPoint());
	}

	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		chart.paint(g);
	}

	public void addNotify()
	{
		super.addNotify();
		ToolTipManager.sharedInstance().registerComponent(this);
	}

	public void removeNotify()
	{
		super.removeNotify();
		ToolTipManager.sharedInstance().unregisterComponent(this);
	}

	public JChartPanel(Chart chart1)
	{
		setBackground(Color.white);
		chart = chart1;
		updateChartSize();
		addComponentListener(new ComponentAdapter()
	{

		public void componentResized(ComponentEvent componentevent)
		{
			updateChartSize();
		}
	});
	}


	

}
