/* Copyright 1996 Matthew Freedman and University of Washington mattf@cac.washington.edu This program may be freely used, modified, or redistributed for any non-commercial purpose as long as credit is given. This is a simple applet for embedding a Nina figure in a page. There is no user interface, just the drawing-engine, so all figure parameters are created randomly. However you can control a number of aspects of the figures that will appear through the following applet parameters: seed: An integer to be used as a seed to the random number generator. If this is not provided the system clock is used as the seed. But if you have more than one Nina on the same page, they are likely to get the same seed, and hence draw the same sequence of figures. So if you have multiple Ninas on a page, it is best to give them each their own seed (Note that a given seed will not generate the same figures each time it is loaded). background: What color to use as the backdrop. Acceptable values are "black" and "white". Default is "black". max_lines: The maximum number of lines that will appear in a figure. Default value is 2000. max_colors: The maximum number of colors to use per figure. The default value is 4. show_animation: Should the individual line-drawing be shown? Acceptable values are "true" and "false". Default is "true". line_delay: If show_animation is true, how many milliseconds to pause between each line drawn. The default value is 5. auto_draw: Should new figures automatically be drawn, or should Nina only redraw on mouse-click? Acceptable values are "true" and "false", the default is "true". figure_delay: How many seconds to pause before drawing a new figure. The default is 5. */ import java.awt.*; public class MiniNina extends java.applet.Applet implements Runnable { Nina nina; NinaParams p; Thread runner; String param_str; public void init() { setLayout(new GridLayout(1, 1, 0, 0)); add(nina = new Nina()); validate(); param_str = getParameter("seed"); if (param_str == null) p = new NinaParams(); else p = new NinaParams(Integer.parseInt(param_str)); if ((param_str = getParameter("background")) != null) if (param_str.equals("white")) p.bg_color = Color.white; if ((param_str = getParameter("max_lines")) != null) p.max_lines = Integer.parseInt(param_str); if ((param_str = getParameter("max_colors")) != null) p.max_colors = Integer.parseInt(param_str); if ((param_str = getParameter("show_animation")) != null) if (param_str.equals("false")) p.show_lines = false; if ((param_str = getParameter("line_delay")) != null) p.ldelay = Integer.parseInt(param_str); p.auto_draw = true; if ((param_str = getParameter("auto_draw")) != null) if (param_str.equals("false")) p.auto_draw = false; if ((param_str = getParameter("figure_delay")) != null) p.fdelay = Integer.parseInt(param_str); p.setup(); } /* Start and stop threads */ public void start() { if (runner == null); { runner = new Thread(this); runner.start(); } } public void stop() { nina.die(); if (runner != null) { runner.stop(); runner = null; } } public void run() { nina.drawFig(p, null); } }