Search this API

y.io.graphml.graph2d
Class HierarchyManagerBasedGraphElementFactory

java.lang.Object
  extended by y.io.graphml.graph2d.HierarchyManagerBasedGraphElementFactory
All Implemented Interfaces:
GraphElementFactory

public class HierarchyManagerBasedGraphElementFactory
extends java.lang.Object
implements GraphElementFactory

Implementation of the GraphElementFactory interface that can create HierarchyManager based hierarchy information.

If a HierarchyManager instance is registered on the graph that is populated, it is used to create the hierarchy information. The actual creation of normal nodes is delegated to a customizable implementation.

 

Constructor Summary
HierarchyManagerBasedGraphElementFactory()
          Create a new instance with a getCoreFactory() set to a Graph2DElementFactory
HierarchyManagerBasedGraphElementFactory(GraphElementFactory coreFactory)
          Create a new instance with a custom getCoreFactory().
 
Method Summary
 Edge createEdge(GraphMLParseContext context, Node sourceNode, Port sourcePort, Node targetNode, Port targetPort)
          Creates an edge for the given context and the provided source and target nodes or ports.
 Node createNode(GraphMLParseContext context)
          Creates a node for the given context.
 Port createPort(GraphMLParseContext context, Node owner)
          Creates a port object that is owned by owner
protected  void edgeCreated(Graph graph, Edge edge, CreationProperties properties)
          Notifies interested parties that an edge was created.
protected  void folderCreated(Graph graph, Node node, CreationProperties properties)
          Notifies interested parties that a folder node was created.
 GraphElementFactory getCoreFactory()
          Returns the core factory for creation of normal nodes and edges.
protected  Node getParent(GraphMLParseContext context)
          Retrieves the parent node for new nodes.
protected  void groupCreated(Graph graph, Node node, CreationProperties properties)
          Notifies interested parties that a group node was created.
protected  void nodeCreated(Graph graph, Node node, CreationProperties properties)
          Notifies interested parties that a normal node was created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchyManagerBasedGraphElementFactory

public HierarchyManagerBasedGraphElementFactory()
Create a new instance with a getCoreFactory() set to a Graph2DElementFactory


HierarchyManagerBasedGraphElementFactory

public HierarchyManagerBasedGraphElementFactory(GraphElementFactory coreFactory)
Create a new instance with a custom getCoreFactory().

It is the users responsibility to set up the HierarchyManager to work correctly with non Graph2D instances.

Method Detail

getCoreFactory

public GraphElementFactory getCoreFactory()
Returns the core factory for creation of normal nodes and edges.

Returns:
The core factory.

createNode

public Node createNode(GraphMLParseContext context)
Description copied from interface: GraphElementFactory
Creates a node for the given context.

Specified by:
createNode in interface GraphElementFactory
Parameters:
context - The context from which the graph, the CreationProperties, and the GraphMLParseContext.getObjectStack() can be queried.
Returns:
A newly created node

getParent

protected Node getParent(GraphMLParseContext context)
Retrieves the parent node for new nodes. Called from createNode(y.io.graphml.input.GraphMLParseContext).

Parameters:
context - The context from which the graph, the CreationProperties, and the GraphMLParseContext.getObjectStack() can be queried.
Returns:
the parent node for new nodes or null if new nodes should be top-level nodes.

nodeCreated

protected void nodeCreated(Graph graph,
                           Node node,
                           CreationProperties properties)
Notifies interested parties that a normal node was created.

The default implementation does nothing.

Called from createNode(y.io.graphml.input.GraphMLParseContext).

See Also:
HierarchyManager.isNormalNode(y.base.Node)

folderCreated

protected void folderCreated(Graph graph,
                             Node node,
                             CreationProperties properties)
Notifies interested parties that a folder node was created.

The default implementation sets the folder node's associated node realizer.

Called from createNode(y.io.graphml.input.GraphMLParseContext).

See Also:
HierarchyManager.isFolderNode(y.base.Node)

groupCreated

protected void groupCreated(Graph graph,
                            Node node,
                            CreationProperties properties)
Notifies interested parties that a group node was created.

The default implementation sets the group node's associated node realizer.

Called from createNode(y.io.graphml.input.GraphMLParseContext).

See Also:
HierarchyManager.isGroupNode(y.base.Node)

createEdge

public Edge createEdge(GraphMLParseContext context,
                       Node sourceNode,
                       Port sourcePort,
                       Node targetNode,
                       Port targetPort)
Description copied from interface: GraphElementFactory
Creates an edge for the given context and the provided source and target nodes or ports.

Specified by:
createEdge in interface GraphElementFactory
Parameters:
context - The context from which the graph, the CreationProperties, and the GraphMLParseContext.getObjectStack() can be queried.
sourceNode - The source node for the edge.
sourcePort - The source port for the edge, if specified, otherwise null.
targetNode - The target node for the edge.
targetPort - The target port for the edge, if specified, otherwise null.
Returns:
A newly created edge.

edgeCreated

protected void edgeCreated(Graph graph,
                           Edge edge,
                           CreationProperties properties)
Notifies interested parties that an edge was created.

The default implementation sets the edge's associated edge realizer.

Called from createNode(y.io.graphml.input.GraphMLParseContext).


createPort

public Port createPort(GraphMLParseContext context,
                       Node owner)
Description copied from interface: GraphElementFactory
Creates a port object that is owned by owner

Specified by:
createPort in interface GraphElementFactory
Parameters:
context - The context from which the graph, the CreationProperties, and the GraphMLParseContext.getObjectStack() can be queried.
owner - The owner of the port object
Returns:
a new port object, or null if ports are not supported

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.