Updated on February 7, 2005

Introduction

This Kaleidoscope program was developed as a case study of object-oriented design and as a test bed for graphics tools for dealing with shapes and images including Bézier curves. The program creates a picture involving random shapes and images and then runs a kaleidoscope animation in which a pair of mirrors reflects this picture continuously around the graphics window. If desired, a string with the word “Kaleidoscope” may be superimposed on the shapes and images and animated as well. Many parameters of the animation may be changed while the animation is running and the objects being animated can themselves be continuously mutated in real time. When the animation is not running, the user may drag the shapes, images, and “Kaleidoscope” string around the graphics window using the mouse.

The origin of this case study came from my participation in the Killer Examples workshop organized by Carl Alphonce, Zung Nguyen, Stephen Wong, and Phil Ventura at OOPSLA 2002. See: Killer Examples, OOPSLA 2002. In particular, another workshop participant, Michael Wick, presented a Kaleidoscope animation suitable for use as a demonstration program early in freshman computer science. This example is available from the above site.

I became interested in the question of whether a more elaborate Kaleidoscope animation would be valuable for a more advanced audience, namely, for upper level students in courses on Object-Oriented Design and/or Software Development. I therefore explored the question of how to build a class and interface structure that would support a very general mechanism for creating and displaying mutatable shapes, images, and text and then transforming these under affine transformations. In my opinion, the resulting structures are quite elegant and will indeed serve as an appropriate case study for advanced students.

The revised Kaleidoscope animation was presented at the Killer Examples, OOPSLA 2003. workshop. By careful refactoring, the Kaleidoscope Source now contains the code specific to the Kaleidoscope application and its test code while the most general classes in this case study have migrated into the Java Power Tools 2.3 (Related JPT Source).

Zip Archive

The Kaleidoscope Files and sample images in zip format

The Kaleidoscope Files and sample images in self extracting exe format

Note that the Kaleidoscope source files must be linked with the Java Power Tools library jpt.jar.

Kaleidoscope Source

The Java file KaleidoscopeApplication.java

To execute the Kaleidoscope application in a standalone fashion, use the main program in the Java class KaleidoscopeApplication.java. This class builds the Kaleidoscope graphical user interface and controls the animation.

The Java file KaleidoscopeTests.java

To execute the Kaleidoscope application in the context of its Java Power Framework test suite, use the main program in the Java class KaleidoscopeTests.java instead. This is strongly recommended since it will expose the testing process that was at the heart of the development process. Indeed, this class and the related test classes are an excellent tutorial on the use of the Java Power Framework. There are now many test classes included that show the recent features added to JPT.

The Java file Kaleidoscope.java

This class encapsulates the Kaleidoscope mirror algorithm that creates a kaleidoscopic image by repeated mirror reflection of a pie wedge section extracted from a picture.

The Java file PieWedge.java

The geometry of a pie wedge is encapsulated in this class.

The Java file KaleidoscopePicture.java

This class manages the creation and display of the shapes, images, and text shown in the graphics window.

The Java file RandomPaintable.java

This class is a helper class for the class KaleidoscopePicture. It manages the random generation of a picture using random shapes and random images.

The Java file KaleidoscopeWidgets.java

This class creates the individual controls in the Kaleidoscope GUI.

The Java file KaleidoscopePanels.java

This class creates the nested panels that build the Kaleidoscope GUI from the individual controls and the graphics window.

The Java file KaleidoscopeAnimation.java

This class manages the kaleidoscope animation of the picture in the graphics window.

The Java file KaleidoscopeMouseInfo.java

This class enables editing of the picture by dragging the mouse as long as the animation is not running. Note that, if the option Show Wedge Always is enabled, then the mouse is active only within the kaleidoscope wedge.

The remaining classes test various aspects of the tools and related features of JPT but are not required for the standalone Kaleidoscope application.

The Java file FontSampler.java

This class tests the ability to access all available fonts and to obtain the metrics for particular strings.

The Java file TestTextOutline.java

This class tests the ability to drag text using the mouse.

The Java file OpenCurveMiniEdit.java

This class tests tools for cubic shapes.

The Java file CircleSample.java

This class tests the revised ColorView class that internally uses an OptionsView with color names. The ColorView selects the color for painting a circle in a small window.

The Java file CheckerBoard.java

This class tests the revised ColorView class that internally uses an OptionsView with color names A pair of ColorView's permit the user to constrast colors painted in a checkerboard pattern.

The Java file TestStringViews.java

This class tests StringObjectView's.

The Java file TestRadioViews.java

This class tests the radio button views.

The Java file CardFun.java

This class tests the tools for loading images (in this case images of playing cards) and for inserting such images in a PaintableSequence that is then displayed in a way that permits the images to be dragged with the mouse.

Access to the Kaleidoscope Images.

Access to the Playing Card Images.

Note that the Kaleidoscope source files must be linked with the Java Power Tools library jpt.jar.

Related JPT Source

See the Annotated JPT Java Source Files and under edu.neu.ccs.gui, look for the sections on Graphics Classes and Shape Creation Classes.

Contact Information