//
// SnowflakeApplet.java
// Applet for drawing snowflake (fractal-like) using recursion
// Based on
// http://chortle.ccsu.ctstateu.edu/CS151/Notes/chap74/ch74_4.html
//
// Nadeem Abdul Hamid
// CSC121 - Berry College - Spring 2005
//

import java.awt.*;
import javax.swing.*;


public class SnowflakeApplet extends JApplet
{

    SnowflakePanel flakepane;   // panel object (inner class defined below)
    
    // add the snowflake panel to the center area of the applet pane
    public void init() 
    {
	flakepane = new SnowflakePanel();

	Container pane = getContentPane();
	pane.setLayout( new BorderLayout() );
	pane.add( flakepane, BorderLayout.CENTER );
    }



    // this inner class defines the panel that draws the actual
    // snowflake in the applet
    class SnowflakePanel extends JPanel
    {
	
	private int minsize;   // length at which to stop drawing flakes
	private int points;    // number of points in star
	private int sizemult;  // size multiplier
	

	// constructor sets initial values for the drawing parameters
	public SnowflakePanel() 
	{
	    minsize = 2;
	    points = 7;
	    sizemult = 3;
	}

	// mutator methods to change the parameters of the snowflake drawing
	public void setMinSize( int newsize ) 
	{
	    minsize = newsize > 0 ? newsize : minsize;
	} // end method setMinSize

	public void setPoints( int newval ) 
	{
	    points = newval > 1 ? newval : points;
	}
	
	public void setSizeMult( int newval ) 
	{
	    sizemult = newval > 1 ? newval : sizemult;
	}
	

	// drawFlake method draws a flake 
	// parameters:
	// (x,y) - center of snowflake
	// size  - length of a line of the snowflake
	// col - color in which to draw the snowflake
	public void drawFlake( Graphics g, int x, int y, int size, Color col ) 
	{
	    
	} // end method drawFlake


	public void paintComponent( Graphics g )
	{
	    super.paintComponent( g );
	    
	    int w = getSize().width;
	    int h = getSize().height;
	    int min = w < h ? w : h;

	    // star is drawn in the middle of the screen, with length
	    // one-third the size of the screen in black color

	    drawFlake( g, __FILL-IN__ , __FILL-IN___, min/3, Color.BLACK );

	} // end method paint
	
    } // end class SnowflakePanel
    

} // end class SnowflakeApplet