|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.DiscreteEdgeLabelModel
public class DiscreteEdgeLabelModel
DiscreteEdgeLabelModel
describes the placement of 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 a combination of valid positions of this model using a logical
or
-operation.
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 middle of the edge beside the edge's path. |
Constructor Summary | |
---|---|
DiscreteEdgeLabelModel()
Creates a new instance of DiscreteEdgeLabelModel with default settings. |
|
DiscreteEdgeLabelModel(int candidateMask)
Creates a new instance of DiscreteEdgeLabelModel 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. |
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 labelLayout,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout)
Returns all EdgeLabelCandidate s that describe valid label positions within this model considering the
current candidate mask . |
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 parameter)
Returns the oriented box of the label for the position encoded by the given model parameter. |
boolean |
isParameterValid(java.lang.Object parameter)
Checks whether or not the given model parameter encodes a valid edge label position for this model. |
void |
setDistance(double value)
Specifies the distance between the label's bounding box and the edge path. |
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 DiscreteEdgeLabelModel()
DiscreteEdgeLabelModel
with default settings.
public DiscreteEdgeLabelModel(int candidateMask)
DiscreteEdgeLabelModel
using the given candidate mask.
The specified mask can also describe a single position.
candidateMask
- the position mask that defines the allowed positions for an edge labelMethod Detail |
---|
public int getCandidateMask()
This mask can also describe a single position.
SIX_POS
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 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 parameter)
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 edgeparameter
- 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 considering the
current candidate mask
.
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
instances describing valid label positionsgetCandidateMask()
protected 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 |