package vgp.iterate.juliaSet;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Rectangle;

import jv.object.PsPanel;
import jv.object.PsViewerIf;
import jv.project.PjProject;
import vgp.object.PsApplet;

/**
 * Applet shows a Julia set and a Mandelbrot set where the Julia set is determined
 * by picking a complex parameter c which is picked in the Mandelbrot image.
 * Picking in the Julia display will show several iterations of the picked point.
 * <p>
 * Demo applet for working with pixel images. 
 * 
 * @see			jv.viewer.PvViewer
 * @author		Konrad Polthier
 * @version		03.09.07, 4.00 revised (kp) Full rewrite, superclass changed to PsApplet.<br>
 * 				04.11.06, 3.00 revised (kp) Moved to vgp.iterate.juliaSet and renamed.<br>
 *					01.10.05, 2.10 revised (kp) User interface improved.<br>
 *					10.08.05, 2.00 revised (kp) Functional extensions and efficiency optimization.<br>
 *					26.09.99, 1.00 created (kp) 
 */
public class PaJuliaSet extends PsApplet {
	/** Interface of applet to inform about author, version, and copyright */
	public String getAppletInfo() {
		return "Name: "		+ this.getClass().getName()+ "\r\n" +
				 "Author: "		+ "Konrad Polthier" + "\r\n" +
				 "Version: "	+ "2.00" + "\r\n" +
				 "Applet shows usage of images in display" + "\r\n";
	}
	/** Return a new allocated project instance. */
	public Rectangle getSizeOfFrame() {
		return new Rectangle(380, 5, 640, 620);
	}
	/** Return a new allocated project instance. */
	public PjProject getProject() {
		return new PjJuliaSet();
	}
	/**
	 * Standalone application support. The main() method acts as the applet's
	 * entry point when it is run as a standalone application. It is ignored
	 * if the applet is run from within an HTML page.
	 */
	public static void main(String args[]) {
		main(new PaJuliaSet(), args);
	}
	/**
	 * Configure and initialize the viewer, load system and user projects.
	 * <p>
	 * Overrides the run() method of PsApplet to specify an individual layout.
	 */
	public void run() {
		drawMessage("Loading project ...");
		PjJuliaSet pjJulia = (PjJuliaSet)getProject();
		m_viewer.addProject(pjJulia);
		m_viewer.selectProject(pjJulia);

		// Must be called after registration of project in m_viewer
		// since m_viewer need in method getDispMandelbrot().
		pjJulia.addDisplay(pjJulia.getDispMandelbrot());
		
		// Get 3d display from viewer and add it to applet
		setLayout(new BorderLayout());
		add(pjJulia.getInfoPanel(), BorderLayout.CENTER);
		PsPanel pDisplay = new PsPanel(new GridLayout(1, 2));
		{
			pDisplay.setPreferredSize(640, 256);
			pDisplay.add(pjJulia.getDispJulia().getCanvas());
			pDisplay.add(pjJulia.getDispMandelbrot().getCanvas());
		}
		add(pDisplay, BorderLayout.NORTH);
		validate();

		// Choose initial panel in control window (must press F1 inside the applet)
		m_viewer.showPanel(PsViewerIf.MATERIAL);

		// Explicitly start the applet
		startFromThread();
	}
}
