|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.SmartEdgeLabelModel
public class SmartEdgeLabelModel
An edge label model that allows the placement of labels at arbitrary positions.
In the move label mode (see MoveLabelMode
) it allows to snap to suitable label positions.
Field Summary | |
---|---|
static int |
POSITION_CENTER
Symbolic position specifier. |
static int |
POSITION_LEFT
Symbolic position specifier. |
static int |
POSITION_RIGHT
Symbolic position specifier. |
static int |
POSITION_SOURCE_CENTER
Symbolic position specifier. |
static int |
POSITION_SOURCE_LEFT
Symbolic position specifier. |
static int |
POSITION_SOURCE_RIGHT
Symbolic position specifier. |
static int |
POSITION_TARGET_CENTER
Symbolic position specifier. |
static int |
POSITION_TARGET_LEFT
Symbolic position specifier. |
static int |
POSITION_TARGET_RIGHT
Symbolic position specifier. |
Constructor Summary | |
---|---|
SmartEdgeLabelModel()
Initializes a new SmartEdgeLabelModel instance. |
Method Summary | |
---|---|
java.lang.Object |
createDiscreteModelParameter(int position)
Creates a model parameter for a label at a given position. |
java.lang.Object |
createModelParameter(OrientedRectangle labelBounds,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout)
Creates a model parameter that represents the given label bounds best within this model. |
MoveLabelMode.MoveLabelHelper |
createMoveLabelHelper()
Creates a move helper for labels that use this SmartEdgeLabelModel instance. |
java.lang.Object |
createRelativeModelParameter(OrientedRectangle labelBounds,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout)
Creates a model parameter that represents the given label bounds best within this model. |
static double |
getAngle(java.lang.Object modelParameter)
Returns the angle (measured in radians) encoded in the specified model parameter. |
double |
getDefaultAngle()
Returns the default angle (measured in radians) of the label model which is used to create the default parameter. |
double |
getDefaultDistance()
Returns the default distance which is used to create the default parameter. |
java.lang.Object |
getDefaultParameter()
Returns the default parameter which uses the specified default angle and distance. |
YList |
getLabelCandidates(EdgeLabelLayout labelLayout,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout)
Returns a list of EdgeLabelCandidate objects each of which describes a valid label position within this model. |
OrientedRectangle |
getLabelPlacement(YDimension labelSize,
EdgeLayout edgeLayout,
NodeLayout sourceLayout,
NodeLayout targetLayout,
java.lang.Object param)
Returns the bounds of the label for the position encoded by the given model parameter. |
boolean |
isAutoFlippingEnabled()
Determines 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. |
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 have to be automatically rotated according to the angle of the corresponding reference edge segment. |
void |
setDefaultAngle(double defaultAngle)
Sets the default angle (measured in radians) of the label model which is used to create the default parameter. |
void |
setDefaultDistance(double defaultDistance)
Sets the default distance which is used to create the default parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int POSITION_SOURCE_CENTER
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_SOURCE_LEFT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_SOURCE_RIGHT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_TARGET_CENTER
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_TARGET_LEFT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_TARGET_RIGHT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_CENTER
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_LEFT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_RIGHT
createDiscreteModelParameter(int)
,
Constant Field ValuesConstructor Detail |
---|
public SmartEdgeLabelModel()
SmartEdgeLabelModel
instance.
Method Detail |
---|
public boolean isAutoRotationEnabled()
By default, this feature is disabled.
true
if edge labels are automatically rotated
according to the angle of the corresponding reference edge segment and
false
if they are not.setAutoRotationEnabled(boolean)
public void setAutoRotationEnabled(boolean enabled)
By default, this feature is disabled.
enabled
- if true
edge labels are automatically rotated
according to the angle of the corresponding reference edge segment.isAutoRotationEnabled()
public boolean isAutoFlippingEnabled()
By default, this feature is disabled.
true
if edge labels get flipped if they would be upside down in their current position,
false
otherwise.setAutoFlippingEnabled(boolean)
public void setAutoFlippingEnabled(boolean autoFlippingEnabled)
By default, this feature is disabled.
autoFlippingEnabled
- true
if edge labels get flipped if they would be upside down in their
current position.isAutoFlippingEnabled()
public double getDefaultAngle()
getDefaultParameter()
public void setDefaultAngle(double defaultAngle)
defaultAngle
- the angle of the label model.getDefaultParameter()
public double getDefaultDistance()
getDefaultParameter()
public void setDefaultDistance(double defaultDistance)
defaultDistance
- the used default distance.getDefaultParameter()
public java.lang.Object getDefaultParameter()
getDefaultParameter
in interface EdgeLabelModel
setDefaultAngle(double)
,
setDefaultDistance(double)
public java.lang.Object createDiscreteModelParameter(int position)
position
- one of the following positions:
POSITION_SOURCE_CENTER
,
POSITION_TARGET_CENTER
,
POSITION_CENTER
,
POSITION_SOURCE_LEFT
,
POSITION_TARGET_LEFT
,
POSITION_LEFT
,
POSITION_SOURCE_RIGHT
,
POSITION_TARGET_RIGHT
, and
POSITION_RIGHT
.
DiscreteEdgeLabelModel.THREE_CENTER
,
DiscreteEdgeLabelModel.SIX_POS
public OrientedRectangle getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout, java.lang.Object param)
getLabelPlacement
in interface EdgeLabelModel
labelSize
- The size of the label that should be placed.edgeLayout
- The layout of the edge to which the label belongs.sourceLayout
- The layout of the source node of the label owning edge.targetLayout
- The layout of the target node of the label owning edge.param
- The model parameter that describes the abstract position of the label within this model.
Note: the parameter must have been generated by this model.
public YList getLabelCandidates(EdgeLabelLayout labelLayout, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout)
EdgeLabelCandidate
objects each of which describes a valid label position within this model.
getLabelCandidates
in interface EdgeLabelModel
labelLayout
- The label for which candidates should be generated.edgeLayout
- The layout of the edge to which the label belongs.sourceLayout
- The layout of the source node of the label owning edge.targetLayout
- The layout of the target node of the label owning edge.
EdgeLabelCandidate
objects.public java.lang.Object createModelParameter(OrientedRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout)
getLabelPlacement(y.geom.YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
is equal to labelBounds.
The only exception to this rule is if an edge has no visible path, i.e., if the source node overlaps
with the target node.
createModelParameter
in interface EdgeLabelModel
labelBounds
- The bounds of the label for which a parameter representation is sought.edgeLayout
- The layout of the edge to which the label belongs.sourceLayout
- The layout of the source node of the label owning edge.targetLayout
- The layout of the target node of the label owning edge.
getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
method.EdgeLabelModel.getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
public java.lang.Object createRelativeModelParameter(OrientedRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceLayout, NodeLayout targetLayout)
setAutoRotationEnabled(boolean)
).
labelBounds
- The bounds of the label for which a parameter representation is sought.edgeLayout
- The layout of the edge to which the label belongs.sourceLayout
- The layout of the source node of the label owning edge.targetLayout
- The layout of the target node of the label owning edge.
getLabelPlacement(YDimension, EdgeLayout, NodeLayout, NodeLayout, Object)
method.public MoveLabelMode.MoveLabelHelper createMoveLabelHelper()
SmartEdgeLabelModel
instance.
The helper supports snapping.
createMoveLabelHelper
in interface MoveLabelMode.MoveLabelHelperProvider
public static double getAngle(java.lang.Object modelParameter)
modelParameter
- the model parameter from which the angle has to be
extracted.
java.lang.IllegalArgumentException
- if the specified model parameter is not
valid for 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 |