|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.SliderEdgeLabelModel
public class SliderEdgeLabelModel
SliderEdgeLabelModel
allows placement of labels at a set of continuous positions
along both sides of an edge or directly on the edge path.
The set of positions can be influenced by specifying the density value
which controls
the spacing between adjacent label positions.
Furthermore, it's possible to specify distance values that control the distance between label and edge and between label and nodes.
CENTER_SLIDER
mode on the left and SIDE_SLIDER
mode on the right
Nested Class Summary | |
---|---|
static class |
SliderEdgeLabelModel.ModelParameter
Encodes the model parameters for the two slider modes. |
Field Summary | |
---|---|
static byte |
CENTER_RATIO
Ratio specifier that describes a label placement on the edge's path. |
static byte |
CENTER_SLIDER
Slider mode specifier which describes continuous label positions directly on the edge path. |
static byte |
HEAD_RATIO
Ratio specifier that describes a label placement left or above of the edge's path. |
static byte |
LEFT_RATIO
Ratio specifier that describes a label placement left of the edge's path. |
static byte |
RIGHT_RATIO
Ratio specifier that describes a label placement right of the edge's path. |
static byte |
SIDE_SLIDER
Slider mode specifier which describes continuous label positions along the sides of the edge path. |
static byte |
TAIL_RATIO
Ratio specifier that describes a label placement right or below of the edge's path. |
Constructor Summary | |
---|---|
SliderEdgeLabelModel(byte mode)
Creates a new instance of SliderEdgeLabelModel with the given mode. |
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. |
java.lang.Object |
getDefaultParameter()
Returns a model parameter that encodes the default position of this model's allowed edge label positions. |
double |
getDensity()
Returns the density for the generation of label candidate positions. |
YList |
getLabelCandidates(EdgeLabelLayout labelLayout,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout)
Returns all EdgeLabelCandidate s that describe valid label positions within this model. |
OrientedRectangle |
getLabelPlacement(YDimension labelSize,
EdgeLayout edgeLayout,
NodeLayout sourceNode,
NodeLayout targetNode,
java.lang.Object para)
Returns the oriented box of the label for the position encoded by the given model parameter. |
double |
getMaximumDistance()
Returns the maximum distance between the label's bounding box and the edge's path. |
double |
getMinimumDistance()
Returns the minimum distance between the label's bounding box and the edge's path. |
byte |
getMode()
Returns the model's slider mode which determines whether the label slides on the edge or
beside the edge . |
double |
getNodeBorderDistance()
Returns the minimum distance between the label's bounding box and a node's borders. |
YVector |
getOffsetVec(double dx,
double dy,
double width,
double height,
byte position)
Returns the offset vector for a given edge label and a given edge segment. |
void |
setDensity(double density)
Specifies the density for the generation of label candidate positions. |
void |
setDistances(double minDistance,
double maxDistance)
Specifies the minimum and maximum distances between the label's bounding box and the edge's path. |
void |
setMaximumDistance(double distance)
Specifies the maximum distance between the label's bounding box and the edge's path. |
void |
setMinimumDistance(double distance)
Specifies the minimum distance between the label's bounding box and the edge's path. |
void |
setNodeBorderDistance(double value)
Specifies the minimum distance between the label's bounding box and a node's borders. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte CENTER_SLIDER
public static final byte SIDE_SLIDER
public static final byte CENTER_RATIO
public static final byte TAIL_RATIO
public static final byte HEAD_RATIO
public static final byte LEFT_RATIO
public static final byte RIGHT_RATIO
Constructor Detail |
---|
public SliderEdgeLabelModel(byte mode)
SliderEdgeLabelModel
with the given mode.
mode
- the slider modegetMode()
Method Detail |
---|
public byte getMode()
on the edge
or
beside the edge
.
CENTER_SLIDER
,
SIDE_SLIDER
public void setDistances(double minDistance, double maxDistance)
The distances need to be non-negative.
minDistance
- the minimum distance between label and edgemaxDistance
- the maximum distance between label and edgegetMaximumDistance()
,
getMinimumDistance()
,
setMaximumDistance(double)
,
setMinimumDistance(double)
public double getMaximumDistance()
The distance needs to be non-negative.
setMaximumDistance(double)
,
setDistances(double, double)
public void setMaximumDistance(double distance)
The distance needs to be non-negative.
distance
- the maximum distance between label and edgesetDistances(double, double)
public double getMinimumDistance()
The distance needs to be non-negative.
setMinimumDistance(double)
,
setDistances(double, double)
public void setMinimumDistance(double distance)
The distance needs to be non-negative.
distance
- the minimum distance between label and edgesetDistances(double, double)
public double getDensity()
The density is defined as a value between 0
and 1
. Lower densities will result in less
LabelCandidate
s. A density value of 1.0
generates the maximum number of possible candidate
positions without overlap.
setDensity(double)
public void setDensity(double density)
The density is defined as a value between 0
and 1
. Lower densities will result in less
LabelCandidate
s. A density value of 1.0
generates the maximum number of possible candidate
positions without overlap.
public double getNodeBorderDistance()
The distance must be non-negative.
setNodeBorderDistance(double)
public void setNodeBorderDistance(double value)
The distance must be non-negative.
public java.lang.Object getDefaultParameter()
This parameter can be passed to getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
to retrieve the corresponding label box.
slider modes
are relative to the
first edge segment, either at the beginning of the segment (SIDE_SLIDER
) or at its middle
(CENTER_SLIDER
).
getDefaultParameter
in interface EdgeLabelModel
getMode()
public OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode, java.lang.Object para)
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 edgepara
- the model parameter that describes the abstract position of the label within this model
public YList getLabelCandidates(EdgeLabelLayout labelLayout, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout 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 EdgeLabelModel
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 edge
EdgeLabelCandidate
instancespublic 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 YVector getOffsetVec(double dx, double dy, double width, double height, byte position)
dx
- the x-coordinate's delta for an edge segmentdy
- the y-coordinate's delta for an edge segmentwidth
- the label's widthheight
- the label's heightposition
- one of the valid ratio specifiers
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |