NINANINA Source Code

NINA generates incredibly beautiful figures with a remarkably simple algorithm:

num_lines = some integer
a_pulse = some integer less than num_lines
b_pulse = some integer less than num_lines
for (count = 0; count < num_lines; count++) {
  cur_x = cos((-2*PI*a_pulse*count)/num_lines) +
  cur_y = sin((-2*PI*a_pulse*count)/num_lines) +
  draw line from (prev_x, prev_y) to (cur_x, cur_y)
  prev_x = cur_x; prev_y = cur_y;

On this page are links to each of the .java files that comprise NINA, along with a general explanation of what classes are in each file, and how those classes are used. For more detailed explanations, such as specific methods and variables that are available, follow the links, and read the header comments for the files. Feel free to send me questions/comments about the code.
Nina is the heart of NINA, a subclass of Canvas that draws pretty pictures. By NINA I mean the whole shebang, including the interface. Nina just means this core object.
A crucial class that encapsulates all the parameters necessary for Nina to draw a figure.
A small class, used for picking random colors. It has some slight optimizations for selecting better looking colors depending on whether the figure background is black or white.
A tiny sample applet that demonstrates how easily you can re-use just the above three pieces, and embed a Nina anywhere you like. Detailed information on how to embed MiniNina applets on your own web pages is available. Embedded MiniNina applets look like this:
A trivial interface definition, which an object that controls a Nina may want to implement.
You may have noticed that the NINA pages each contain five separate applets, placed in separate cells of a table. I mostly did this because it looks cool, and was not much harder. This file is the applet wrapper for the Nina object. It is the only piece that knows whether we are running in a floating window or inlined.
This is the applet that contains the three buttons. It has overall control over NINA, and handles the communications between the individual parameter controllers and the Nina object.
A small, but important class which is never actually instantiated. However the next three items are subclassed off of it.
The applet that holds Conrollers for Number of Lines, A Pulse and B Pulse.
The applet that holds Controllers for Show Animation and Auto Draw.
The applet that holds Controllers for Number of Colors and Palette.
A class hierarchy that builds individual Controller objects.
The classes that define the interactive color-chooser.