Search this API

y.view.hierarchy
Class DefaultHierarchyGraphFactory

java.lang.Object
  extended by y.view.DefaultGraph2DFactory
      extended by y.view.hierarchy.DefaultHierarchyGraphFactory
All Implemented Interfaces:
GraphFactory

public class DefaultHierarchyGraphFactory
extends DefaultGraph2DFactory

This is the default graph factory used by HierarchyManager to create and configure new graph elements within the hierarchy.

The graph factory creates graphs of type Graph2D and corresponding graph elements, i.e., in particular, group nodes and folder nodes. It is also responsible for configuring the default node realizers used for the representation of both group nodes and folder nodes.

Whenever a new graph is created by this factory, it will inherit all listeners registered with the parent graph, i.e., all GraphListener, Graph2DListener, and Graph2DSelectionListener references are copied. The new graph will also use the same default node realizers as the parent graph.

 
Your browser does not support SVG content.

Constructor Summary
DefaultHierarchyGraphFactory()
          Creates a new instance of DefaultHierarchyGraphFactory.
 
Method Summary
protected  void configureGraph(Graph2D createdGraph, java.lang.Object hint)
          Adds all GraphListener, Graph2DListener, and Graph2DSelectionListener references that are registered with the parent graph to the newly created graph.
 Graph createGraph(java.lang.Object hint)
          Creates a new Graph2D that is configured as a copy of the given parent graph, basically.
 Node createNode(Graph graph, java.lang.Object hint)
          Creates a new node in the given graph.
 NodeRealizer createNodeRealizer(java.lang.Object hint)
          Creates a realizer for a node.
 NodeRealizer getDefaultFolderNodeRealizer()
          Returns the default node realizer for folder nodes.
 NodeRealizer getDefaultGroupNodeRealizer()
          Returns the default node realizer for group nodes.
 boolean isProxyNodeRealizerEnabled()
          Returns whether or not to use a proxy node realizer that delegates to the default realizers for group or folder nodes.
 void setDefaultFolderNodeRealizer(NodeRealizer r)
          Sets the default node realizer for folder nodes.
 void setDefaultGroupNodeRealizer(NodeRealizer r)
          Sets the default node realizer for group nodes.
 void setProxyNodeRealizerEnabled(boolean proxyNodeRealizerEnabled)
          Whether or not this class should assign a proxy node realizer to all group and folder nodes.
 
Methods inherited from class y.view.DefaultGraph2DFactory
createEdge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHierarchyGraphFactory

public DefaultHierarchyGraphFactory()
Creates a new instance of DefaultHierarchyGraphFactory. Initializes the default node realizers for both group nodes and folder nodes.

See Also:
getDefaultGroupNodeRealizer(), getDefaultFolderNodeRealizer()
Method Detail

createGraph

public Graph createGraph(java.lang.Object hint)
Creates a new Graph2D that is configured as a copy of the given parent graph, basically.

Specified by:
createGraph in interface GraphFactory
Overrides:
createGraph in class DefaultGraph2DFactory
Parameters:
hint - Is expected to be the parent graph of the newly created graph.
Returns:
A configured Graph2D.

configureGraph

protected void configureGraph(Graph2D createdGraph,
                              java.lang.Object hint)
Adds all GraphListener, Graph2DListener, and Graph2DSelectionListener references that are registered with the parent graph to the newly created graph.
In particular, this copies the GraphListener that is needed by HierarchyManager in order to keep the model that it maintains for the entire hierarchic structure consistent.

Note that the newly created graph will also use the same default node realizers as the parent graph.

Parameters:
createdGraph - A newly created Graph2D instance.
hint - Is expected to be the parent graph of the newly created graph.

createNode

public Node createNode(Graph graph,
                       java.lang.Object hint)
Creates a new node in the given graph. If the hint is of type Graph the newly created node is considered to be a folder node within the hierarchy. Otherwise it is considered to be a group node. Calls createNodeRealizer(Object) to create a NodeRealizer for the new node.

Specified by:
createNode in interface GraphFactory
Overrides:
createNode in class DefaultGraph2DFactory
Parameters:
graph - the graph containing the newly created node.
hint - the hint object will be ignored.
Returns:
a newly created node
See Also:
createNodeRealizer(Object)

createNodeRealizer

public NodeRealizer createNodeRealizer(java.lang.Object hint)
Creates a realizer for a node. If this factory is configured to use proxy realizers, the returned realizer is of type ProxyShapeNodeRealizer. Else, this method creates realizers from its folder and group node realizer templates as returned by getDefaultFolderNodeRealizer() and getDefaultGroupNodeRealizer(), respectively. The folder template is chosen if hint is of type Graph, otherwise the group template is used.

See Also:
createNode(Graph, Object), isProxyNodeRealizerEnabled(), setProxyNodeRealizerEnabled(boolean), getDefaultFolderNodeRealizer(), getDefaultGroupNodeRealizer()

setDefaultGroupNodeRealizer

public void setDefaultGroupNodeRealizer(NodeRealizer r)
Sets the default node realizer for group nodes. A copy of this realizer will be bound to a newly created group node.

See Also:
getDefaultGroupNodeRealizer()

setDefaultFolderNodeRealizer

public void setDefaultFolderNodeRealizer(NodeRealizer r)
Sets the default node realizer for folder nodes. A copy of this realizer will be bound to a newly created folder node.

See Also:
getDefaultFolderNodeRealizer()

getDefaultGroupNodeRealizer

public NodeRealizer getDefaultGroupNodeRealizer()
Returns the default node realizer for group nodes.

See Also:
setDefaultGroupNodeRealizer(NodeRealizer)

getDefaultFolderNodeRealizer

public NodeRealizer getDefaultFolderNodeRealizer()
Returns the default node realizer for folder nodes.

See Also:
setDefaultFolderNodeRealizer(NodeRealizer)

setProxyNodeRealizerEnabled

public void setProxyNodeRealizerEnabled(boolean proxyNodeRealizerEnabled)
Whether or not this class should assign a proxy node realizer to all group and folder nodes. Both the default realizer for group nodes and for folder nodes will be added to the list of maintained realizers of this proxy node. Initially, the proxy node realizer will redirect its calls to the corresponding realizer. The realizer for group nodes can be found at position 0 of the realizer list. The realizer for folder nodes can be found at position 1 of this list.

The main purpose of using a proxy node realizer is to be able to use completely different realizers to represent open and closed group nodes.

By default, this feature is deactivated.

See Also:
ProxyShapeNodeRealizer, ProxyShapeNodeRealizer.getRealizer(int), ProxyShapeNodeRealizer.setRealizerDelegate(NodeRealizer)

isProxyNodeRealizerEnabled

public boolean isProxyNodeRealizerEnabled()
Returns whether or not to use a proxy node realizer that delegates to the default realizers for group or folder nodes.

See Also:
setProxyNodeRealizerEnabled(boolean)

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