Search this API

y.layout
Interface EdgeLabelModel

All Known Implementing Classes:
AutoRotationSliderEdgeLabelModel, DiscreteEdgeLabelModel, FreeEdgeLabelModel, RotatedDiscreteEdgeLabelModel, RotatedSliderEdgeLabelModel, SliderEdgeLabelModel, SmartEdgeLabelModel

public interface EdgeLabelModel

This interface defines the properties of the model associated with an EdgeLabelLayout.

An EdgeLabelModel provides a set of possible candidates for the placement of an edge label. It also defines a parameter that describes the current location of the label.

It is important that all state information is encapsulated in the model parameter. EdgeLabelModel instances may be shared between multiple edge labels but produce different parameters for labels with different locations.

 
Your browser does not support SVG content.

Method Summary
 java.lang.Object createModelParameter(OrientedRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout)
          Creates a model parameter that represents the given edge label position within this model.
 java.lang.Object getDefaultParameter()
          Returns a model parameter that encodes the default position of this model's allowed edge label positions.
 YList getLabelCandidates(EdgeLabelLayout labelLayout, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout)
          Returns all EdgeLabelCandidates that describe valid label positions within this model.
 OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout, java.lang.Object parameter)
          Returns the oriented box of the label for the position encoded by the given model parameter.
 

Method Detail

getDefaultParameter

java.lang.Object getDefaultParameter()
Returns a model parameter that encodes the default position of this model's allowed edge label positions.

This parameter can be passed to getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object) to retrieve the corresponding label box.

Returns:
the model parameter describing the default placement of the edge label

getLabelPlacement

OrientedRectangle getLabelPlacement(YDimension labelSize,
                                    EdgeLayout edgeLayout,
                                    NodeLayout sourceLayout,
                                    NodeLayout targetLayout,
                                    java.lang.Object parameter)
Returns the oriented box of the label for the position encoded by the given model parameter.

 
The provided parameter must have been generated by this model.
Parameters:
labelSize - the width and height of the label
edgeLayout - the layout of the edge to which the label belongs
sourceLayout - the layout of the source node of the label-owning edge
targetLayout - the layout of the target node of the label-owning edge
parameter - the model parameter that describes the abstract position of the label within this model
Returns:
the oriented bounds of the label

getLabelCandidates

YList getLabelCandidates(EdgeLabelLayout labelLayout,
                         EdgeLayout edgeLayout,
                         NodeLayout sourceLayout,
                         NodeLayout targetLayout)
Returns all EdgeLabelCandidates that describe valid label positions within this model.

In case the implementing EdgeLabelModel allows every possible location, this method always returns the current location as a LabelCandidate.

Parameters:
labelLayout - the label for which candidates should be generated
edgeLayout - the layout of the edge to which the label belongs
sourceLayout - the layout of the source node of the label-owning edge
targetLayout - the layout of the target node of the label-owning edge
Returns:
a list of EdgeLabelCandidate instances

createModelParameter

java.lang.Object createModelParameter(OrientedRectangle labelBounds,
                                      EdgeLayout edgeLayout,
                                      NodeLayout sourceLayout,
                                      NodeLayout targetLayout)
Creates a model parameter that represents the given edge label position within this model.

The created model parameter is the closest parameter representation of the given label location that can be achieved within this model.

This parameter can be passed to getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object) to retrieve the current label box.

A model parameter can be an arbitrary Object. However it must contain all information to allow restoring of the encoded location with this EdgeLabelModel.

Parameters:
labelBounds - the oriented box of the label, encoding the label location for which the parameter should be created
edgeLayout - the layout of the edge to which the label belongs
sourceLayout - the layout of the source node of the label-owning edge
targetLayout - the layout of the target node of the label-owning edge
Returns:
the model parameter representing the given label location
See Also:
getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)

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