public class PreferredPlacementDescriptor extends Object
PreferredPlacementDescriptor
provides placement information for automatic edge labeling.
It provides several options that influence the label placement in generic labeling algorithms and layout algorithms that support integrated label placement.
The preferred placement can describe multiple locations. For some options, like the
placement along the edge
, it is possible to have a combination of the valid values.
These values can be connected with a logical or
-operation.
The following options describe the preferred placement:
The PreferredPlacementDescriptor
will be immutable after freeze()
is called.
A PreferredPlacementDescriptor
must be set for each label and will be retrieved by the layout algorithms calling
PreferredPlacementDescriptor
.
Constructor and Description |
---|
PreferredPlacementDescriptor()
Creates a new
PreferredPlacementDescriptor instance with default settings. |
PreferredPlacementDescriptor(PreferredPlacementDescriptor descriptor)
Creates a new
PreferredPlacementDescriptor instance that copies the given descriptor. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
void |
freeze()
Makes this
PreferredPlacementDescriptor instance immutable. |
double |
getAngle()
Gets the angle (in radians) for the label rotation.
|
LabelAngleOnRightSideOffsets |
getAngleOffsetOnRightSide()
Gets the angle offset for labels that are placed on the right side of the edge.
|
LabelAngleReferences |
getAngleReference()
Gets the reference of the angle given by
Angle . |
LabelAngleOnRightSideRotations |
getAngleRotationOnRightSide()
Gets how the angle is applied to labels on the right side in respect of the labels of the left side of the edge.
|
double |
getDistanceToEdge()
Gets the preferred distance between a label and the corresponding edge segment.
|
LabelPlacements |
getPlaceAlongEdge()
Gets the preferred placement along the edge.
|
LabelPlacements |
getSideOfEdge()
Gets the preferred side of the edge.
|
LabelSideReferences |
getSideReference()
Gets how to interpret the preferred side as given by
SideOfEdge . |
int |
hashCode() |
boolean |
isAngleAbsolute()
Gets whether or not one of the angle interpretations is absolute.
|
boolean |
isAngleOffsetOnRightSide180()
Gets whether or not one of the angle interpretations is to add an angle offset of
180 degrees to labels that are
right of the edge. |
boolean |
isAngleOffsetOnRightSideZero()
Gets whether or not one of the angle interpretations is to add no angle offset to labels that are right of the edge.
|
boolean |
isAngleOnRightSideCoRotating()
Gets whether or not one of the angle interpretations is to rotate the angle of labels that are right of the edge
co-rotating with the labels left of or centered on the edge, i.e., the angle of all labels is interpreted clockwise.
|
boolean |
isAngleOnRightSideCounterRotating()
Gets whether or not one of the angle interpretations is to rotate the angle of labels that are right of the edge
counter-rotating with the labels left of or centered on the edge, i.e., the angle of labels left or centered on edge is
interpreted clockwise while the angle of labels right of edge is interpreted counter-clockwise.
|
boolean |
isAngleRelativeToEdgeFlow()
Gets whether or not one of the angle interpretation is relative to the edge slope.
|
boolean |
isAtCenter()
Gets whether or not one of the preferred placement locations for this label is at center.
|
boolean |
isAtSource()
Gets whether or not one of the preferred placement locations for this label is at source.
|
boolean |
isAtSourcePort()
Gets whether or not one of the preferred placements for this label is at the source port.
|
boolean |
isAtTarget()
Gets whether or not one of the preferred placements for this label is at target.
|
boolean |
isAtTargetPort()
Gets whether or not one of the preferred placements for this label is at the target port.
|
boolean |
isFrozen()
Returns whether or not this is an immutable instance of
PreferredPlacementDescriptor . |
boolean |
isLeftOfEdge()
Gets whether or not one of the preferred sides for this label is left of the edge.
|
boolean |
isOnEdge()
Gets whether or not one of the preferred sides for this label is on the edge.
|
boolean |
isRightOfEdge()
Gets whether or not one of the preferred sides for this label is right of the edge.
|
boolean |
isSideAbsoluteWithLeftInNorth()
Gets whether or not the preferred side specified by
SideOfEdge is interpreted absolute, and on
horizontal segments, labels with preferred side LabelPlacements.LEFT_OF_EDGE are placed above the segment. |
boolean |
isSideAbsoluteWithRightInNorth()
Gets whether or not the preferred side specified by
SideOfEdge is interpreted absolute, and on
horizontal segments, labels with preferred side LabelPlacements.RIGHT_OF_EDGE are placed above the segment. |
boolean |
isSideRelativeToEdgeFlow()
Gets whether or not the preferred side specified by
SideOfEdge is interpreted relative to the
edge flow. |
static PreferredPlacementDescriptor |
newSharedInstance(LabelPlacements placement)
Returns an immutable descriptor instance for the specified placement.
|
void |
setAngle(double value)
Sets the angle (in radians) for the label rotation.
|
void |
setAngleOffsetOnRightSide(LabelAngleOnRightSideOffsets value)
Sets the angle offset for labels that are placed on the right side of the edge.
|
void |
setAngleReference(LabelAngleReferences value)
Sets the reference of the angle given by
Angle . |
void |
setAngleRotationOnRightSide(LabelAngleOnRightSideRotations value)
Sets how the angle is applied to labels on the right side in respect of the labels of the left side of the edge.
|
void |
setDistanceToEdge(double value)
Sets the preferred distance between a label and the corresponding edge segment.
|
void |
setPlaceAlongEdge(LabelPlacements value)
Sets the preferred placement along the edge.
|
void |
setSideOfEdge(LabelPlacements value)
Sets the preferred side of the edge.
|
void |
setSideReference(LabelSideReferences value)
Sets how to interpret the preferred side as given by
SideOfEdge . |
String |
toString() |
public PreferredPlacementDescriptor()
PreferredPlacementDescriptor
instance with default settings.public PreferredPlacementDescriptor(PreferredPlacementDescriptor descriptor)
PreferredPlacementDescriptor
instance that copies the given descriptor.descriptor
- the PreferredPlacementDescriptor
that is copiedpublic void freeze()
PreferredPlacementDescriptor
instance immutable.
If this instance is immutable, all setter
methods will throw an IllegalStateException
when invoked.
isFrozen()
public double getAngle()
How this angle is applied depends on the angle reference
, the rotation
and the offset
for labels on the right side of the edge.
IllegalStateException
- if this instance is immutable
setAngleReference(LabelAngleReferences)
,
setAngleRotationOnRightSide(LabelAngleOnRightSideRotations)
,
setAngleOffsetOnRightSide(LabelAngleOnRightSideOffsets)
,
setAngle(double)
public LabelAngleOnRightSideOffsets getAngleOffsetOnRightSide()
IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is not valid angle offsetLabelAngleOnRightSideOffsets.NONE
0
or 180
degrees)setAngleOffsetOnRightSide(LabelAngleOnRightSideOffsets)
public LabelAngleReferences getAngleReference()
Angle
.IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is not a valid angle referenceLabelAngleReferences.ABSOLUTE
setAngleReference(LabelAngleReferences)
public LabelAngleOnRightSideRotations getAngleRotationOnRightSide()
IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is not a valid angle rotationLabelAngleOnRightSideRotations.CLOCKWISE
setAngleRotationOnRightSide(LabelAngleOnRightSideRotations)
public double getDistanceToEdge()
If the given distance is
< 0
, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm.
IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is infinite or NaN
setDistanceToEdge(double)
public LabelPlacements getPlaceAlongEdge()
IllegalStateException
- if this instance is immutable
LabelPlacements.AT_SOURCE_PORT
and LabelPlacements.AT_TARGET_PORT
that indicate a placement
directly at the edge port are currently only supported by HierarchicLayout
.LabelPlacements.AT_CENTER
setPlaceAlongEdge(LabelPlacements)
public LabelPlacements getSideOfEdge()
IllegalStateException
- if this instance is immutable
LabelPlacements.ON_EDGE
setSideOfEdge(LabelPlacements)
public LabelSideReferences getSideReference()
SideOfEdge
.IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified side reference is invalidLabelSideReferences.RELATIVE_TO_EDGE_FLOW
setSideReference(LabelSideReferences)
public boolean isAngleAbsolute()
true
if absolute angle interpretation is a possible angle interpretation for this label, false
otherwiseLabelAngleReferences.ABSOLUTE
public boolean isAngleOffsetOnRightSide180()
180
degrees to labels that are
right of the edge.true
if adding an angle offset of 180
degrees for right-side edges is a possible angle interpretation
for this label, false
otherwise.isRightOfEdge()
,
LabelAngleOnRightSideOffsets.SEMI
public boolean isAngleOffsetOnRightSideZero()
true
if adding no angle offset for right-side edges is a possible angle interpretation for this label, false
otherwiseisRightOfEdge()
,
LabelAngleOnRightSideOffsets.NONE
public boolean isAngleOnRightSideCoRotating()
true
if co-rotating angle interpretation for right-side edges is a possible angle interpretation for this label,
false
otherwiseisRightOfEdge()
,
LabelAngleOnRightSideRotations.CLOCKWISE
public boolean isAngleOnRightSideCounterRotating()
true
if counter-rotating angle interpretation for right-side edges is a possible angle interpretation for this
label, false
otherwiseisRightOfEdge()
,
LabelAngleOnRightSideRotations.COUNTER_CLOCKWISE
public boolean isAngleRelativeToEdgeFlow()
true
if angle interpretation relative to the edge slope is a possible angle interpretation for this label, false
otherwiseLabelAngleReferences.RELATIVE_TO_EDGE_FLOW
public boolean isAtCenter()
true
if at center is a possible placement for this label, false
otherwiseLabelPlacements.AT_CENTER
public boolean isAtSource()
true
if at source is a possible placement for this label, false
otherwiseLabelPlacements.AT_SOURCE
public boolean isAtSourcePort()
true
if at source port is a possible placement for this label, false
otherwiseLabelPlacements.AT_SOURCE_PORT
public boolean isAtTarget()
true
if at target is a possible placement for this label, false
otherwiseLabelPlacements.AT_TARGET
public boolean isAtTargetPort()
true
if at target port is a possible placement for this label, false
otherwiseLabelPlacements.AT_TARGET_PORT
public boolean isFrozen()
PreferredPlacementDescriptor
.
If this instance is immutable, all setter
methods will throw an IllegalStateException
when invoked.
true
if this instance is immutable, false
otherwisefreeze()
public boolean isLeftOfEdge()
true
if left of the edge is a possible side for this label, false
otherwiseLabelPlacements.LEFT_OF_EDGE
public boolean isOnEdge()
true
if on the edge is a possible side for this label, false
otherwiseLabelPlacements.ON_EDGE
public boolean isRightOfEdge()
true
if right of the edge is a possible side for this label, false
otherwiseLabelPlacements.RIGHT_OF_EDGE
public boolean isSideAbsoluteWithLeftInNorth()
SideOfEdge
is interpreted absolute, and on
horizontal segments, labels with preferred side LabelPlacements.LEFT_OF_EDGE
are placed above the segment.true
if the preferred side is interpreted absolute, false
otherwiseLabelSideReferences.ABSOLUTE_WITH_LEFT_IN_NORTH
public boolean isSideAbsoluteWithRightInNorth()
SideOfEdge
is interpreted absolute, and on
horizontal segments, labels with preferred side LabelPlacements.RIGHT_OF_EDGE
are placed above the segment.true
if the preferred side is interpreted absolute, false
otherwiseLabelSideReferences.ABSOLUTE_WITH_RIGHT_IN_NORTH
public boolean isSideRelativeToEdgeFlow()
SideOfEdge
is interpreted relative to the
edge flow.true
if the preferred side is interpreted relative to the edge flow, false
otherwiseLabelSideReferences.RELATIVE_TO_EDGE_FLOW
public static final PreferredPlacementDescriptor newSharedInstance(LabelPlacements placement)
Descriptor instances returned by this method will use default values for all properties but placement along edge
and side of edge
.
placement
- a combination of valid placements along the edge and valid sides of the edgeisFrozen()
,
getPlaceAlongEdge()
,
getSideOfEdge()
public void setAngle(double value)
How this angle is applied depends on the angle reference
, the rotation
and the offset
for labels on the right side of the edge.
IllegalStateException
- if this instance is immutable
value
- the angle in radianssetAngleReference(LabelAngleReferences)
,
setAngleRotationOnRightSide(LabelAngleOnRightSideRotations)
,
setAngleOffsetOnRightSide(LabelAngleOnRightSideOffsets)
,
getAngle()
public void setAngleOffsetOnRightSide(LabelAngleOnRightSideOffsets value)
IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is not valid angle offsetLabelAngleOnRightSideOffsets.NONE
value
- any combination of valid offsets (0
or 180
degrees)getAngleOffsetOnRightSide()
public void setAngleReference(LabelAngleReferences value)
Angle
.IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is not a valid angle referenceLabelAngleReferences.ABSOLUTE
value
- any combination of valid angle referencesgetAngleReference()
public void setAngleRotationOnRightSide(LabelAngleOnRightSideRotations value)
IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is not a valid angle rotationLabelAngleOnRightSideRotations.CLOCKWISE
value
- any combination of valid rotation directionsgetAngleRotationOnRightSide()
public void setDistanceToEdge(double value)
If the given distance is
< 0
, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm.
IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified value is infinite or NaN
value
- preferred distance between a label and the corresponding edge segmentgetDistanceToEdge()
public void setPlaceAlongEdge(LabelPlacements value)
IllegalStateException
- if this instance is immutable
LabelPlacements.AT_SOURCE_PORT
and LabelPlacements.AT_TARGET_PORT
that indicate a placement
directly at the edge port are currently only supported by HierarchicLayout
.LabelPlacements.AT_CENTER
value
- one of the valid positions along the edgegetPlaceAlongEdge()
public void setSideOfEdge(LabelPlacements value)
IllegalStateException
- if this instance is immutable
LabelPlacements.ON_EDGE
value
- one of the valid sides of the edgegetSideOfEdge()
public void setSideReference(LabelSideReferences value)
SideOfEdge
.IllegalStateException
- if this instance is immutable
IllegalArgumentException
- if the specified side reference is invalidLabelSideReferences.RELATIVE_TO_EDGE_FLOW
value
- any combination of the valid side referencesgetSideReference()