public class SliderEdgeLabelLayoutModel extends Object implements IEdgeLabelLayoutModel
SliderEdgeLabelLayoutModel
allows placement of labels at a set of continuous rotated positions along both sides
of an edge or directly on the edge path.
It is possible to specify distance values that control the distance between label and edge and between label and nodes.
SliderMode.CENTER
mode on the left, SliderMode.SIDE
mode in the middle and SliderMode.SINGLE_SIDE
on the right
Constructor and Description |
---|
SliderEdgeLabelLayoutModel(SliderMode mode)
Creates a new instance of
SliderEdgeLabelLayoutModel with the given mode. |
Modifier and Type | Method and Description |
---|---|
Object |
createModelParameter(YOrientedRectangle labelBounds,
IEdgeLayout edgeLayout,
INodeLayout sourceNode,
INodeLayout targetNode)
Creates a model parameter that represents the given edge label position within this model.
|
double |
getAngle()
Gets the angle (measured in radians) of the label model.
|
Object |
getDefaultParameter()
Gets a model parameter that encodes the default position of this model's allowed edge label positions.
|
double |
getDistance()
Gets the distance between the label's box and the edge's path.
|
YList |
getLabelCandidates(IEdgeLabelLayout labelLayout,
IEdgeLayout edgeLayout,
INodeLayout sourceLayout,
INodeLayout targetLayout)
Returns all
EdgeLabelCandidate s that describe valid label positions within this model. |
YOrientedRectangle |
getLabelPlacement(YDimension labelSize,
IEdgeLayout edgeLayout,
INodeLayout sourceNode,
INodeLayout targetNode,
Object para)
Returns the oriented box of the label for the position encoded by the given model parameter.
|
SliderMode |
getMode()
Gets the model's slider mode which determines whether the label slides
on the edge , along both sides of the edge
or along one side of the edge . |
boolean |
isAutoFlipping()
Gets whether or not edge labels get flipped if they would be upside down in their current position.
|
boolean |
isAutoRotationEnabled()
Gets whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge
segment.
|
boolean |
isDistanceRelativeToEdge()
Gets whether or not the distance to the edge is interpreted relative to the edge's path.
|
void |
setAngle(double value)
Sets the angle (measured in radians) of the label model.
|
void |
setAutoFlipping(boolean value)
Sets whether or not edge labels get flipped if they would be upside down in their current position.
|
void |
setAutoRotationEnabled(boolean value)
Sets whether or not 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's box and the edge's path.
|
void |
setDistanceRelativeToEdge(boolean value)
Sets whether or not the distance to the edge is interpreted relative to the edge's path.
|
public SliderEdgeLabelLayoutModel(SliderMode mode)
SliderEdgeLabelLayoutModel
with the given mode.mode
- the slider modegetMode()
public Object createModelParameter(YOrientedRectangle labelBounds, IEdgeLayout edgeLayout, INodeLayout sourceNode, INodeLayout targetNode)
IEdgeLabelLayoutModel
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 IEdgeLabelLayoutModel.getLabelPlacement(YDimension, IEdgeLayout, INodeLayout, INodeLayout, 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 IEdgeLabelLayoutModel
.
createModelParameter
in interface IEdgeLabelLayoutModel
labelBounds
- the oriented box of the label, encoding the label location for which the parameter should be creatededgeLayout
- the layout of the edge to which the label belongssourceNode
- the layout of the source node of the label-owning edgetargetNode
- the layout of the target node of the label-owning edgeIEdgeLabelLayoutModel.getLabelPlacement(YDimension, IEdgeLayout, INodeLayout, INodeLayout, Object)
public double getAngle()
The angle is applied in clockwise direction.
setAngle(double)
public Object getDefaultParameter()
This parameter can be passed to getLabelPlacement(YDimension, IEdgeLayout, INodeLayout, INodeLayout, Object)
to
retrieve the corresponding label box.
The default positions for the slider modes
are relative to the first edge segment, either at the
beginning of the segment (SliderMode.SIDE
or
SliderMode.SINGLE_SIDE
) or at its middle (SliderMode.CENTER
).
getDefaultParameter
in interface IEdgeLabelLayoutModel
getMode()
public double getDistance()
DistanceRelativeToEdge
.setDistanceRelativeToEdge(boolean)
,
setDistance(double)
public YList getLabelCandidates(IEdgeLabelLayout labelLayout, IEdgeLayout edgeLayout, INodeLayout sourceLayout, INodeLayout targetLayout)
EdgeLabelCandidate
s that describe valid label positions within this model.
The number of candidates and their respective locations are computed depending on the geometries of both label and edge.
getLabelCandidates
in interface IEdgeLabelLayoutModel
labelLayout
- the label for which candidates should be generatededgeLayout
- the layout of the edge to which the label belongssourceLayout
- the layout of the source node of the label-owning edgetargetLayout
- the layout of the target node of the label-owning edgeEdgeLabelCandidate
instancespublic YOrientedRectangle getLabelPlacement(YDimension labelSize, IEdgeLayout edgeLayout, INodeLayout sourceNode, INodeLayout targetNode, Object para)
IEdgeLabelLayoutModel
getLabelPlacement
in interface IEdgeLabelLayoutModel
labelSize
- the width and height of the labeledgeLayout
- the layout of the edge to which the label belongssourceNode
- the layout of the source node of the label-owning edgetargetNode
- the layout of the target node of the label-owning edgepara
- the model parameter that describes the abstract position of the label within this modelpublic SliderMode getMode()
on the edge
, along both sides of the edge
or along one side of the edge
.public boolean isAutoFlipping()
false
. Edge labels keep their orientation.true
if edge labels get flipped if they would be upside down in their current position, false
otherwisesetAutoFlipping(boolean)
public boolean isAutoRotationEnabled()
true
. Labels are rotated with their edge segment.true
if edge labels are automatically rotated according to the angle of the corresponding reference edge
segment, false
otherwisesetAutoRotationEnabled(boolean)
public boolean isDistanceRelativeToEdge()
If enabled, the label is placed to the left of the edge segment (relative to the segment direction) if the given
distance is less than 0
and to the right of the edge segment if the given distance is greater than 0
.
If disabled, the label is placed below the edge segment (in geometric sense) if the distance is less than 0
and
above the edge segment if the distance is greater than 0
.
true
. The distance to the edge is interpreted relative to the edge's path.true
if the distance is described relative to the edge, false
otherwisesetDistance(double)
,
setDistanceRelativeToEdge(boolean)
public void setAngle(double value)
The angle is applied in clockwise direction.
value
- the angle of the label modelgetAngle()
public void setAutoFlipping(boolean value)
false
. Edge labels keep their orientation.value
- true
if edge labels get flipped if they would be upside down in their current position, false
otherwiseisAutoFlipping()
public void setAutoRotationEnabled(boolean value)
true
. Labels are rotated with their edge segment.value
- true
if edge labels are automatically rotated according to the angle of the corresponding reference edge
segment, false
otherwiseisAutoRotationEnabled()
public void setDistance(double value)
DistanceRelativeToEdge
.value
- the distance between the label's box and the edge's pathsetDistanceRelativeToEdge(boolean)
,
getDistance()
public void setDistanceRelativeToEdge(boolean value)
If enabled, the label is placed to the left of the edge segment (relative to the segment direction) if the given
distance is less than 0
and to the right of the edge segment if the given distance is greater than 0
.
If disabled, the label is placed below the edge segment (in geometric sense) if the distance is less than 0
and
above the edge segment if the distance is greater than 0
.
true
. The distance to the edge is interpreted relative to the edge's path.value
- true
if the distance is described relative to the edge, false
otherwisesetDistance(double)
,
isDistanceRelativeToEdge()