com.yworks.yfiles.server.graphml.flexio.data
Class StyledLayoutGraph

java.lang.Object
  extended byy.base.Graph
      extended byy.layout.LayoutGraph
          extended byy.layout.DefaultLayoutGraph
              extended bycom.yworks.yfiles.server.graphml.flexio.data.StyledLayoutGraph
All Implemented Interfaces:
GraphInterface, GraphLayout
Direct Known Subclasses:
FoldedLayoutGraph

public class StyledLayoutGraph
extends DefaultLayoutGraph

This class extends the DefaultLayoutGraph by adding convenient methods to configure styles and labels for nodes and edges and to access and set their user tags.

It also provides access to an INodeHierarchy for this graph instance which offers grouping related functionality.


Field Summary
 
Fields inherited from class y.layout.DefaultLayoutGraph
edgeLabelFeatureMap, edgeLabelMap, nodeLabelFeatureMap, nodeLabelMap
 
Fields inherited from class y.layout.LayoutGraph
z
 
Fields inherited from class y.base.Graph
AFTER, BEFORE
 
Constructor Summary
StyledLayoutGraph()
           
 
Method Summary
 void addLabel(Edge edge, Label label)
          Adds a label to the given edge.
 void addLabel(Node node, Label label)
          Adds a label to the given node.
 void doLayout(Layouter layouter)
          Calculates a layout for the styled graph using the given layout algorithm.
 YDimension getDefaultNodeSize()
          The default node size the is applied when a new node is created.
 java.util.List getLabels(Edge edge)
          Returns the list of labels registered for the given edge.
 java.util.List getLabels(Node node)
          Returns the list of labels registered for the given node.
 INodeHierarchy getNodeHierarchy()
          Returns an INodeHierarchy for this graph that can be used for grouping related functionality.
 IEdgeStyle getStyle(Edge edge)
          Returns the style that is currenlty registered for the given edge.
 INodeStyle getStyle(Node node)
          Returns the style that is currently registered for the given node.
 java.lang.Object getUserTag(java.lang.Object item)
          Returns the user tag of the provided node, edge or Label

The usertag is retrieved using the data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

 void setDefaultNodeSize(YDimension defaultNodeSize)
          The default node size the is applied when a new node is created.
 void setStyle(Edge edge, IEdgeStyle style)
          Sets an edge style for the given node.
 void setStyle(Node node, INodeStyle style)
          Sets a node style for the given node.
 void setUserTag(java.lang.Object item, java.lang.Object tag)
          Sets the user tag of the provided node, edge or Label

The usertag is set on data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

 void syncLabels(Edge edge, boolean createIfNotExisting)
          Synchronizes all Label instances associated with the given edge with the EdgeLabelLayouts of this graph.
 void syncLabels(Node node, boolean createIfNotExisting)
          Synchronizes all Label instances associated with the given node with the NodeLabelLayouts of this graph.
 
Methods inherited from class y.layout.DefaultLayoutGraph
createEdgeLayout, createGraphCopyFactory, createNodeLayout, getFeature, getFeature, getLabelLayout, getLabelLayout, getLayout, getLayout, setLabelLayout, setLabelLayout, setLabelLayout, setLayout, setLayout
 
Methods inherited from class y.layout.LayoutGraph
getBoundingBox, getCenter, getCenterX, getCenterY, getEdgeLabelLayout, getEdgeLayout, getEdgeList, getHeight, getLocation, getNodeLabelLayout, getNodeLayout, getPath, getPathList, getPointList, getPoints, getRectangle, getSize, getSourcePointAbs, getSourcePointRel, getTargetPointAbs, getTargetPointRel, getWidth, getX, getY, moveBy, setCenter, setCenter, setEndPointsAbs, setLocation, setLocation, setPath, setPath, setPoints, setPoints, setSize, setSize, setSourcePointAbs, setSourcePointRel, setTargetPointAbs, setTargetPointRel
 
Methods inherited from class y.base.Graph
addDataProvider, addGraphListener, changeEdge, changeEdge, changeEdge, clear, contains, contains, containsEdge, createCopy, createEdge, createEdge, createEdgeMap, createGraph, createNode, createNodeMap, disposeEdgeMap, disposeNodeMap, E, edgeCount, edgeObjects, edges, fireGraphEvent, firePostEvent, firePostEvent, firePreEvent, firePreEvent, firstEdge, firstNode, firstOutEdge, getDataProvider, getDataProviderKeys, getEdgeArray, getGraphCopyFactory, getGraphListeners, getNodeArray, getRegisteredEdgeMaps, getRegisteredNodeMaps, getSource, getTarget, hasListeners, hide, hide, isEmpty, lastEdge, lastNode, moveSubGraph, moveToFirst, moveToFirst, moveToLast, moveToLast, N, nodeCount, nodeObjects, nodes, printNodeSlotSize, reInsertEdge, reInsertNode, removeDataProvider, removeEdge, removeGraphListener, removeNode, reverseEdge, setGraphCopyFactory, sortEdges, sortEdges, sortNodes, toString, unhide, unhide
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StyledLayoutGraph

public StyledLayoutGraph()
Method Detail

getNodeHierarchy

public INodeHierarchy getNodeHierarchy()
Returns an INodeHierarchy for this graph that can be used for grouping related functionality.

Returns:
An INodeHierarchy for this graph.

getStyle

public INodeStyle getStyle(Node node)
Returns the style that is currently registered for the given node.

The style is retrieved using the data mapper registered with key GraphRoundtripSupport.NODE_STYLE_DPKEY

Parameters:
node - The node to get the style for.
Returns:
The registered style, or null if no style has been registered yet.

setStyle

public void setStyle(Node node,
                     INodeStyle style)
Sets a node style for the given node.

The style is set using the data mapper registered with the key GraphRoundtripSupport.NODE_STYLE_DPKEY

Parameters:
node - The node
style - the style to use for the given node
See Also:
GraphRoundtripSupport.NODE_STYLE_DPKEY

getStyle

public IEdgeStyle getStyle(Edge edge)
Returns the style that is currenlty registered for the given edge.

The style is retrieved using the data mapper registered with key GraphRoundtripSupport.EDGE_STYLE_DPKEY

Parameters:
edge - The edge to get the style for.
Returns:
The registered style, or null if no style has been registered yet.

setStyle

public void setStyle(Edge edge,
                     IEdgeStyle style)
Sets an edge style for the given node.

The style is set using the data mapper registered with the key GraphRoundtripSupport.EDGE_STYLE_DPKEY

Parameters:
edge - The edge
style - the style to use for the given edge
See Also:
GraphRoundtripSupport.EDGE_STYLE_DPKEY

addLabel

public void addLabel(Node node,
                     Label label)
Adds a label to the given node.

The label is added using the list found in the data mapper registered with the key GraphRoundtripSupport.NODE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new list is created.

Adding a label will not automatically add a label layout instance to the layout graph. Therefore, a label that was newly added using this method will not be considered in a layout calculation. To synchronize the labels of a node with the layout graph, use syncLabels(y.base.Node, boolean).

Parameters:
node - The node to add a label to.
label - The label to add to the node.
See Also:
GraphRoundtripSupport.NODE_LABELS_DPKEY

addLabel

public void addLabel(Edge edge,
                     Label label)
Adds a label to the given edge.

The label is added using the list found in the data mapper registered with the key GraphRoundtripSupport.EDGE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new label list is created.

Adding a label will not automatically add a label layout instance to the layout graph. Therefore, a label that was newly added using this method will not be considered in a layout calculation. To synchronize the labels of an edge with the layout graph, use syncLabels(y.base.Edge, boolean).

Parameters:
edge - The edge to add a label to.
label - The label to add to the edge.
See Also:
GraphRoundtripSupport.EDGE_LABELS_DPKEY

getLabels

public java.util.List getLabels(Node node)
Returns the list of labels registered for the given node.

The list is retrieved using the data mapper registered with key GraphRoundtripSupport.NODE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new list is created.

Parameters:
node - The node to get the registered labels for.
Returns:
The list of labels that are registred for the given node.

getLabels

public java.util.List getLabels(Edge edge)
Returns the list of labels registered for the given edge.

The list is retrieved using the data mapper registered with key GraphRoundtripSupport.EDGE_LABELS_DPKEY

If no label list is registed in the corresponding data map yet, a new list is created.

Parameters:
edge - The edge to retrieve the labels for.
Returns:
The list of labels that are registered for the given edge.

syncLabels

public void syncLabels(Node node,
                       boolean createIfNotExisting)
Synchronizes all Label instances associated with the given node with the NodeLabelLayouts of this graph.

This method can be called if a label was created on the server (e.g. using addLabel(y.base.Edge, com.yworks.yfiles.server.graphml.flexio.data.Label) and a label layout calculation will be executed before the graph is sent back to the client.

Note that either a reasonable preferred size should be set on the Label instance or a style which implements the interface LabelSizeCalculator (e.g. SimpleLabelStyle; in that case, a font should be set to that style, too). If neither is set, (40,40) is used.

Parameters:
node - The node to update the labels from.
createIfNotExisting - Whether to create new label layout instances for this graph, if there are more Label instances associated with this node than label layouts known by the LayoutGraph.

syncLabels

public void syncLabels(Edge edge,
                       boolean createIfNotExisting)
Synchronizes all Label instances associated with the given edge with the EdgeLabelLayouts of this graph.

This method can be called if a label was created on the server (e.g. using addLabel(y.base.Edge, com.yworks.yfiles.server.graphml.flexio.data.Label) and a label layout calculation will be executed before the graph is sent back to the client.

Note that either a reasonable preferred size should be set on the Label instance or a style which implements the interface LabelSizeCalculator (e.g. SimpleLabelStyle; in that case, a font should be set to that style, too). If neither is set, (40,40) is used.

Parameters:
edge - The edge to update the labels from.
createIfNotExisting - Whether to create new label layout instances for this graph, if there are more Label instances associated with this edge than label layouts known by the LayoutGraph.

getUserTag

public java.lang.Object getUserTag(java.lang.Object item)
Returns the user tag of the provided node, edge or Label

The usertag is retrieved using the data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

Parameters:
item - The graph item to retrieve the tag for.
Returns:
The user tag, or null if no user tag has been registered for the provided item.

setUserTag

public void setUserTag(java.lang.Object item,
                       java.lang.Object tag)
Sets the user tag of the provided node, edge or Label

The usertag is set on data mapper registered with key AbstractGraphRoundtripSupport.USERTAGS_DPKEY

Parameters:
item - The graph item to set the tag for.
tag - The user object to set.

getDefaultNodeSize

public YDimension getDefaultNodeSize()
The default node size the is applied when a new node is created.


setDefaultNodeSize

public void setDefaultNodeSize(YDimension defaultNodeSize)
The default node size the is applied when a new node is created.


doLayout

public void doLayout(Layouter layouter)
Calculates a layout for the styled graph using the given layout algorithm.

Parameters:
layouter - The layout algorithm that will be applied to the styled graph.


Copyright © 2000-2007 yWorks GmbH. All rights reserved