Search this API

y.layout
Class FreeEdgeLabelModel

java.lang.Object
  extended by y.layout.FreeEdgeLabelModel
All Implemented Interfaces:
EdgeLabelModel

public class FreeEdgeLabelModel
extends java.lang.Object
implements EdgeLabelModel

FreeEdgeLabelModel allows placing edge labels at any location.

 

Nested Class Summary
static class FreeEdgeLabelModel.ModelParameter
          This model parameter encodes a label position within FreeEdgeLabelModel.
 
Constructor Summary
FreeEdgeLabelModel()
          Creates a new instance of FreeEdgeLabelModel.
 
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 the model parameter that encodes the default position of FreeEdgeLabelModel.
 YList getLabelCandidates(EdgeLabelLayout labelLayout, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout)
          Returns the EdgeLabelCandidate that describes the current label position.
 OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode, java.lang.Object param)
          Returns the oriented box of the label for the position encoded by the given model parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeEdgeLabelModel

public FreeEdgeLabelModel()
Creates a new instance of FreeEdgeLabelModel.

Method Detail

getDefaultParameter

public java.lang.Object getDefaultParameter()
Returns the model parameter that encodes the default position of FreeEdgeLabelModel. The distance of the label to the edge's source point will be 20. The angle between the line to the center of the label and the first segment is 20 radians. The label is not rotated.

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

Specified by:
getDefaultParameter in interface EdgeLabelModel
Returns:
the model parameter describing the default placement of the edge label

createModelParameter

public 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 represents the current location of the given label.

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

Specified by:
createModelParameter in interface EdgeLabelModel
Parameters:
labelBounds - the oriented box of the label the parameter represents
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
Throws:
java.lang.IllegalArgumentException - if one or more of the given bounds' values are invalid, i.e., NaN
See Also:
getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)

getLabelPlacement

public OrientedRectangle getLabelPlacement(YDimension labelSize,
                                           EdgeLayout edgeLayout,
                                           NodeLayout sourceNode,
                                           NodeLayout targetNode,
                                           java.lang.Object param)
Description copied from interface: EdgeLabelModel
Returns the oriented box of the label for the position encoded by the given model parameter.

Specified by:
getLabelPlacement in interface EdgeLabelModel
Parameters:
labelSize - the width and height of the label
edgeLayout - the layout of the edge to which the label belongs
sourceNode - the layout of the source node of the label-owning edge
targetNode - the layout of the target node of the label-owning edge
param - the model parameter that describes the abstract position of the label within this model
Returns:
the oriented bounds of the label

getLabelCandidates

public YList getLabelCandidates(EdgeLabelLayout labelLayout,
                                EdgeLayout edgeLayout,
                                NodeLayout sourceLayout,
                                NodeLayout targetLayout)
Returns the EdgeLabelCandidate that describes the current label position.

Specified by:
getLabelCandidates in interface EdgeLabelModel
 
The returned list contains only one candidate which describes the current location.
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

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