Search this API

y.io.graphml.layout
Class GroupingBasedGraphElementFactory

java.lang.Object
  extended by y.io.graphml.layout.GroupingBasedGraphElementFactory
All Implemented Interfaces:
GraphElementFactory

public class GroupingBasedGraphElementFactory
extends java.lang.Object
implements GraphElementFactory

Element factory that creates nesting information for GroupingKeys. I.e. this factory's createNode method will set node ID, parent node ID, and group state of newly created nodes if the corresponding GroupingKeys reference DataAcceptor implementations.

 

Constructor Summary
GroupingBasedGraphElementFactory(GraphElementFactory coreFactory)
          Initializes a new GroupingBasedGraphElementFactory instance.
 
Method Summary
 Edge createEdge(GraphMLParseContext context, Node sourceNode, Port sourcePort, Node targetNode, Port targetPort)
          Creates a new edge for the given context.
protected  java.lang.Object createId(Node node)
          Creates a unique ID for the given node that can be used as data for GroupingKeys.NODE_ID_DPKEY and GroupingKeys.PARENT_NODE_ID_DPKEY.
 Node createNode(GraphMLParseContext context)
          Creates a new node for the given context.
 Port createPort(GraphMLParseContext context, Node owner)
          Creates a new port for the given context.
 GraphElementFactory getCoreFactory()
          Returns the decorated graph element factory that handles the actual element creation.
protected  Node getParent(GraphMLParseContext context)
          Retrieves the parent node for new nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupingBasedGraphElementFactory

public GroupingBasedGraphElementFactory(GraphElementFactory coreFactory)
Initializes a new GroupingBasedGraphElementFactory instance.

Parameters:
coreFactory - the factory used for actually creating graph elements.
Method Detail

getCoreFactory

public GraphElementFactory getCoreFactory()
Returns the decorated graph element factory that handles the actual element creation.

Returns:
the decorated graph element factory.
See Also:
GroupingBasedGraphElementFactory(y.io.graphml.input.GraphElementFactory)

createNode

public Node createNode(GraphMLParseContext context)
Creates a new node for the given context. Sets node ID, parent node ID, and group state of newly created nodes if the corresponding GroupingKeys reference DataAcceptor implementations.

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 new node.

createEdge

public Edge createEdge(GraphMLParseContext context,
                       Node sourceNode,
                       Port sourcePort,
                       Node targetNode,
                       Port targetPort)
Creates a new edge for the given context.

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 new edge.

createPort

public Port createPort(GraphMLParseContext context,
                       Node owner)
Creates a new port for the given context.

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.

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.

createId

protected java.lang.Object createId(Node node)
Creates a unique ID for the given node that can be used as data for GroupingKeys.NODE_ID_DPKEY and GroupingKeys.PARENT_NODE_ID_DPKEY.

The default implementation returns the node itself.

Parameters:
node - the node for which a unique ID has to be created.
Returns:
a unique ID for the given node.

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