Search this API

y.layout
Interface LabelLayoutFactory


public interface LabelLayoutFactory

LabelLayoutFactory provides methods to create, add and remove node/edge labels for LayoutGraphs. It can be used, e.g., to temporarily add labels during layout calculation.

Note that original labels which are removed during a layout calculation have to be re-added when the layout calculation is done. Otherwise buffered layout calculations and delayed layout results will most likely produce incorrect results or break down with ClassCastExceptions.

An instance of this factory can be obtained with method LayoutTool.getLabelFactory(LayoutGraph). This method uses the LayoutGraph.createLabelFactory() method to create the factory.

Note that each factory instance is bound to a specific graph instance, i.e., you can only create, add and remove labels for the graph which was given to method LayoutTool.getLabelFactory(LayoutGraph).

 

Method Summary
 void addLabelLayout(Edge edge, EdgeLabelLayout labelLayout)
          Adds the given EdgeLabelLayout to the given edge.
 void addLabelLayout(Node node, NodeLabelLayout labelLayout)
          Adds the given node label layout to the given node.
 EdgeLabelLayout createEdgeLabelLayout(Edge edge, OrientedRectangle orientedBox)
          Creates a new LabelLayout for the given edge.
 EdgeLabelLayout createEdgeLabelLayout(Edge edge, OrientedRectangle orientedBox, EdgeLabelModel model, PreferredPlacementDescriptor descriptor)
          Creates a new LabelLayout for the given edge.
 NodeLabelLayout createNodeLabelLayout(Node node, OrientedRectangle orientedBox)
          Creates a new LabelLayout for the given node.
 NodeLabelLayout createNodeLabelLayout(Node node, OrientedRectangle orientedBox, NodeLabelModel model)
          Creates a new LabelLayout for the given node.
 LayoutGraph getGraph()
          Returns the graph associated with this label factory instance.
 void removeLabelLayout(Edge edge, EdgeLabelLayout labelLayout)
          Removes the given EdgeLabelLayout from the given edge.
 void removeLabelLayout(Node node, NodeLabelLayout labelLayout)
          Removes the given node label layout from the given node.
 

Method Detail

getGraph

LayoutGraph getGraph()
Returns the graph associated with this label factory instance.

Returns:
the graph associated with this label factory instance

addLabelLayout

void addLabelLayout(Node node,
                    NodeLabelLayout labelLayout)
Adds the given node label layout to the given node. The given label layout has to be created with method createNodeLabelLayout(Node, OrientedRectangle) or createNodeLabelLayout(Node, OrientedRectangle, NodeLabelModel).

 
Implementations of this method must ensure that re-adding temporarily removed original labels during buffered layout calculations automatically restores the original order of labels at the given node. Otherwise, the layout calculation will most likely produce incorrect results or break down with ClassCastExceptions.
Parameters:
node - the node
labelLayout - the node label layout that should be added to the given node
Throws:
java.lang.IllegalArgumentException - if the given label layout has already been added to the graph
See Also:
createNodeLabelLayout(Node, OrientedRectangle), createNodeLabelLayout(Node, OrientedRectangle, NodeLabelModel)

removeLabelLayout

void removeLabelLayout(Node node,
                       NodeLabelLayout labelLayout)
Removes the given node label layout from the given node.

 
Original labels which are removed during a layout calculation have to be re-added when the layout calculation is done. Otherwise, buffered layout calculations and delayed layout results will most likely produce incorrect results or break down with ClassCastExceptions.
Parameters:
node - the node
labelLayout - the label layout that should be removed from the given node
See Also:
addLabelLayout(Edge, EdgeLabelLayout)

createNodeLabelLayout

NodeLabelLayout createNodeLabelLayout(Node node,
                                      OrientedRectangle orientedBox)
Creates a new LabelLayout for the given node.

This method should create a LabelLayout with a NodeLabelModel that supports the desired oriented label box exactly as given.

 
Calling this method has no effect on the node's labels. The returned label layout has to be added to the node using method addLabelLayout(Node, NodeLabelLayout).
Parameters:
node - the node
orientedBox - the box specifying the size and location of the label
Returns:
a new node label layout
See Also:
addLabelLayout(Node, NodeLabelLayout)

createNodeLabelLayout

NodeLabelLayout createNodeLabelLayout(Node node,
                                      OrientedRectangle orientedBox,
                                      NodeLabelModel model)
Creates a new LabelLayout for the given node.

 
Calling this method has no effect on the node's labels. The returned label layout has to be added to the node using method addLabelLayout(Node, NodeLabelLayout).
Parameters:
node - the node
orientedBox - the box specifying the size and location of the label
model - specifies the model of the created node label
Returns:
a new node label layout
See Also:
addLabelLayout(Node, NodeLabelLayout)

addLabelLayout

void addLabelLayout(Edge edge,
                    EdgeLabelLayout labelLayout)
Adds the given EdgeLabelLayout to the given edge. The given LabelLayout has to be created with method createEdgeLabelLayout(Edge, OrientedRectangle) or createEdgeLabelLayout(Edge, OrientedRectangle, EdgeLabelModel, PreferredPlacementDescriptor).

 
Implementations of this method must ensure that re-adding temporarily removed original labels during buffered layout calculations automatically restores the original order of labels of the given edge. Otherwise, the layout calculation will most likely produce incorrect results or break down with ClassCastExceptions.
Parameters:
edge - the edge
labelLayout - the edge label layout that should be added to the given edge
Throws:
java.lang.IllegalArgumentException - if the given label layout has already been added to the graph
See Also:
createEdgeLabelLayout(Edge, OrientedRectangle), createEdgeLabelLayout(Edge, OrientedRectangle, EdgeLabelModel, PreferredPlacementDescriptor)

removeLabelLayout

void removeLabelLayout(Edge edge,
                       EdgeLabelLayout labelLayout)
Removes the given EdgeLabelLayout from the given edge.

 
Original labels which are removed during a layout calculation have to be re-added when the layout calculation is done. Otherwise, buffered layout calculations and delayed layout results will most likely produce incorrect results or break down with ClassCastExceptions.
Parameters:
edge - the edge
labelLayout - the label layout that should be removed from the given edge
See Also:
addLabelLayout(Edge, EdgeLabelLayout)

createEdgeLabelLayout

EdgeLabelLayout createEdgeLabelLayout(Edge edge,
                                      OrientedRectangle orientedBox)
Creates a new LabelLayout for the given edge.

This method should create a LabelLayout with an EdgeLabelModel that supports the desired oriented label box exactly as given.

 
Calling this method has no effect on the edge's labels. The returned label layout has to be added to the edge using method addLabelLayout(Edge, EdgeLabelLayout).
Parameters:
edge - the edge
orientedBox - the box specifying the size and location of the label
Returns:
a new edge label layout
See Also:
addLabelLayout(Edge, EdgeLabelLayout)

createEdgeLabelLayout

EdgeLabelLayout createEdgeLabelLayout(Edge edge,
                                      OrientedRectangle orientedBox,
                                      EdgeLabelModel model,
                                      PreferredPlacementDescriptor descriptor)
Creates a new LabelLayout for the given edge.

 
Calling this method has no effect on the edge's labels. The returned LabelLayout has to be added to the edge using method addLabelLayout(Edge, EdgeLabelLayout).
Parameters:
edge - the edge
orientedBox - the box specifying the size and location of the label
model - specifies the model of the created edge label
descriptor - specifies the preferred placement descriptor of the created label. If this value is null, the default descriptor is used
Returns:
a new edge label layout
See Also:
addLabelLayout(Edge, EdgeLabelLayout)

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