public class EdgePathLabelModel extends Object implements ILabelModel, ILabelModelParameterProvider, ILabelModelParameterFinder
sides of the edge path.
The set of positions can be influenced by specifying the SideOfEdge value that controls on
which side of the edge labels positions should be considered. Furthermore, it's possible to specify distance values that
control the distance between label and edge and between label and nodes.
If a label model parameter is created EdgeSides.ON_EDGE, the label's center is usually placed on the edge. It
can be shifted by specifying a Offset value but the Distance value is
ignored. For all other values of EdgeSides the total distance between the label bounds and the edge path is the
sum of Offset and Distance.
The label placements use a ratio value as fraction of the full edge
path length. This is the main difference to the EdgePathLabelModel which uses a specified segment index from the
source or target
side and a ratio on this segment.
| Constructor and Description |
|---|
EdgePathLabelModel()
Returns a new instance of
EdgePathLabelModel class. |
EdgePathLabelModel(double distance,
double offset,
double angle,
boolean autoRotationEnabled,
EdgeSides sideOfEdge)
Initializes a new instance of the
EdgePathLabelModel class. |
| Modifier and Type | Method and Description |
|---|---|
ILabelModelParameter |
createDefaultParameter()
A model parameter that encodes the default position of this model's allowed edge label positions.
|
ILabelModelParameter |
createRatioParameter(double edgePathRatio,
EdgeSides sideOfEdge)
Creates a parameter at the provided edge path ratio.
|
ILabelModelParameter |
findBestParameter(ILabel label,
ILabelModel model,
IOrientedRectangle layout)
Tries to find a parameter that best matches the given layout for the provided label instance.
|
double |
getAngle()
Gets the rotation angle of all labels with this model in radians.
|
ILookup |
getContext(ILabel label,
ILabelModelParameter layoutParameter)
Returns an empty context.
|
double |
getDistance()
Gets the distance between the label box and the edge path.
|
IOrientedRectangle |
getGeometry(ILabel label,
ILabelModelParameter layoutParameter)
Calculates the
geometry of the given label using the given model parameter. |
double |
getOffset()
Gets pr sets the offset of the label box and the edge path relative to the default placement.
|
IEnumerable<ILabelModelParameter> |
getParameters(ILabel label,
ILabelModel model)
Returns an enumerator over a set of possible
ILabelModelParameter instances that can be used for the given label
and model. |
EdgeSides |
getSideOfEdge()
Gets the side placement specifiers for edge labels.
|
boolean |
isAutoRotationEnabled()
Gets whether edge labels are automatically rotated according to the angle of the corresponding reference edge segment.
|
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null. |
void |
setAngle(double value)
Sets the rotation angle of all labels with this model in radians.
|
void |
setAutoRotationEnabled(boolean value)
Sets whether edge labels are automatically rotated according to the angle of the corresponding reference edge segment.
|
void |
setDistance(double value)
Sets the distance between the label box and the edge path.
|
void |
setOffset(double value)
Sets pr sets the offset of the label box and the edge path relative to the default placement.
|
void |
setSideOfEdge(EdgeSides value)
Sets the side placement specifiers for edge labels.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookuppublic EdgePathLabelModel()
EdgePathLabelModel class.public EdgePathLabelModel(double distance,
double offset,
double angle,
boolean autoRotationEnabled,
EdgeSides sideOfEdge)
EdgePathLabelModel class.distance - the distance to the edge.offset - the offset to the default placement.angle - the angle of the label's rotation in radians.autoRotationEnabled - if set to true auto rotation is enabled.sideOfEdge - the side of the edge labels.public final ILabelModelParameter createDefaultParameter()
Returns a model parameter that encodes the default position of this model's allowed edge label positions.
createDefaultParameter in interface ILabelModelpublic final ILabelModelParameter createRatioParameter(double edgePathRatio, EdgeSides sideOfEdge)
edgePathRatio - The ratio at which to place the label at the edge path. A ratio of 0.0 will place the label at the source side of the
edge path, a ratio of 1.0 at the target side.sideOfEdge - The side of the edge the label is placed on. Note that only single enum values but no combined ones are allowed.public final ILabelModelParameter findBestParameter(ILabel label, ILabelModel model, IOrientedRectangle layout)
ILabelModelParameterFinder
This method may not necessarily find a parameter that matches the provided layout exactly. Implementations may choose to
simply return the model's default parameter but may never return
null.
findBestParameter in interface ILabelModelParameterFinderlabel - The label to find a parameter for.model - The model instance to use. This should be the instance this instance has been obtained from.layout - The anticipated layout for the label.null parameter that can be used for the label to approximate the provided layout.public final double getAngle()
setAngle(double)public final ILookup getContext(ILabel label, ILabelModelParameter layoutParameter)
getContext in interface ILabelModellabel - The label to use in the context.layoutParameter - The parameter to use for the label in the context.ILookup.EMPTYpublic final double getDistance()
The interpretation of the values depends on the SideOfEdge of the individual
ILabelModelParameter.
Note that for EdgeSides.ON_EDGE this property is ignored. For all other values of EdgeSides the Offset
property is added to this distance.
getSideOfEdge(),
EdgeSides,
getOffset(),
setDistance(double)public final IOrientedRectangle getGeometry(ILabel label, ILabelModelParameter layoutParameter)
ILabelModelgeometry of the given label using the given model parameter.getGeometry in interface ILabelModellabel - The label to calculate the geometry for.layoutParameter - A parameter that is compatible with this model. Typically, this is a parameter that has been created by this model, and
its property Model returns this instance.IOrientedRectangle that describes the geometry of the label. This is typically designed as a flyweight,
therefore clients should not cache the instance but store the values if they need a snapshot for later use.public final double getOffset()
For EdgeSides.ON_EDGE this is the offset between the center of the label box and the edge path. For all other EdgeSides
values this offset is added to the Distance property which results in the total distance between
the label box and the edge path.
getSideOfEdge(),
EdgeSides,
setOffset(double)public final IEnumerable<ILabelModelParameter> getParameters(ILabel label, ILabelModel model)
ILabelModelParameterProviderILabelModelParameter instances that can be used for the given label
and model.getParameters in interface ILabelModelParameterProviderlabel - The label instance to use.model - The model to provide parameters for.public final EdgeSides getSideOfEdge()
The label model parameter finder and provider
returned by lookup(Class) consider the specified sides.
EdgeSides,
setSideOfEdge(EdgeSides)public final boolean isAutoRotationEnabled()
By default, this feature is enabled.
true if edge labels are automatically rotated; false otherwise.setAutoRotationEnabled(boolean)public final <TLookup> TLookup lookup(Class<TLookup> type)
ILookupnull.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.public final void setAngle(double value)
value - The rotation angle of all labels with this model in radians.getAngle()public final void setAutoRotationEnabled(boolean value)
By default, this feature is enabled.
value - true if edge labels are automatically rotated; false otherwise.isAutoRotationEnabled()public final void setDistance(double value)
The interpretation of the values depends on the SideOfEdge of the individual
ILabelModelParameter.
Note that for EdgeSides.ON_EDGE this property is ignored. For all other values of EdgeSides the Offset
property is added to this distance.
value - The distance between the label box and the edge path.getSideOfEdge(),
EdgeSides,
getOffset(),
getDistance()public final void setOffset(double value)
For EdgeSides.ON_EDGE this is the offset between the center of the label box and the edge path. For all other EdgeSides
values this offset is added to the Distance property which results in the total distance between
the label box and the edge path.
value - The offset of the label box and the edge path relative to the default placement.getSideOfEdge(),
EdgeSides,
getOffset()public final void setSideOfEdge(EdgeSides value)
The label model parameter finder and provider
returned by lookup(Class) consider the specified sides.
value - The SideOfEdge to set.EdgeSides,
getSideOfEdge()