/*
 * Copyright (C) 1998  Ralf Wiebicke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package de.rw7;

import java.awt.Button;
import java.awt.Choice;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.GridLayout;
import java.awt.Panel;

public class Diagram extends java.applet.Applet
{
	Display d;

	public void init()
	{
		final Dimension dim = getSize();
		dim.width = dim.height;
		add("CENTER", d = new Display(this, dim));

		Panel P = new Panel();
		Choice FunctionChoice;
		P.add(FunctionChoice = new Choice());
		FunctionChoice.addItem("(kein)");
		for (int i = 0; i < Functions.length; i++)
			FunctionChoice.addItem(Functions[i]);
		P.add(new Button("redraw"));
		P.add(new Button("Zoom Out"));
		P.add(new Button("Zoom In"));
		P.setLayout(new GridLayout(0, 1, 5, 5));
		add("EAST", P);
		doLayout();
	}

	public boolean action(Event e, Object arg)
	{
		if (e.target instanceof Choice)
		{
			d.setFunction(getByString((String) arg));
			return (true);
		}
		return (d.action(e, arg));
	}

	private String[] Functions = { "Feigenbaum", "InfPower" };
	private Function getByString(String s)
	{
		if (s == Functions[0])
			return (new Feigenbaum());
		if (s == Functions[1])
			return (new InfPower());
		return (null);
	}

}
