net.xqhs.graphs.representation.graphical
Class GraphicalGraphRepresentation

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

public class GraphicalGraphRepresentation
extends LinearGraphRepresentation

Graphical representation for a Graph that relies on LinearGraphRepresentation to create a tree of paths and then displays the tree of paths.

It relies on GCanvas and the Gel framework for the graphical display.

Currently not supporting links in the same path very well.

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
(package private)  java.awt.geom.Point2D bottomright
          Bottom right corner of the representation, in the canvas.
(package private)  net.xqhs.graphical.GCanvas canvas
          The canvas in which the graph will be displayed.
(package private)  java.awt.geom.Point2D topleft
          Top left corner of the representation, in the canvas.
 
Fields inherited from class net.xqhs.graphs.representation.linear.LinearGraphRepresentation
isBackwards, paths, sortedNodes
 
Fields inherited from class net.xqhs.graphs.representation.GraphRepresentationImplementation
parentRepresentation, theGraph, theRepresentation
 
Fields inherited from class net.xqhs.util.logging.Unit
DEFAULT_LEVEL, DEFAULT_UNIT_NAME
 
Constructor Summary
GraphicalGraphRepresentation(Graph theGraph)
          Creates a new representation, based on the specified graph.
 
Method Summary
 net.xqhs.graphical.GCanvas displayRepresentation()
          Depending on the nature of the representation, this method returns a way to visualize the representation.
protected  void doLayout()
           
protected  void doLayout(GraphicalRepresentationElement repr, java.awt.Point cPos, float wFactor, float hFactor, GraphicalRepresentationElement container)
           
 GraphicalRepresentationElement getRepresentation()
          Gets the root element of the representation.
 GraphicalGraphRepresentation makeDefaults()
          Sets a new GCanvas as a canvas for the representation, and sets the representation to be represented in a 200 units square centered in the origin of the canvas.
protected  java.awt.Point measureLayout(GraphicalRepresentationElement repr)
           
protected  void processGraph()
          Calculates the graph paths and creates the layout.
protected  GraphicalRepresentationElement representChildren(PathElement el, java.util.Set<PathElement> blackNodes)
           
protected  void representOthers(java.util.List<PathElement> others, java.util.Set<PathElement> blackNodes, GraphicalRepresentationElement.EdgeType edgeType, PathElement parent, GraphicalRepresentationElement parentRepr)
           
 GraphicalGraphRepresentation setBottomRight(java.awt.geom.Point2D bottomRight)
          Sets the size of the representation, by means of the bottom right corner.
 GraphicalGraphRepresentation setCanvas(net.xqhs.graphical.GCanvas representationCanvas)
          Configures the representation to use the specified canvas.
protected  java.lang.String setDefaultName(java.lang.String name)
          This can be overridden by other representations to produce the correct suffix.
 GraphicalGraphRepresentation setOrigin(java.awt.geom.Point2D origin)
          Sets the origin of the rectangle for this representation, on the GCanvas.
 
Methods inherited from class net.xqhs.graphs.representation.linear.LinearGraphRepresentation
buildPaths, isBackwards, setBackwards, setBackwards
 
Methods inherited from class net.xqhs.graphs.representation.GraphRepresentationImplementation
getRootRepresentation, setParentRepresentation, setUnitName, update
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canvas

net.xqhs.graphical.GCanvas canvas
The canvas in which the graph will be displayed.


topleft

java.awt.geom.Point2D topleft
Top left corner of the representation, in the canvas.


bottomright

java.awt.geom.Point2D bottomright
Bottom right corner of the representation, in the canvas.

Constructor Detail

GraphicalGraphRepresentation

public GraphicalGraphRepresentation(Graph theGraph)
Creates a new representation, based on the specified graph.

Parameters:
theGraph - - the Graph instance to be represented.
Method Detail

makeDefaults

public GraphicalGraphRepresentation makeDefaults()
Sets a new GCanvas as a canvas for the representation, and sets the representation to be represented in a 200 units square centered in the origin of the canvas.

Specified by:
makeDefaults in interface net.xqhs.util.config.Configurable
Overrides:
makeDefaults in class net.xqhs.util.config.Config

setCanvas

public GraphicalGraphRepresentation setCanvas(net.xqhs.graphical.GCanvas representationCanvas)
Configures the representation to use the specified canvas. By default, a new canvas is used.

Parameters:
representationCanvas - - the GCanvas instance. If the argument is null, the call will be ignored.
Returns:
the instance itself.

setOrigin

public GraphicalGraphRepresentation setOrigin(java.awt.geom.Point2D origin)
Sets the origin of the rectangle for this representation, on the GCanvas.

Parameters:
origin - - the origin (top left corner - the minimum x and y in the representation).
Returns:
the instance itself.

setBottomRight

public GraphicalGraphRepresentation setBottomRight(java.awt.geom.Point2D bottomRight)
Sets the size of the representation, by means of the bottom right corner.

Parameters:
bottomRight - - the bottom right corner - the maximum x and y in the representation).
Returns:
the instance itself.

setDefaultName

protected java.lang.String setDefaultName(java.lang.String name)
Description copied from class: GraphRepresentationImplementation
This can be overridden by other representations to produce the correct suffix.

Overrides:
setDefaultName in class LinearGraphRepresentation
Parameters:
name - : the name of the graph's unit.
Returns:
the name of the representation

processGraph

protected void processGraph()
Calculates the graph paths and creates the layout.

Overrides:
processGraph in class LinearGraphRepresentation

representChildren

protected GraphicalRepresentationElement representChildren(PathElement el,
                                                           java.util.Set<PathElement> blackNodes)

representOthers

protected void representOthers(java.util.List<PathElement> others,
                               java.util.Set<PathElement> blackNodes,
                               GraphicalRepresentationElement.EdgeType edgeType,
                               PathElement parent,
                               GraphicalRepresentationElement parentRepr)

doLayout

protected void doLayout()

doLayout

protected void doLayout(GraphicalRepresentationElement repr,
                        java.awt.Point cPos,
                        float wFactor,
                        float hFactor,
                        GraphicalRepresentationElement container)

measureLayout

protected java.awt.Point measureLayout(GraphicalRepresentationElement repr)

getRepresentation

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

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

displayRepresentation

public net.xqhs.graphical.GCanvas 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
Specified by:
displayRepresentation in class GraphRepresentationImplementation
Returns:
the representation of the graph.