Project #3--Extra Credit (Due December 9th, 2005)

Tree of Colors

Develop an application that allows a user to pick colors from a colorchooser and add them to an AVL tree.

as you may know with three primary colors Red, Green, and Blue, it is difficult to assess whether one color is lighter or darker than another.

Our color tree tool is designed to help in understanding brightness and darkness of colors. The affect that the amount of any of the primary colors have in creating a new color on how we perceive it as lighter or darker than another can be examined with this tool. .

Writing an application that utilizes swing's JColorChooser is fairly easy. Color Chooser Demo should demonstrate how it works.

We are going to employ a topology that is fairly straight forward. Compare summation of red, green, and blue values of one color against another; if they are different by more than a certain amount (delta), we assume the one with a bigger sum is brighter. If the sums are too close, then, we need to revert to comparing their three values for the RGB in a pre-established order and the color that has more of one of these primary colors will be identified as brighter. Obviously, one could spent a great deal of time coming up with such topologies or examining different ones, but this one will be ours.

You may also find that during this exercise it will be too close to visually find one color brighter just because it has a little bit more red than green. But, the primary objective of the tool, again, is to help one better understand the role of the primary colors in determining lightness and darkness and not for establishing a natural ordering of all colors.

The delta value represents the minimum amount of difference between the sum of the three primary colors for two color objects when determining one is brighter than the other. For example, suppose delta is 75; when RGB values for one color are (0,0,0), which implies the color object is black, and another color's RGB is (50,20,10), the 2nd color is brighter than the first. This is because if you add the three values for each color, the difference is more than the delta value.

If the difference in the sums of the RGBs of two color objects is less than the delta value, then we need to know in what order the primary colors have to be compared to determine which is brighter. In my version, in these cases, I check the red value first and unless they are the same I determine that the color with more red is brighter. If the two colors have the same amount of red, then their green values are compared, and so on.

The following image demonstrates how my version of the program interfaces with a user. I assumes a delta value of 75 and Red, Green, and Blue for the order of comparisons.


In your version, you will allow for setting of a delta value and the priority of the primary colors for comparisons when the application begins (the user must not be able to change these rules mid-game).

In developing this application, you will need to develop a couple of classes.