|
|
Java applet source code and documentation
by F. Crusius, Dec. 2000
|
|
|
|
ImageLink applet running with embedded applets
|
|
SimpleIFS
|
PingPong
|
Boing
|
|
|
Download source code
|
You can use the source code for the applets above any way you
like. Note that it comes "as is" with absolutely no warranty.
For ideas and background material, a list of
acknowledgements is given at the end of this page.
|
|
General information
|
The source code zip file contains Borland JBuilder 3.5 project files. All source
modules can be built with JDK 1.2.x and JDK 1.1.8. For each project, a subdirectory
jdk11 contains a simple bourne shell script to build JDK 1.1 jar archives. Though
all applets behave fine with JDK 1.2, a variety of recent browsers is only capable
of running JDK 1.1 applets. To use the shell scripts, you may have to adapt the
path to your JDK 1.1 binaries.
The classes were modeled using Together Control Center 4.2. I provided
Together projects with models as well.
All files from the zip archive are in UNIX text format, using "\n" for line feed
rather than IBM PC style "\r\n". If that is a problem for you, just open and modify
the files with wordpad.exe.
For additional information on applet parameters, refer to the parameterInfo provided
by the applets or the source code.
The applets have been tested with Netscape 4.6 and MS-IE 4.0.
|
|
ImageLink applet
|
The purpose of the ImageLink applet is to provide a means for individually designing
toolbars with URL links assigned to each toolbar link field. A link field can
contain standard AWT buttons, images or applets. The applets running on
top of this page demonstrate the link field options. It should be possible to run
any Java applet within an ImageLink link field.
On this page, the applets embedded in ImageLink link fields run standalone below.
The page source should give you an idea on how to pass applet parameters from the
ImageLink applet to contained applets.
|
Parameter
|
Format
|
Info
|
|
audioClip
|
Pathname
|
Path and name of an audio clip file to be played when a link field gets activated.
|
|
orientation
|
1 Character
|
"h" for horizontical or "v" for vertical orientation of the toolbar.
|
|
labelSize
|
Integer
|
Width/height of the label pane in pixels.
|
|
labelFont
|
Font name;Integer
|
The name of the font to be used for the label, followed by a ";" and the integer font
size.
|
|
background
|
6 Hex digits (0xffffff)
|
Color of the applet background for both the link and the label panel.
|
|
linkPanelBackground
|
6 Hex digits (0xffffff)
|
Color of the background of the link panel. Overwrites the background value.
|
|
labelPanelBackground
|
6 Hex digits (0xffffff)
|
Color of the background of the label panel. Overwrites the background value.
|
|
labelBackground
|
6 Hex digits (0xffffff)
|
Color of the background of the labels. Overwrites the labelPanelBackground value.
|
|
gap
|
Integer
|
Gap in pixels between the link fields.
|
|
|
SimpleIFS applet
|
The SimpleIFS applet demonstrates some principles in the computation of fractal
sets. The same operation is applied to ever smaller areas again and again. At present,
four different sets or IFSObject classes are implemented. Using these, SimpleIFS
can display CauchyRectangles and three types of iterated function systems (IFS). The
SierpinskiTriangleIFSObject uses probabilities to apply its transformations to the
original set - therefore the resulting set differs every time the applet is run. If
you watch closely, you will notice that the triangles that appear to be placed at
random by the SierpinskiTriangle IFS form several larger triangles themselves.
|
Parameter
|
Format
|
Info
|
|
SleepInterval
|
Integer
|
Time in milliseconds between iteration steps
|
|
background
|
6 Hex digits (0xffffff)
|
Color of the background of the IFS, that is the color of the rectangle that
fills the whole applet window.
|
|
foreground
|
6 Hex digits (0x000000)
|
Color of the foreground of CauchyRectangle, that is the color of the ever smaller
rectangles.
|
|
IFSObjectClassN
|
Class name followed by integer index
|
Class of an IFSObject that implements the operations for a specific set.
|
|
|
PingPong applet
|
The PingPong applet shows an arbitrary number of moving and spinning geometrical
objects, being reflected at the applet borders. The colors of the objects and the
applet background can be adjusted to fixed and changing colors. Also, the start
position, direction and speed of movement of the objects can be adjusted by parameters.
Generally, the parameters for diffenrent object attributes are separated by ";".
Objects are described by a basic geometrical figure (i.e. "Ball", "Oval", "Rect",
"Poly", "Star", "CogWheel", "PunchedCogWheel", "DoubleCogWheel"). Next comes the
object's Hex color followed by an integer color shifter value. All other attributes
depend on the kind of figure described.
Objects get parameter names Object<n>, e.g. Object0, Object1, ... . Objects are
numbered in Z-order, making Object0 the lowermost being covered by all other Objects.
Figures can be assigned any object number, as long as they form an uninterrupted zero
based sequence. For simplification, the possible figure names will be given parameter
names Object0 ... ObjectX.
|
Parameter
|
Format
|
Info
|
|
SleepInterval
|
Integer
|
Time in milliseconds between moving all objects
|
|
background
|
6 Hex digits (0xffffff);Integer
|
Color of the background of PingPong applet, followed by an integer color shifter
value. Every time the objects are moved, the RGB color values are incremented or
decremented by the color shifter value, giving the impression of continually changing
colors.
fills the whole applet window.
|
|
Object0
|
Attributes separated by ";".
Ball;0xff00ff;1;20;30;2;5;6
|
Figure name "Ball", Color=0xff00ff, Color shifter=1, x-start=20, y-start=30,
moved 2 pixels in x-direction each step, moved 5 pixels in y-direction each step,
diameter=6 pixels.
|
|
Object1
|
Attributes separated by ";".
Oval;0x0000ff;3;40;80;2;4;20;40
|
Figure name "Oval", Color=0x0000ff, Color shifter=3, x-start=40, y-start=80,
moved 2 pixels in x-direction each step, moved 4 pixels in y-direction each step,
x-diameter=20 pixels, y-diameter=40 pixels.
|
|
Object2
|
Attributes separated by ";".
Rect;0x00ff00;9;30;90;5;18;8;8
|
Figure name "Rect", Color=0x00ff00, Color shifter=9, x-start=30, y-start=90,
moved 5 pixels in x-direction each step, moved 18 pixels in y-direction each step,
x-diameter=8 pixels, y-diameter=8 pixels.
|
|
Object3
|
Attributes separated by ";".
Poly;0x0000ff;0;50;50;1;1;1; -10;0;10;0;10;20;0;30
|
Figure name "Poly", having an arbitray number of corners. Color=0x0000ff,
Color shifter=0, x-start=50, y-start=50, moved 1 pixels in x-direction each step,
moved 1 pixels in y-direction each step, rotation=1 degree each step, Corner0(-10,0),
Corner1(10, 0), Corner3(10, 20), Corner4(0, 30).
|
|
Object4
|
Attributes separated by ";".
Star;0xff0000;1;200;100;2;3;1; 5;40;70;0.5
|
Figure name "Star", having an arbitray number of corners. Color=0xff0000,
Color shifter=1, x-start=200, y-start=100, moved 2 pixels in x-direction each step,
moved 3 pixels in y-direction each step, rotation=1 degree each step, 5 corners,
x-diameter=40, y-diameter=70, ToothRatio=0.5.
|
|
Object5
|
Attributes separated by ";".
CogWheel;0x00ff00;1;100;200; 5;2;-1;12;120;120;0.75;0.9;0.79
|
Figure name "CogWheel", having an arbitray number of teeth. Color=0x00ff00,
Color shifter=1, x-start=100, y-start=200, moved 5 pixels in x-direction each step,
moved 2 pixels in y-direction each step, rotation=-1 degree each step, 12 corners,
x-diameter=120, y-diameter=120, ToothRatio=0.75, Outer flat ratio=0.9,
Inner flat ratio=0.79. The "flat ratios" determine how much the star's prongs will
be flattened to form a cogwheel tooth.
|
|
Object6
|
Attributes separated by ";".
PunchedCogWheel;0xff0000;1; 0xffffff;1;100;200;5;2;-1;
10;100;150;0.75;0.9;0.79;0.3
|
Figure name "PunchedCogWheel", having an arbitray number of teeth. The cogwheel
gets an oval punch in its middle. Color=0xff0000, Color shifter=1,
Punch color=0xffffff, Color shifter=1,x-start=100, y-start=200, moved 5 pixels in x-direction each step,
moved 2 pixels in y-direction each step, rotation=-1 degree each step, 10 corners,
x-diameter=100, y-diameter=150, ToothRatio=0.75, Outer flat ratio=0.9,
Inner flat ratio=0.79, punch ratio=0.3. The "flat ratios" determine how much the star's prongs will
be flattened to form a cogwheel tooth. The punch ratio determines the diameter of the punch
relative to the unflattened cogwheel diameter.
|
|
Object7
|
Attributes separated by ";".
DoubleCogWheel;0x00ffff;1;
0xffffff;1;200;100;3;4;1;
10;140;140;0.75;0.9;0.79;
0.5;0.8;0.9;0.81
|
Figure name "DoubleCogWheel", having an arbitray number of teeth. The cogwheel
is punched by a second cogwheel in its middle. Color=0x00ffff, Color shifter=1,
Punch color=0xffffff, Color shifter=1,x-start=200, y-start=100, moved 3 pixels
in x-direction each step, moved 4 pixels in y-direction each step, rotation=1
degree each step, 10 corners, x-diameter=140, y-diameter=140, ToothRatio=0.75,
Outer flat ratio=0.9, Inner flat ratio=0.79, inner cogwheel punch ratio=0.5.
Inner cogwheel toot ratio=0.8, inner cogwheel outer flat ratio=0.9, inner cogwheel
inner flat ratio=0.81.
|
|
|
Boing applet
|
The Boing applet simply moves an oval over a background of two rectangles.
|
Parameter
|
Format
|
Info
|
|
SleepInterval
|
Integer
|
Time in milliseconds between moves of oval
|
|
MarginRatio
|
Integer
|
Ratio withX / dX (With and movement of oval.
|
|
iL
|
Integer
|
Color shift increment of left rectangle
|
|
iR
|
Integer
|
Color shift increment of right rectangle
|
|
iO
|
Integer
|
Color shift increment of moving oval
|
|
cL
|
Hex
|
Hexadecimal RGB start color of left rectangle
|
|
cR
|
Hex
|
Hexadecimal RGB start color of right rectangle
|
|
cO
|
Hex
|
Hexadecimal RGB start color of moving oval
|
|
|
Acknowledgements
|
|
Thinking in Java, Bruce Eckel,
www.bruceeckel.com
|
|
Design Patterns - Elements of Reusable
Object-Oriented Software, Gamma, Helm, Johnson, Vlissides, Addison-Wesley
|
|
Java in a Nutshell, David Flanagan, Second Edition, O'Reilly
|
|
Java 1.2 in 21 Days, Laura Lemay & Rogers Cadenhead, SAMS
|
|
Mathematik fürs Auge - Eine Einführung
in die Welt der Fraktale, Horst Halling & Rolf Möller, Spektrum Akademischer Verlag
|
|
|