net.xqhs.graphs.representation
Class GraphRepresentationImplementation

java.lang.Object
  extended by net.xqhs.util.config.Config
      extended by net.xqhs.util.logging.Unit
          extended by net.xqhs.graphs.representation.GraphRepresentationImplementation
All Implemented Interfaces:
GraphRepresentation, net.xqhs.util.config.Configurable
Direct Known Subclasses:
LinearGraphRepresentation, MultilevelGraphRepresentation

public abstract class GraphRepresentationImplementation
extends net.xqhs.util.logging.Unit
implements GraphRepresentation

Abstract class for all classes that produce a representation (graphical, textual, etc) for a Graph instance.

It is possible that a GraphRepresentationImplementation class uses other, "sub-" GraphRepresentationImplementation instances for the representation, forming a tree that is defined by its root representation. In this tree, each representation has a parentRepresentation. If this instance is the root of the tree (or it is not part of such a tree), the member is null.

A GraphRepresentationImplementation is based on RepresentationElement instances, each instance associated with a specific VisualizableGraphComponent. Representation elements should be updateable, potentially leading to an update of the whole representation.

Author:
Andrei Olaru

Nested Class Summary
 
Nested classes/interfaces inherited from class net.xqhs.util.config.Config
net.xqhs.util.config.Config.ConfigLockedException
 
Field Summary
protected  GraphRepresentation parentRepresentation
          The parent representation in the tree of representations this is part of (if any such tree exists).
protected  Graph theGraph
          The represented Graph.
protected  RepresentationElement theRepresentation
          The root representation element of this representation, from which all other elements in this representation can be found.
 
Fields inherited from class net.xqhs.util.logging.Unit
DEFAULT_LEVEL, DEFAULT_UNIT_NAME
 
Constructor Summary
GraphRepresentationImplementation(Graph graph)
          This constructor creates the link with the Graph instance that this representation will be bound to throughout its lifecycle.
 
Method Summary
abstract  java.lang.Object displayRepresentation()
          Depending on the nature of the representation, this method returns a way to visualize the representation.
abstract  RepresentationElement getRepresentation()
          Gets the root element of the representation.
 GraphRepresentation getRootRepresentation()
          Gets the root representation of the tree of representation this instance is part of.
protected  void processGraph()
          Begins processing of the graph in order to create a representation.
protected  java.lang.String setDefaultName(java.lang.String name)
          This can be overridden by other representations to produce the correct suffix.
 GraphRepresentationImplementation setParentRepresentation(GraphRepresentation parent)
          Set the parent representation in a multi-level graph representation.
 GraphRepresentationImplementation setUnitName(java.lang.String unitName)
           
 GraphRepresentation update()
          Instructs the representation to update, since some elements of the graph may have changed.
 
Methods inherited from class net.xqhs.util.logging.Unit
compose, dbg, doExit, getDefaultUnitName, getUnitName, l, le, lf, li, lock, lockedR, lr, lr, lw, setLink, setLink, setLogDisplay, setLogEnsureNew, setLoggerClass, setLoggerType, setLoggerTypeClass, setLogLevel, setLogReporter, setUnitName
 
Methods inherited from class net.xqhs.util.config.Config
build, ensureLocked, locked, lockedEx, makeDefaults
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theGraph

protected Graph theGraph
The represented Graph.


parentRepresentation

protected GraphRepresentation parentRepresentation
The parent representation in the tree of representations this is part of (if any such tree exists).


theRepresentation

protected RepresentationElement theRepresentation
The root representation element of this representation, from which all other elements in this representation can be found.

Constructor Detail

GraphRepresentationImplementation

public GraphRepresentationImplementation(Graph graph)
This constructor creates the link with the Graph instance that this representation will be bound to throughout its lifecycle.

Parameters:
graph - : the represented graph.
Method Detail

setDefaultName

protected java.lang.String setDefaultName(java.lang.String name)
This can be overridden by other representations to produce the correct suffix.

Parameters:
name - : the name of the graph's unit.
Returns:
the name of the representation

setUnitName

public GraphRepresentationImplementation setUnitName(java.lang.String unitName)
Overrides:
setUnitName in class net.xqhs.util.logging.Unit

setParentRepresentation

public GraphRepresentationImplementation setParentRepresentation(GraphRepresentation parent)
Description copied from interface: GraphRepresentation
Set the parent representation in a multi-level graph representation.

The argument may be null, to indicate this representation does not belong to a larger one, or is the root of a larger representation.

Specified by:
setParentRepresentation in interface GraphRepresentation
Parameters:
parent - : the parent representation.
Returns:
the instance itself.

getRootRepresentation

public GraphRepresentation getRootRepresentation()
Description copied from interface: GraphRepresentation
Gets the root representation of the tree of representation this instance is part of. The result may be the instance itself, if there is no higher-level representation.

Specified by:
getRootRepresentation in interface GraphRepresentation
Returns:
the root GraphRepresentation.

update

public GraphRepresentation update()
Description copied from interface: GraphRepresentation
Instructs the representation to update, since some elements of the graph may have changed.

FIXME: this is inefficient as it will cause the whole representation to update - there is no indication on what part of the graph has changed.

Specified by:
update in interface GraphRepresentation
Returns:
the instance itself.

processGraph

protected void processGraph()
Begins processing of the graph in order to create a representation.

It is assumed that all configuration of this instance is completed when this method is called.

It is important for inheriting classes to call super.processGraph() because this ensures that the instance is 'locked' (see Unit).


getRepresentation

public abstract RepresentationElement getRepresentation()
Description copied from interface: GraphRepresentation
Gets the root element of the representation.

Specified by:
getRepresentation in interface GraphRepresentation
Returns:
the root RepresentationElement instance.

displayRepresentation

public abstract java.lang.Object displayRepresentation()
Description copied from interface: GraphRepresentation
Depending on the nature of the representation, this method returns a way to visualize the representation. For instance, for textual representations, the returned value is of type String.

Specified by:
displayRepresentation in interface GraphRepresentation
Returns:
the representation of the graph.