5.1 Application’s Classes and
Responsibilities
The simplified class diagram can be seen in Fig. 4,
from which we will highlight the key components
and their function.
The Gallery class holds the instances of the two
main classes: GUInterface and Xj3DScene.
GUInterface is responsible for all the menus. It
holds an instance of the class responsible for the
database connection, which it uses for painting ac-
cess and filtering. It also uses the ImageTool class to
generate thumbnails of the paintings in real time.
Xj3DScene is responsible for the display and in-
teraction with the X3D model. It keeps a collection
of Painting’s instances, which represent the paint-
ings added to the scene. Each one of these instances
has a Sensor associated, with information about the
painting’s sensor. The TransformationTool class is
responsible for all calculations involved in 3D trans-
formations, like placing and moving paintings. Ex-
portX3D is responsible for all the X3D code, also
saving it to a new X3D file when the user chooses to
save his work.
5.2 X3D Code Handling
The X3D code is kept in three separate containers,
as seen in Fig. 5.
The first container, PRE, holds all the X3D code
until the end of scene tag.
The collection of containers in the middle holds
the shapes of all the paintings added to the scene.
Each one of these containers is divided into three
sub containers. The B container has the coordinates
of the shape, pertaining to the Coordinate X3D tag,
A and C contain, respectively, the code before and
after the shape’s coordinates.
Figure 5: X3D File Contents.
This allows for the updating of the paintings’ coor-
dinates when needed.
The last container, POS holds the end of scene
tag and the remaining code.
When the user saves his work the file is written,
starting with PRE, then all the containers in the
collection, and finally POS is written.
5.3 Handling the Scene with XJ3D
When the application starts all the sensors in the
X3D file are loaded into a collection of sensors and
the coordinates of each sensor are also stored. A
listener is created and all the sensors are added to it.
This will allow the application to catch the activa-
tion of any sensor. When a sensor is activated, its
coordinates are used to place the currently selected
painting on the corresponding surface. The scene is
updated, but it is not possible to retrieve the new
X3D code from the scene. Therefore we generate
the X3D code for the new painting, by passing its
information to the ExportX3D class.
The newly placed paintings must also have sen-
sors, so that they can be selected to adjust their posi-
tion. Each Painting instance holds an instance of the
Sensor class, with all the information about the sen-
sor. When a painting is selected, the Image Tool
menu becomes available. A new shape is created
between the painting and the wall to give feedback
to the user about the selection. If the user chooses to
delete the painting, its node is removed from the
scene and the ExportX3D instance is informed of its
deletion, so it can update its X3D code accordingly.
If the user chooses to move the painting several
steps are taken:
Its parameters and desired movement are passed
into TransformationTool’s instance to calculate
the new coordinates.
The scene is changed to reflect the new position,
by altering the shape’s Coordinates node. The
coordinates for the visual selection indicator are
also updated.
The painting’s sensor is updated with the new
coordinates.
The painting is marked as changed, signaling that
it has moved from its original position.
ExportX3D’s instance code is not updated at this
time. When the user chooses to save, all the new
paintings marked as changed will be updated in
ExportX3D’s instance.
GRAPP 2008 - International Conference on Computer Graphics Theory and Applications
474