Example Programs (Introduction to Computer Graphics Using Java 2D and 3D)

All programs mentioned in the topic and additional ones can be downloaded at the online service to this book. Tables B.1 and B.2 refer to the pages where the programs are mentioned in the book. There is Table B.1 for Java 2D and Table B.2 for Java 3D programs. The programs are listed in alphabetical order.

Java class

Topic

ArcExample

Ellipse arc and segment

AreaExample

Union, intersection, difference and symmetric difference for areas

BufferedImageDrawer

Generic class for the use of double buffering for drawing a BufferedImage

ConvexCombTransforms

Animation based on convex combinations of transformations with an example of transforming two ellipses

CurveDemo

Drawing of lines, quadratic and cubic curves

DoubleBufferingClockExample

Animation with moving objects using double buffering with a moving clock as an example

DToCMorphing

Transformation of one object into another. The objects are modelled by curves defined over control points. The letter D is transformed into the letter C


GeneralPathCar

Example of a GeneralPath for the silhouette of a car

GradientPaintExample

Use of colour gradients

ImageLoadingExample

Loading a JPEG image

ImageSavingExample

Saving a JPEG image

LineEndings

Line endings and joints for thick lines

MorphingCandS

Uses the class TriangulatedImage for transforming two triangulated images into each other

MyFinishWindow

Class for closing a window

NonSynchronizedClock

Movements of a simple clock

RectangleEllipseExample

Rectangle and ellipse

RotationExample

Rotation

ScalingExample

Scaling

Java class

Topic

 

ShearingExample

Shear transformation

SimpleJava2DExample

First Java 2D example program

SimpleLetterC

Representation of the letter C with quadratic curves

SimpleLetterD

Representation of the letter D with quadratic curves

StrokingExample

Various dash patterns

TextExample

Drawing and modifying text

Texture2DExample

Drawing of textures

TransformationOrderExample

Importance of the order for transformations

TransformationOrderExampleR

Importance of the order for transformations

TransformationOrderExampleRT

Importance of the order for transformations

TransformationOrderExampleT

Importance of the order for transformations

TransformationOrderExampleTR

Importance of the order for transformations

TranslationExample

Translation

TriangulatedImage

Class for triangulated images which can be transformed into each other by pixel and colour interpolation

Java class

Topic

 

BackgroundExample

An image from file as background. This program requires the file sunset.jpg. A background with a homogeneous colour can be found in the program StaticSceneExample

ClippingPlanes

Modification of the clipping volume by the angle for the field of view and the front and the back clipping plane

CollisionBehaviour1

A class that is used in CollisionExample in order to change the colour of an object when a collision occurs. A Switch is used here

CollisionBehaviour2

A class that is used in CollisionExample in order to move an object when a collision occurs

CollisionExample

Example for the application of collision detection. Uses also a Switch and navigation via keyboard commands. The classes CollisionBehaviour1 and CollisionBehaviour2 are needed

ConstantFloatCreator

Implements the Interface IFloatCreator

ConstantLongCreator

Implements the Interface ILongCreator

ConstantVector3fCreator

Implements the Interface IVector3fCreator

DynamicSurfaceExample

Carries out morphing of one surface into another one. IFunctionInTwoVariables, FunctionInTwoVariablesExample FunctionInTwoVariablesExample2 and SimpleMorphBehaviour are required

ExpFogExample

Exponential fog and the multiple use of transformation group in a scene as a Link

Table B.2

Java class

Topic

 

Extract3DExample

Loading an object from a file in Wavefront Object Format. Only a selected part of the whole object is included in the scene. The file schiff.obj is required

FunctionInTwo-

VariablesExample

Implements the Interface

IFunctionInTwoVariables which is needed in the class SurfaceExample

GeomArrayExample

Definition of an object (tetrahedron) with triangles

IDirectionCreator

An Interface to generate the directions of movement of particles

IFloatCreator

An Interface to generate the velocity of particles

IFunctionInTwoVariables

An Interface to describe a real-valued function of two variables

ILongCreator

An Interface to generate the time between the creation of two consecutive particles and to define the life span of a particle

InteractionExample

Picking objects with the mouse and initiating movements. The class PickingExample is needed

InteractionTest

Picking objects with the mouse. Using the class PickingTest the name of the picked object is printed

ISimpleParticleCreator

An Interface in the package

simpleParticleSystemPackage to generate single particles

IVector3fCreator

An Interface to generate the initial position of a particle

LightingExample

Use of different light sources and different reflection properties of surfaces

LightingExample2

A rotating Light source causing unrealistic colour effects for objects with badly modelled reflection properties

LineOfSparksCreator

Implements the Interface ISimpleParticleCreator

LinFogExample

Linear fog and the multiple use of transformation group in a scene as a Link

Load3DExample

Loading and displaying an object from a file in Wavefront Object Format. Printing out the names of all sub-objects. Assigning a new colour to one of the sub-objects. The file schiff.obj is needed

LODExample

Usage of the LOD technique (level of detail)

MovingLight

A moving light source

MovingSpotLight

A spotlight rotation around the scene. The intensity in the cone of light is constant and drops abruptly to zero at the edge

NormalsForGeomArrays

Definition of an object (tetrahedron) with triangles. Normal vectors are interpolated

Java class

Topic

 

ParticleSystemExample

Implementation of a sparkler based on a particle system. The package

simpleParticleSystemPackage is required

PickingExample

A class needed for InteractionExample for initiating movements and scalings for picked objects

PickingTest

A class needed for InteractionTest in order to print out the names of picked objects

RandomDirectionCreator2

Implements the Interface IDirectionCreator

RandomLongCreator

Implements the Interface ILongCreator

ShadingExample

Use of constant instead of Gouraud shading

SimpleAnimation3d

A simple animation with a starting and landing helicopter

SimpleMorphBehaviour

Ein Behaviour, das die Konvexkombination bei einem Morph steuert

SimpleParticleSystem

The central class in the package simpleParticleSystemPackage to generate a simple particle system

SimpleParticleSystemRunner

A Thread in which the particle system is generated and executed

SimpleSingleParticleCreator

A Thread to generate to generate single particles including their movement

SoundExample

Incorporating sound effects into a scene in the form of a BackgroundSound and a PointSound. The files bgsound.wav,psound.wav and darkclouds.jpg are needed

StaticSceneExample

A static scene with a helicopter and a tree

SurfaceExample

Display of a function of two variables as a surface. The classes IFunctionInTwoVariables and FunctionInTwoVariablesExample are required

TesselationBWExample

Wire frame model of a static scene with a helicopter and a tree

TesselationExample

Part of a static scene with a helicopter and a tree shown as a wire frame model

TesselationResolution

Approximation of the surface of a sphere with different numbers of triangles

Text3DExample

An example for displaying text and a Billboard behaviours in a three-dimensional scene. The classes IFunctionInTwoVariables and FunctionInTwoVariablesExample are required

TextureExample

Loading a texture from a file and mapping it to an object’s surface. The file myTexture.jpg is needed

TransparencyExample

Example for interpolated and screen-door transparency

ViewParallelProjection

Parallel projection for displaying a static scene with a helicopter and a tree

Next post:

Previous post: