ThreeSpace
IMPLEMENTATION DOCUMENT
Adam Chodorowski & John Nilsson
June 28, 2001
This document aims to describe the current implementation of ThreeSpace; what packages and
classes it consists of and how they interact.
Please see the requirements document and design document for a full list of definitions
and abbreviations used in this document.
ThreeSpace consists of 9 different packages and the top-level class called Application.
Application handles the startup of the program, making sure to instantiate the different
classes that are required for correct operation. It also handles the top-level GUI (ie.
the main window), even though most of the work is delegated to classes in threespace.gui.
This package contains classes for handling the composition of the scene, the visual
objects it contain (and their composition) and visualization using Java3D.
The following classes are available:
The Scene class handles the Scene with all its SceneObject, the Camera and creates the
Component which can be added to the ViewPanel.
An interface for a listener that listens for Scene events.
The Camera class wraps around the Java3D View Model. Implmenting MovableObject allows it
to be modified as a regular object with rotation and position. A Camera object can
be considered as a camera looking at a center point from a given angle from a given
distance. It can thus be defined using:
- A center point which the camera is looking at
- A distance from the center point
- Three angles which define the orientation and direction from which the camera is looking
The distance from the center and the position at which the center appears on the canvas are
handled by the MovableObject methods. The three angles are also handled by MovableObject.
Choosing the point to center around is left as a method which the GUI can access if it so chooses.
A MovableObject can move and rotate.
An abstract class which extends MovableObject and adds color methods.
A SceneObject holds the two shapes which contain geometry-information. One shape is before filters
have applied and the others is after they have been applied. The SceneObject is added to the Scene's
list of objects.
The Shape class encapsulates the Shape's geometry and the properties that control how the Shape is
viewied. It also controls the rotation and positioning of the object.
The Geometry class is the wrapper around the Java3D Geometry data. The Java3D data is in the form of
IndexedTriangleArray and thus all constructors and access is on the form of this structure. The arrays
that are included in the structure are:
- Vertices - all vertices in the 3D object on the form of {x1,y1,z1,x2,y2,z2,x3,y3,z3}
- Colors - the color of the vertices specified in the Vertices array. {red1,green1,blue1,r2,g2,b2}
- Triangles - Defines the connection between vertices {triangle1vertex1,triangle1vertex2,triangle1vertex3,
triangle2vertex1,triangle2vertex2,triangle2vertex3}
- Normals - automatically created. Creates a normal for each triangle.
This class handles the KeyboardEvents that the Canvas receives. It handles movement of the Centerpoint for
the camera.
This class handles the MouseEvents that the Canvas receives. It handles movement and rotation of the Camera
and selected SceneObject. It also handles selection of a objects and selection of CenterAround-object.
This package contains classes and interfaces for implementing notifications when things
(rotation, position, color, etc.) are changed in the Scene or in a SceneObject. This makes
it possible for non-related classes (eg. that draw the GUI handling) to update their
information without direct intervention of the scene classes.
The following classes are available:
This class is used to notify interested parties that the color of the event source (ie. a
ColorableObject) has changed.
This is an interface for classes to implement if they wish to be notified about ColorChangeEvents
from some kind of event source.
This class is used to notify interested parties that the position of the event source (ie. a
MovableObject) has changed.
This is an interface for classes to implement if they wish to be notified about PositionChangeEvents
from some kind of event source.
This class is used to notify interested parties that the rotation of the event source (ie. a
MovableObject) has changed.
This is an interface for classes to implement if they wish to be notified about RotationChangeEvents
from some kind of event source.
This package contains the main bulk of classes and interfaces that are used for creating
the GUI. This ranges from flexible GUI components that are meant for reuse in other classes
and specific classes that handle a single domain (eg. CreateDialog that handles the object-
creation dialog).
The following classes are available:
This class implements a simple about dialog that displays the following information about the
application:
- Logotype image.
- Version information.
- List of authors.
It also provides a button for closing the window. See the design document for a scetch of how
the dialog looks (or compile and run the code).
This class implements a simple splash dialog, useful for providing feedback when the application
is started. It look really nice, too. The dialog provides the following:
- Logotype image.
- Progress bar.
- Description of current event.
See the design document for a scetch of how it looks (or compile and run the code). All methods
provided by this class affect only the display of the GUI, nothing else.
The Dialog which ShapeCreator plugins are shown in. The dialog includes the ShapeCreator's option-panel.
The dialog used to control a specific filter list of a scene object. It allows new Filters to set their
properties. Also includes functions to remove and add filters to the filter list.
The MenuPanel populates the menus with the plugins and the standard menuitems.
An extension to ActionEvent which stores an extra Object parameter which can then be retrieved through the
getParameter().
An interface for a listener capable of receiving the special MenuActionEvents.
This class implements a specially customised version of JToolbar for embedding in the main window of ThreeSpace.
It provides buttons for the following actions:
- New scene
- Load scene
- Save scene
- Save scene as
- Switch to Camera State
- Switch to Object State
- Switch to Vertex State
- Switch to rendering mode 1
- Switch to rendering mode 2
- Switch to rendering mode 3
- Switch to rendering mode 4
The PropertyPanel handles the CameraPanel and the ObjectPanel. When the scene
is in Camera-mode the CameraPanel is displayed and when the scene is in Object-mode
the ObjectPanel is displayed.
The CameraPanel includes controls for changing the camera position and viewing direction
and also has a control for adding bookmarks.
The ObjectPanel includes controls for changing the objects position, rotation, name,
color and the filters which it utilizes.
The ViewPanel is a panel which contains the Canvas3D component (ie. that renders the view).
The GUI component which lets the user select a specific color through either RGB or HSV
values. The getColor method returns the RGB-values.
A Panel which includes a number of sliders that go between specified min and max values.
A Panel which handles a number of textfiels and puts a plus and minus button next to them.
An extension to JTextField which sends an ActionEvent when the text field loses focus.
The regular JTextField does not do this, which can result in that values aren't properly
updated if you're not careful.
An extension to JTextField which only allows doubles to be written in the text field.
An extension to JTextField which only allows integers to be written to the text field.
An abstract class for validating text before the text is allowed to enter a TextField.
A List model which handles the PluginLists we have for Color, Structure, etc. It updates
its values whenever the PluginList changes, automatically.
A class used by filters and plugins to show error messages
This package contains flexible classes that are used for editing a scene object's different
attributes. These classes are "embed-and-forget", ie. you only have to give them a reference
to a scene object and embed them in a GUI, and they will handle all interaction between the
user and the scene object automatically by themselves.
The following classes are available:
The ColorEditor panel is used for changing the color of an object. It uses a ColorSelector
for selecting the color.
The NameEditor panel is used for changing the name of an object. It uses a ITextField.
The editor used for changing the position of the camera or an object.
The editor used for changing the rotation of the camera or an object.
This package contains all concrete plugins that have been implemented. These can be plugins
for creating new scene objects, filtering plugins, savers, loaders, etc. All must implement
some interface as defined in threespace.plugin.type.*.
The following classes are available:
This class implements a ShapeCreator plugin that generates a plain
circle with a specified radius.
This class implements a ShapeCreator plugin that generates a 3D shape
that visualizes a mathematical function, eg. z = f(x,y).
This class implements a ColorFilter which sets the color according to
the height of the object.
This class implements a ShapeCreator plugin that generates a hemispere.
This class implements a ShapeCreator plugin that generates a mandelbrot
image in 3D given some parameters.
This class implements a ShapeCreator plugin that generates a 2D plane.
This plugin implements a ColorFilter that gives all vertices with
positive z-coordinates a specific color.
This class implements a ShapeCreator plugin that generates a 3D spere
with a specific radius.
This class implements a ShapeCreator plugin that generates a randomly
created shape in the form of a mountain.
This package contains interfaces for all kinds of plugins supported by ThreeSpace. All that
a specific plugin must do is implement one if these interfaces, and it will automatically
be instantiated and available for use in ThreeSpace.
The following classes are available:
This is the minimal common interface that all plugins for ThreeSpace must implement. Ofcourse
plugins should implement subinterfaces of this interface, since it doesn't provide any actual
functionality.
This is an interface for plugins that create new shapes from scratch.
This is the top-level interface for any filter plugins that modify SceneObjects in some way.
Note that concrete plugins must implement a subclass of this interface; simply implementing
this interface is not very useful.
This is an interface for filter plugins that modify a SceneObject's color.
This is an interface for filter plugins that modify a SceneObject's position.
This is an interface for filter plugins that modify a SceneObject's rotation.
This is an interface for filter plugins that modify a SceneObject's structure,
ie. the vertices, triangles and/or polygons.
This is an interface for plugins that can load a SceneObject from disk.
This is an interface for plugins that can save an SceneObject to disk, possibly for
later retrieval.
This is an interface for plugins that can load a Scene from disk.
This is an interface for plugins that can save a Scene out to disk, possibly for
later retrieval.
This is an interface for plugins that export the currently rendered view
to a file. This generally means encoding the 2D image as a JPEG, GIF, PNG
or a similar format; although this is up to the plugin to decide.
This package contains classes and interfaces for handling and loading the plugins.
This consists of a custom class-loader for loading and instantiating classes from disk,
a manager for handling the collection of plugins (scanning the plugin-directory,
grouping plugins by type, etc) and various supporting classes.
The following classes are available:
This class is used to notify interested parties that the state of the event source has
changed, and how. It is intended for use with different kinds of indexed lists, and you
can specify if a specific list element has been added or removed.
This is an interface for classes to implement if they wish to be notified about
ListChangeEvents from some kind of event source.
This class implements an abstract collection of Plugins of a specific type. It is does not
implement the full List interface, since that seemed unneccesary for the intended use.
Apart from methods for operating on the list, it can also notify interested parties using
ListChangeEvents if it is changed in some way.
This class implements a custom class-loader for dynamic loading of plugins.
This class implements a high-level handler of collections of different types of Plugins.
It automatically scans the plugin-directory and uses the PluginLoader to load any class-files it
can find there. It also provides an API for getting at lists of Plugins organized after type.
This package contains classes for interfacing with GNU JEL (Java Expression Library) which
support for parsing and evaluating mathematical expressions. This is then used by the
various plugins that support mathematical formulae.
The following classes are available:
This class interfaces with GNU JEL (Java Expression Library) for parsing and evaluation
mathematical formulae.
This class is just a wrapper around variables that can be used in the expressions evaluated
by Calculator.
This package is meant for different utility-classes that don't fit in anyware else.
There is currently only a single class available:
This class provides static methods for printing debug output to the console. This way,
you just have to disable the output in this class to disable all debug output in the program.
We have created some diagrams to illustrate the different packages of the program and how
the different classes interact and subclass each other. Note that some of these files are
big.
A diagram that illustrates the GUI package can be found at:
http://www.d.kth.se/~d00-jni/progstil/implementation/gui.png
A diagram that illustrates the plugin package can be found at:
http://www.d.kth.se/~d00-jni/progstil/implementation/plugin.png
A diagram that illustrates the scene package can be found at:
http://www.d.kth.se/~d00-jni/progstil/implementation/scene.png
And, if you want to see it all in it's whole glory, the following
diagram shows all packages and their classes together:
http://www.d.kth.se/~d00-jni/progstil/implementation/threespace.png
Please se the Javadoc for a complete reference of the methods and classes.
http://www.d.kth.se/~d00-jni/progstil/javadoc/
Adam Chodorowski
2001-06-28