Introduction

The MutationVisualizationViewer appends the VisualizationViewer? with an 'ear' to hear user 'mutation' events (creation, deletion and alteration of graph elements).

Creation of Mutations

The MutationVisualizationViewer is just like the normal VisualizationViewer? accessible by Plugins like the EditingGraphMousePlugin? and the EditingPopupGraphMousePlugin?. The user can create create or remove vertices or edges in these plugins. It has a MutationFactory?. The creation of a vertex can be initiated like this:

   GraphMutation? mutation = mutationFactory.createVertex();
   if (mutation != null) vv.mutate(mutation); 

Listening to Mutations

The MutationVisualizationViewer receives this mutation event and transmits this message to the attached mutation listeners. By default will the GraphMode? of the MutationVisualizationViewer be readable and writable (READWRITE). This means that 4 mutation listeners are added:

Performing the Mutations

To each of these listeners a GraphMutationEvent? will be sent, that also contains the source (the MutationVisualizationViewer). Subsequently each of these listeners will be able to perform the actual mutation, by calling for example:

   ((MutationVisualizationModel?)vv.getModel()).addVertex(vertex);
   vv.repaint();

The model contains a reference to the layout (and thus the graph) and will mutate the graph and indicate the layout of the change. This layout is therefore from the type MutationLayout? and knows how to add/remove vertex/edge to/from the graph without having to filter the whole graph again according some predicate.

Valid XHTML 1.0! Valid CSS!