de.cau.cs.kieler.kwebs.util
Class Graphs

java.lang.Object
  extended by de.cau.cs.kieler.kwebs.util.Graphs

public final class Graphs
extends Object

Utility class for duplicating layout information between structurally identical graphs. Every graph element gets annotated with an unique identifier. This is used to duplicate the calculated layout information from a graph which was layout done on back to the original graph.

Rating proposed yellow
(2011-08-02) reviewed by ckru, mri, msp

Method Summary
static void annotateGraphWithUniqueID(KNode graph)
          Annotates each element of a KGraph instance with an unique id.
static int countEdges(KNode graph)
          Determines the total number of edges in the given graph.
static int countElements(KNode graph)
          Determines the total number of elements in the given graph.
static int countLabels(KNode graph)
          Determines the total number of labels in the given graph.
static int countNodes(KNode graph)
          Determines the total number of nodes in the given graph.
static int countPorts(KNode graph)
          Determines the total number of ports in the given graph.
static void duplicateGraphLayoutByUniqueID(KNode sourceGraph, KNode targetGraph)
          Duplicates layout information from source model to target model.
static
<T> List<T>
getAllElementsOfType(KNode graph, Class<T> type)
          Returns a list containing all the elements from a given graph which are of the specified type or sub classes of it.
static
<T> List<T>
getAllElementsOfType(KNode graph, Class<T> type, boolean maySubclass)
          Returns a list containing all the elements from a given graph which are of the specified type or sub classes of it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

duplicateGraphLayoutByUniqueID

public static void duplicateGraphLayoutByUniqueID(KNode sourceGraph,
                                                  KNode targetGraph)
Duplicates layout information from source model to target model.

Parameters:
sourceGraph - the model which contains the layout information
targetGraph - the model which gets the layout information

annotateGraphWithUniqueID

public static void annotateGraphWithUniqueID(KNode graph)
Annotates each element of a KGraph instance with an unique id.

Parameters:
graph - the graph to be annotated

countElements

public static int countElements(KNode graph)
Determines the total number of elements in the given graph.

Parameters:
graph - parent layout node to examine
Returns:
total number of elements

countNodes

public static int countNodes(KNode graph)
Determines the total number of nodes in the given graph.

Parameters:
graph - parent layout node to examine
Returns:
total number of child nodes

countEdges

public static int countEdges(KNode graph)
Determines the total number of edges in the given graph.

Parameters:
graph - parent layout node to examine
Returns:
total number of edges

countPorts

public static int countPorts(KNode graph)
Determines the total number of ports in the given graph.

Parameters:
graph - parent layout node to examine
Returns:
total number of ports

countLabels

public static int countLabels(KNode graph)
Determines the total number of labels in the given graph.

Parameters:
graph - parent layout node to examine
Returns:
total number of labels

getAllElementsOfType

public static <T> List<T> getAllElementsOfType(KNode graph,
                                               Class<T> type)
Returns a list containing all the elements from a given graph which are of the specified type or sub classes of it.

Type Parameters:
T - the type of the elements
Parameters:
graph - the graph of which the elements of the defined type shall be returned
type - class defining the type of the elements which are to be returned
Returns:
a list containing all the elements from a given graph which are of the specified type or sub classes of it

getAllElementsOfType

public static <T> List<T> getAllElementsOfType(KNode graph,
                                               Class<T> type,
                                               boolean maySubclass)
Returns a list containing all the elements from a given graph which are of the specified type or sub classes of it.

Type Parameters:
T - the type of the elements
Parameters:
graph - the graph of which the elements of the defined type shall be returned
type - class defining the type of the elements which are to be returned
maySubclass - whether the returned list may contain subclass instances
Returns:
a list containing all the elements from a given graph which are of the specified type