y25.view
Class Graph25D

java.lang.Object
  extended byy25.base.LayeredGraph
      extended byy25.layout.LayeredLayoutGraph
          extended byy25.view.Graph25D

public class Graph25D
extends LayeredLayoutGraph

Represents a LayeredLayoutGraph with additional 2.5D support. Instances of this class can be displayed within a Graph25DView. The layout and visual representation of nodes, edges, layer edges and layers are encapsulated in so called realizer objects, which implement the respective Layout25D interfaces defined in the y25.layout package. Every node has a NodeRealizer25D, every edge an EdgeRealizer25D, every layer edge a LayerEdgeRealizer25D and every layer (graph) a LayerRealizer25D associated with it.

All geometric or visual changes hat are performed on this Graph25D result in an attribute or type change of an associated realizer. If nodes, edges, layer edges or layers (graphs) get newly created in this Graph25D then a default node, edge, layer edge or layer realizer 25D will be automatically associated with these elements. To change the default appearance of these elements, one can assign different default realizers by using the methods setDefault[Node|Edge|LayerEdge|Layer]Realizer.

In order to be able to assign node and edge realizers to nodes and edges inside different layers, every graph this class class stores internally is of type Graph2D, so when iterating over this Graph25D's layers, casting to Graph2D is always allowed.

There is one subtle implementation detail worth noting: Since compatibility with the yFiles package was one of the major goals in designing this package, every Graph2D that is stored inside this Graph25D can be displayed and modified in a separate Graph2DView. To allow for this usage, node and edge realizers stored inside the Graph2Ds have to be of type NodeRealizer and EdgeRealizer respectively. The same realizers, however, are used when displaying the Graph2Ds inside the Graph25DView. For this to be possible, every realizer stored inside a Graph2D needs to extend NodeRealizer and implement the NodeRealizer25D interface. (ShapeNodeRealizer25D and PolyLineEdgeRealizer25D are examples for this).


Nested Class Summary
 
Nested classes inherited from class y25.base.LayeredGraph
LayeredGraph.EdgeMapImpl, LayeredGraph.GraphMapImpl, LayeredGraph.IDAssigner, LayeredGraph.IDCreator, LayeredGraph.LayerEdgeMapImpl, LayeredGraph.NodeMapImpl
 
Field Summary
 
Fields inherited from class y25.layout.LayeredLayoutGraph
boundingBox, layerEdgeLayouts, layerLayouts
 
Fields inherited from class y25.base.LayeredGraph
AFTER, BEFORE, EDGE_ID_DPKEY, edgeIDCreator, graphList, graphType, idAssigner, inLayerEdges, layerEdgeList, NODE_ID_DPKEY, nodeIDCreator, outLayerEdges, PARENT_ID_DPKEY
 
Constructor Summary
Graph25D()
          Creates a new Graph25D.
 
Method Summary
 void clear()
          Resets the Graph25D to its initial state.
 void clearLayerEdges()
          Removes all layer edges present in this Graph25D.
 Graph createGraph()
          Creates a new Graph2D and returns it.
 Graph createGraph(int where, Graph reference)
          Creates a new Graph2D at a specified location inside the graph list and returns it.
 LayerEdge createLayerEdge(Node source, Node target)
          Creates a new layer edge from the source to the target node.
 Graph duplicateGraph(Graph original)
          Creates a new Graph2D by copying the passed Graph2D.
 EdgeRealizer getDefaultEdgeRealizer25D()
          Returns a copy of the default edge realizer used in this Graph25D.
 LayerEdgeRealizer25D getDefaultLayerEdgeRealizer25D()
          Returns a copy of the default layer edge realizer used in this Graph25D.
 LayerRealizer25D getDefaultLayerRealizer25D()
          Returns a copy of the default layer realizer used in this Graph25D.
 NodeRealizer getDefaultNodeRealizer25D()
          Returns a copy of the default node realizer used in this Graph25D.
 EdgeRealizer getRealizer(Edge edge)
          Returns the EdgeRealizer that is associated with the passed edge.
 LayerRealizer25D getRealizer(Graph graph)
          Returns the LayerRealizer25D that is associated with the passed graph.
 LayerEdgeRealizer25D getRealizer(LayerEdge layerEdge)
          Returns the LayerEdgeRealizer25D that is associated with the passed layer edge.
 NodeRealizer getRealizer(Node node)
          Returns the NodeRealizer that is associated with the passed node.
 Graph importGraph(Graph graph)
          Creates a new Graph2D by copying the passed Graph2D.
 void removeGraph(Graph graph)
          Removes the passed Graph2D from this Graph25D.
 void removeLayerEdge(LayerEdge layerEdge)
          Removes the passed layer edge from this Graph25D.
 void setDefaultEdgeRealizer25D(EdgeRealizer er)
          Sets the default EdgeRealizer for this Graph25D and all its associated Graph2Ds to the passsed realizer.
 void setDefaultLayerEdgeRealizer25D(LayerEdgeRealizer25D ler)
          Sets the default LayerEdgeRealizer25D for this Graph25D to the passsed realizer.
 void setDefaultLayerRealizer25D(LayerRealizer25D lr)
          Sets the default LayerRealizer25D for this Graph25D to the passsed realizer.
 void setDefaultNodeRealizer25D(NodeRealizer nr)
          Sets the default NodeRealizer for this Graph25D and all its associated Graph2Ds to the passsed realizer.
 void setRealizer(Edge edge, EdgeRealizer er)
          Sets the passed edge's realizer to the passed edge realizer.
 void setRealizer(Graph graph, LayerRealizer25D lr)
          Sets the passed graph's realizer to the passed layer realizer.
 void setRealizer(LayerEdge layerEdge, LayerEdgeRealizer25D ler)
          Sets the passed layer edge's realizer to the passed layer edge realizer.
 void setRealizer(Node node, NodeRealizer nr)
          Sets the passed node's realizer to the passed node realizer.
 
Methods inherited from class y25.layout.LayeredLayoutGraph
getBoundingBox, getLayout, getLayout, getPoint3D, getZ, recalculateBoundingBox, setZ, sortGraphsByZ
 
Methods inherited from class y25.base.LayeredGraph
copyCreateStructureData, createEdgeMap, createGraphMap, createLayerEdgeMap, createNodeMap, E, edgeCount, G, getEdgeID, getGraphArray, getGraphCursorAfter, getGraphCursorBefore, getLayerEdgeArray, getNodeID, getParentID, graphCount, graphs, inLayerEdges, layerEdgeCount, layerEdges, LE, moveBackward, moveForward, moveToBack, moveToFront, N, nodeCount, outLayerEdges, setEdgeID, setNodeID, setParentID, sortGraphs, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph25D

public Graph25D()
Creates a new Graph25D.

Method Detail

clear

public void clear()
Resets the Graph25D to its initial state.

Overrides:
clear in class LayeredLayoutGraph

clearLayerEdges

public void clearLayerEdges()
Removes all layer edges present in this Graph25D.

Overrides:
clearLayerEdges in class LayeredLayoutGraph

createGraph

public Graph createGraph()
Creates a new Graph2D and returns it. The new graph will be located at the end of the graph list inside this Graph2D.

The returned graph automatically assigns new and unique IDs to nodes and edges as soon as they are created. After creation, changing these automatically assigned IDs is accomplished by calling the LayeredGraph methods setNodeID, setParentID and setEdgeID.

The created graph is automatically assigned the default layer realizer. Also, newly created nodes and edges inside the Graph2D will automatically receive the default node and edge realizers associated with this Graph25D.

The z-position of the returned graph is set to 0.

Overrides:
createGraph in class LayeredGraph
Returns:
The newly created graph.

createGraph

public Graph createGraph(int where,
                         Graph reference)
Creates a new Graph2D at a specified location inside the graph list and returns it.

The returned graph automatically assigns new and unique IDs to nodes and edges as soon as they are created. After creation, changing these automatically assigned IDs is accomplished by calling the LayeredGraph methods setNodeID, setParentID and setEdgeID.

The created graph is automatically assigned the default layer realizer. Also, newly created nodes and edges inside the Graph2D will automatically receive the default node and edge realizers associated with this Graph25D.

Overrides:
createGraph in class LayeredGraph
Parameters:
where - Can be either LayeredGraph.BEFORE or LayeredGraph.AFTER. In the fromer case, the new graph is inserted into the list right before the passed reference graph, in the latter case it is inserted after the passed reference graph.
reference - A graph that is already in the graph list of this Graph25D. If null is passed, the newly created graph is inserted at the very beginning of the list if where is LayeredGraph.BEFORE or at the very end of the graph list if where is LayeredGraph.AFTER.
Returns:
The newly created graph.

duplicateGraph

public Graph duplicateGraph(Graph original)
Creates a new Graph2D by copying the passed Graph2D. The passed graph has to be part of this Graph25D. The new graph's location inside the graph list will be right after the original graph.

The created graph is assigned a copy of the layer realizer of the original graph. Newly created nodes and edges inside the Graph2D will automatically receive the default node and edge realizers associated with the original graph.

The new graph is then returned. It has exactly the same nodes and edges as the original graph. All node, edge and parent IDs are also identical to the original. The returned graph automatically assigns new and unique IDs to newlu created nodes and edges. After creation, changing these automatically assigned IDs is accomplished by calling the LayeredGraph methods setNodeID, setParentID and setEdgeID.

Overrides:
duplicateGraph in class LayeredGraph
Parameters:
original - the graph that will be copied.
Returns:
the newly created graph that is a duplicate of the original.

importGraph

public Graph importGraph(Graph graph)
Creates a new Graph2D by copying the passed Graph2D. The difference to the duplicateGraph method is, that the passed graph is not part of this Graph25D. If you already have code that generates a Graph2D and you want to use that graph inside this Graph25D, this is the method you have to use. (It is an error to pass a graph that is already inside this Graph25D to this method.)

The new graph will be located at the end of the graph list inside this Graph25D. It has exactly the same nodes and edges as the original graph.

Regarding node, edge and parent IDs, there are two possibilities:

  1. If the graph you pass has no DataProviders for the keys LayeredGraph.NODE_ID_DPKEY, LayeredGraph.PARENT_ID_DPKEY and LayeredGraph.EDGE_ID_DPKEY, new IDs will be created for every node and edge in the copied graph. The parent IDs will all be set to 0.
  2. If you want to specify node, edge and parent IDs, you have to register DataProviders for the following keys: LayeredGraph.NODE_ID_DPKEY, LayeredGraph.PARENT_ID_DPKEY, LayeredGraph.EDGE_ID_DPKEY. Then you can assign node, edge and parent IDs as you like. These IDs will then be copied to the new graph that is created. Note that you have to perform these steps before you call this method.
The new graph automatically assigns new and unique IDs to newly created nodes and edges. After creation, changing these automatically assigned IDs is accomplished by calling the LayeredGraph methods setNodeID, setParentID and setEdgeID.

Overrides:
importGraph in class LayeredGraph
Parameters:
graph - the graph that will be copied.
Returns:
the newly created graph that is a duplicate of the passed graph.

removeGraph

public void removeGraph(Graph graph)
Removes the passed Graph2D from this Graph25D.

See LayeredGraph.removeGraph and LayeredLayoutGraph.removeGraph for a description of what exactly this method does.

Overrides:
removeGraph in class LayeredLayoutGraph
Parameters:
graph - The graph that will be removed.

createLayerEdge

public LayerEdge createLayerEdge(Node source,
                                 Node target)
Creates a new layer edge from the source to the target node. Both nodes must be inside Graph2Ds that belong to this Graph25D.

The created layer edge is automatically assigned the default layer edge realizer.

Overrides:
createLayerEdge in class LayeredGraph
Parameters:
source - The source node for the layer edge.
target - The target node for the layer edge.
Returns:
The newly created layer edge.

removeLayerEdge

public void removeLayerEdge(LayerEdge layerEdge)
Removes the passed layer edge from this Graph25D.

See LayeredGraph.removeLayerEdge for a description of what exactly this method does.

Overrides:
removeLayerEdge in class LayeredLayoutGraph
Parameters:
layerEdge - The layer edge that will be removed.

setRealizer

public void setRealizer(Node node,
                        NodeRealizer nr)
Sets the passed node's realizer to the passed node realizer. A copy of the realizer will be created and stored internally.

Note that the passed NodeRealizer has to implement the NodeRealizer25D interface. If this is not the case, an attempt is made to create an analog 25D version of the passed realizer via an instance of Realizer25DFactory. If this fails too, the default layer realizer of this Graph25D is used.


setRealizer

public void setRealizer(Edge edge,
                        EdgeRealizer er)
Sets the passed edge's realizer to the passed edge realizer. A copy of the realizer will be created and stored internally.

Note that the passed EdgeRealizer has to implement the EdgeRealizer25D interface. If this is not the case, an attempt is made to create an analog 25D version of the passed realizer via an instance of Realizer25DFactory. If this fails too, the default layer realizer of this Graph25D is used.


setRealizer

public void setRealizer(LayerEdge layerEdge,
                        LayerEdgeRealizer25D ler)
Sets the passed layer edge's realizer to the passed layer edge realizer. A copy of the realizer will be created and stored internally.


setRealizer

public void setRealizer(Graph graph,
                        LayerRealizer25D lr)
Sets the passed graph's realizer to the passed layer realizer. A copy of the realizer will be created and stored internally.


getRealizer

public NodeRealizer getRealizer(Node node)
Returns the NodeRealizer that is associated with the passed node.

All NodeRealizers stored inside this Graph25D (or inside the node's Graph2D for that matter) implement the NodeRealizer25D interface, so casting the result to that type is always safe.


getRealizer

public EdgeRealizer getRealizer(Edge edge)
Returns the EdgeRealizer that is associated with the passed edge.

All EdgeRealizers stored inside this Graph25D (or inside the edge's Graph2D for that matter) implement the EdgeRealizer25D interface, so casting the result to that type is always safe.


getRealizer

public LayerEdgeRealizer25D getRealizer(LayerEdge layerEdge)
Returns the LayerEdgeRealizer25D that is associated with the passed layer edge.


getRealizer

public LayerRealizer25D getRealizer(Graph graph)
Returns the LayerRealizer25D that is associated with the passed graph.


setDefaultNodeRealizer25D

public void setDefaultNodeRealizer25D(NodeRealizer nr)
Sets the default NodeRealizer for this Graph25D and all its associated Graph2Ds to the passsed realizer.

Note that the passed NodeRealizer has to implement the NodeRealizer25D interface. If this is not the case, an attempt is made to create an analog 25D version of the passed realizer via an instance of Realizer25DFactory. If this fails too, the default layer realizer of this Graph25D is used.


setDefaultEdgeRealizer25D

public void setDefaultEdgeRealizer25D(EdgeRealizer er)
Sets the default EdgeRealizer for this Graph25D and all its associated Graph2Ds to the passsed realizer.

Note that the passed EdgeRealizer has to implement the EdgeRealizer25D interface. If this is not the case, an attempt is made to create an analog 25D version of the passed realizer via an instance of Realizer25DFactory. If this fails too, the default layer realizer of this Graph25D is used.


setDefaultLayerEdgeRealizer25D

public void setDefaultLayerEdgeRealizer25D(LayerEdgeRealizer25D ler)
Sets the default LayerEdgeRealizer25D for this Graph25D to the passsed realizer.


setDefaultLayerRealizer25D

public void setDefaultLayerRealizer25D(LayerRealizer25D lr)
Sets the default LayerRealizer25D for this Graph25D to the passsed realizer.


getDefaultNodeRealizer25D

public NodeRealizer getDefaultNodeRealizer25D()
Returns a copy of the default node realizer used in this Graph25D.

All NodeRealizers stored inside this Graph25D and its associated Graph2Ds implement the NodeRealizer25D interface, so casting the result to that type is always safe.

Note that this method doesn't work like its corresponding Graph2D method, since a copy of the default realizer is returned at not the realizer itself. This is done in order to prevent unexpected behavior. If the the goal is to change the default realizer of this Graph25D and all its associated Graph2Ds by modifying a parameter of the default node realizer, the following steps have to be performed:


getDefaultEdgeRealizer25D

public EdgeRealizer getDefaultEdgeRealizer25D()
Returns a copy of the default edge realizer used in this Graph25D.

All EdgeRealizers stored inside this Graph25D and its associated Graph2Ds implement the EdgeRealizer25D interface, so casting the result to that type is always safe.

Note that this method doesn't work like its corresponding Graph2D method, since a copy of the default realizer is returned at not the realizer itself. This is done in order to prevent unexpected behavior. If the the goal is to change the default realizer of this Graph25D and all its associated Graph2Ds by modifying a parameter of the default edge realizer, the following steps have to be performed:


getDefaultLayerEdgeRealizer25D

public LayerEdgeRealizer25D getDefaultLayerEdgeRealizer25D()
Returns a copy of the default layer edge realizer used in this Graph25D.

Note that this method doesn't necessarily work as you might expect. It is important to realize that a copy of the default realizer is returned. If the the goal is to change the default layer realizer of this Graph25D and all its associated Graph2Ds by modifying a parameter of the default layer edge realizer, the following steps have to be performed:


getDefaultLayerRealizer25D

public LayerRealizer25D getDefaultLayerRealizer25D()
Returns a copy of the default layer realizer used in this Graph25D.

Note that this method doesn't necessarily work as you might expect. It is important to realize that a copy of the default realizer is returned. If the the goal is to change the default layer realizer of this Graph25D and all its associated Graph2Ds by modifying a parameter of the default layer realizer, the following steps have to be performed: