|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.RotatedDiscreteEdgeLabelModel
public class RotatedDiscreteEdgeLabelModel
RotatedDiscreteEdgeLabelModel
describes the placement of rotated labels at some predefined positions along the edge.
The predefined positions in this model
It's possible to specify a distance value that controls the distance between label and edge.
Furthermore, there's the possibility to mask out arbitrary edge label candidates. This can either be done by
specifying predefined candidate masks or combining several label positions with a logical or
-operation
to a user-defined mask.
Field Summary | |
---|---|
static int |
CENTER
Position specifier that describes a label placement near the middle of the edge, directly on the edge's path. |
static int |
CENTERED
Position mask that constrains the allowed positions to the CENTER of the edge's path. |
static int |
HEAD
Position specifier that describes a label placement near the middle of the edge, left/above the edge's path. |
static int |
SCENTER
Position specifier that describes a label placement near the source, directly on the edge's path. |
static int |
SHEAD
Position specifier that describes a label placement near the source, left/above the edge's path. |
static int |
SIX_POS
Position mask that constrains the allowed positions to a set of six positions beside the edge path. |
static int |
STAIL
Position specifier that describes a label placement near the source, right/below the edge's path. |
static int |
TAIL
Position specifier that describes a label placement near the middle of the edge, right/below the edge's path. |
static int |
TCENTER
Position specifier that describes a label placement near the target, directly on the edge's path. |
static int |
THEAD
Position specifier that describes a label placement near the target, left/above the edge's path. |
static int |
THREE_CENTER
Position mask that constrains the allowed positions to a set of three positions directly on the edge's path. |
static int |
TTAIL
Position specifier that describes a label placement near the target, right/below the edge's path. |
static int |
TWO_POS
Position mask that constrains the allowed positions to the two locations near the center of the edge, beside the edge path. |
Constructor Summary | |
---|---|
RotatedDiscreteEdgeLabelModel()
Creates a new instance of RotatedDiscreteEdgeLabelModel with default settings. |
|
RotatedDiscreteEdgeLabelModel(int candidateMask)
Creates a new instance of RotatedDiscreteEdgeLabelModel using the given candidate mask. |
Method Summary | |
---|---|
java.lang.Object |
createModelParameter(OrientedRectangle labelBounds,
EdgeLayout edgeLayout,
NodeLayout sourceNode,
NodeLayout targetNode)
Creates a model parameter that represents the given edge label position within this model. |
static java.lang.Object |
createPositionParameter(int position)
Returns a model parameter that encodes the specified position. |
double |
getAngle()
Returns the angle (measured in radians) of the label model. |
int |
getCandidateMask()
Returns the candidate mask which specifies the valid positions for edge labels. |
java.lang.Object |
getDefaultParameter()
Returns a model parameter that encodes the default position of this model's allowed edge label positions. |
double |
getDistance()
Returns the distance between the label's bounding box and the edge path. |
YList |
getLabelCandidates(EdgeLabelLayout label,
EdgeLayout edgeLayout,
NodeLayout sourceNode,
NodeLayout targetNode)
Returns all EdgeLabelCandidate s that describe valid label positions within this model. |
protected OrientedRectangle |
getLabelPlacement(YDimension labelSize,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout,
int position)
Returns the oriented box of the label for the given 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. |
static int |
getPosition(java.lang.Object parameter)
Returns the position specifier that is encoded by the given model parameter. |
boolean |
isAutoFlippingEnabled()
Returns whether or not edge labels get flipped if they would be upside down in their current position. |
boolean |
isAutoRotationEnabled()
Returns whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment. |
boolean |
isParameterValid(java.lang.Object parameter)
Checks whether or not the given model parameter encodes a valid edge label position for this model. |
boolean |
isPositionRelativeToSegment()
Returns whether or not the label position mask should be interpreted relative to the edge segment. |
void |
setAngle(double angle)
Specifies the angle (measured in radians) of the label model. |
void |
setAutoFlippingEnabled(boolean autoFlippingEnabled)
Specifies whether or not edge labels get flipped if they would be upside down in their current position. |
void |
setAutoRotationEnabled(boolean enabled)
Specifies whether or not edge labels are automatically rotated according to the angle of the corresponding reference edge segment. |
void |
setDistance(double value)
Specifies the distance between the label's bounding box and the edge path. |
void |
setPositionRelativeToSegment(boolean positionRelativeToSegment)
Specifies whether or not the label position mask should be interpreted relative to the edge segment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SHEAD
public static final int HEAD
public static final int THEAD
public static final int STAIL
public static final int TAIL
public static final int TTAIL
public static final int SCENTER
public static final int CENTER
public static final int TCENTER
public static final int TWO_POS
public static final int CENTERED
CENTER
of the edge's path.
public static final int SIX_POS
Two of the positions are near the source and two others are near the target. The remaining positions are in the middle of the edge.
public static final int THREE_CENTER
Constructor Detail |
---|
public RotatedDiscreteEdgeLabelModel()
RotatedDiscreteEdgeLabelModel
with default settings.
public RotatedDiscreteEdgeLabelModel(int candidateMask)
RotatedDiscreteEdgeLabelModel
using the given candidate mask.
The candidates mask can either describe multiple or single valid positions.
candidateMask
- the position mask that defines the allowed positions for an edge labelMethod Detail |
---|
public int getCandidateMask()
SIX_POS
public boolean isPositionRelativeToSegment()
true
if the position mask is interpreted relative to the edge segment, false
otherwisesetPositionRelativeToSegment(boolean)
public void setPositionRelativeToSegment(boolean positionRelativeToSegment)
positionRelativeToSegment
- true
if the position mask should be interpreted relative to the
edge segment, false
otherwiseThe label is placed at HEAD position in relation to the edge segment | The label is placed at HEAD position in a geometric sense |
public boolean isAutoRotationEnabled()
true
if edge labels are automatically rotated according to the angle of the corresponding
reference edge segment, false
otherwisesetAutoRotationEnabled(boolean)
public void setAutoRotationEnabled(boolean enabled)
public boolean isAutoFlippingEnabled()
true
if edge labels get flipped if they would be upside down in their current position,
false
otherwisesetAutoFlippingEnabled(boolean)
public void setAutoFlippingEnabled(boolean autoFlippingEnabled)
public double getAngle()
setAngle(double)
public void setAngle(double angle)
public double getDistance()
The distance must be a non-negative value.
setDistance(double)
public void setDistance(double value)
The distance must be a non-negative value.
public java.lang.Object getDefaultParameter()
getDefaultParameter
in interface EdgeLabelModel
CENTER
when none of the above default positions is part of the allowed
positions.public java.lang.Object createModelParameter(OrientedRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
EdgeLabelModel
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 EdgeLabelModel.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
.
createModelParameter
in interface EdgeLabelModel
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 edge
EdgeLabelModel.getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
public static java.lang.Object createPositionParameter(int position)
This model parameter can be passed to
getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
to determine the label's
position.
position
- one of the valid positions
java.lang.IllegalArgumentException
- if the specified position is unknownpublic static int getPosition(java.lang.Object parameter)
parameter
- the model parameter
java.lang.IllegalArgumentException
- if the specified model parameter is not valid for this modelpublic boolean isParameterValid(java.lang.Object parameter)
If the model parameter describes a position that is accepted by the candidate mask, this is a valid parameter.
parameter
- the model parameter
true
if the label position described by the given model parameter is allowed,
false
otherwisepublic OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode, java.lang.Object param)
EdgeLabelModel
getLabelPlacement
in interface EdgeLabelModel
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 edgeparam
- the model parameter that describes the abstract position of the label within this model
public YList getLabelCandidates(EdgeLabelLayout label, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
EdgeLabelModel
EdgeLabelCandidate
s 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
.
getLabelCandidates
in interface EdgeLabelModel
label
- the label for which candidates should be generatededgeLayout
- 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 edge
EdgeLabelCandidate
instancesprotected OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout, int position)
This method is called by getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
and
getLabelCandidates(EdgeLabelLayout, EdgeLayout, NodeLayout, NodeLayout)
to retrieve a valid position.
labelSize
- the size of the label that should be placededgeLayout
- 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 edgeposition
- the label position that is valid in this model
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |