|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.YLabel y.view.EdgeLabel
public class EdgeLabel
This class represents a label associated with an EdgeRealizer.
EdgeLabel has special label models and positions that are suitable for placing the label along an edge path.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class y.view.YLabel |
---|
YLabel.BoundsProvider, YLabel.Factory, YLabel.Layout, YLabel.Painter, YLabel.SelectionChangeHandler, YLabel.UserDataHandler |
Field Summary | |
---|---|
static byte |
ANYWHERE
Edge label position specifier. |
static byte |
CENTER
Edge label position specifier. |
static byte |
CENTER_RATIO
Edge label position specifier. |
static byte |
CENTER_SLIDER
Edge label model specifier. |
static byte |
CENTERED
Edge label model specifier. |
static byte |
CUSTOM_LABEL_MODEL
Edge label model specifier that signals that a user-defined, custom EdgeLabelModel is used. |
static byte |
DYNAMIC
Edge label position specifier for label models SIDE_SLIDER
and CENTER_SLIDER . |
static byte |
FREE
Edge label model specifier. |
static byte |
HEAD
Edge label position specifier. |
static byte |
HEAD_RATIO
Edge label position specifier. |
static byte |
SCENTR
Edge label position specifier. |
static byte |
SHEAD
Edge label position specifier. |
static byte |
SIDE_SLIDER
Edge label model specifier. |
static byte |
SIX_POS
Edge label model specifier. |
static byte |
STAIL
Edge label position specifier. |
static byte |
TAIL
Edge label position specifier. |
static byte |
TAIL_RATIO
Edge label position specifier. |
static byte |
TCENTR
Edge label position specifier. |
static byte |
THEAD
Edge label position specifier. |
static byte |
THREE_CENTER
Edge label model specifier. |
static byte |
TTAIL
Edge label position specifier. |
static byte |
TWO_POS
Edge label model specifier. |
static byte |
UNDEFINED
|
Fields inherited from interface y.layout.LabelLayoutConstants |
---|
PLACE_ANYWHERE, PLACE_AT_CENTER, PLACE_AT_SOURCE, PLACE_AT_SOURCE_PORT, PLACE_AT_TARGET, PLACE_AT_TARGET_PORT, PLACE_LEFT_OF_EDGE, PLACE_ON_EDGE, PLACE_RIGHT_OF_EDGE, PLACEMENT_ALONG_EDGE_MASK, PLACEMENT_ON_SIDE_OF_EDGE_MASK |
Constructor Summary | |
---|---|
EdgeLabel()
Default is visible label with empty text, model 2-pos |
|
EdgeLabel(java.lang.String str)
Default: CENTERED labeling and visible. |
|
EdgeLabel(java.lang.String st,
byte mode)
Edge Label with positioning model mode. |
Method Summary | |
---|---|
void |
adoptValues(YLabel label)
Adopts the values from the given label. |
static java.util.Vector |
availablePositions(java.lang.Byte model)
Returns the possible edge label position specifiers for the given model. |
void |
bindRealizer(EdgeRealizer r)
Binds the given edge realizer to this label. |
void |
calculateOffset()
Calculates the offset coordinates of this label. |
java.lang.Object |
clone()
Returns a copy of this instance |
java.lang.Object |
getBestModelParameterForBounds(OrientedRectangle bounds)
Returns the best model parameter for this label such that the label's oriented bounds will match the specified bounds
as closely as possible within the label's current label model . |
java.lang.Object |
getBestModelParameterForLocation(double x,
double y)
Returns the best model parameter for this label at the given location. |
java.lang.Object |
getBestModelParameterForOffset(double offsetX,
double offsetY)
Returns the best model parameter for this label with the given offset. |
double |
getDistance()
Returns the distance of the label to the edge. |
Edge |
getEdge()
Returns the Edge this EdgeLabel is associated with. |
static YLabel.Factory |
getFactory()
Retrieves the factory instance that can be used to store different configurations
of pluggable node label behaviors. |
protected Graph2D |
getGraph2D()
Returns that Graph2D instance that owns the Edge this edge is associated with or null
if this label is not associated with an Edge. |
EdgeLabelModel |
getLabelModel()
Returns the edge label model that determines the placement of this label instance. |
java.lang.Object |
getModelParameter()
Returns the current parameter of the edge label model. |
byte[] |
getModelPositions()
Returns the possible positions for the model that is set for this label instance. |
static byte[] |
getModelPositions(byte model)
Returns the possible edge label position specifiers for the given model specifier. |
OrientedRectangle |
getOrientedBox()
Returns the label's oriented bounding box. |
EdgeRealizer |
getOwner()
Returns the realizer that is bound to this edge label. |
byte |
getPosition()
Returns the actual position of the label. |
byte |
getPreferredPlacement()
Deprecated. use getPreferredPlacementDescriptor() instead. |
PreferredPlacementDescriptor |
getPreferredPlacementDescriptor()
Determines a descriptor that holds information about where, on which side of the edge and with which orientation to place the edge label, preferably. |
double |
getRatio()
Returns the source-target distance ratio of the label. |
EdgeRealizer |
getRealizer()
Returns the realizer that is bound to this edge label. |
boolean |
hasFreePositioning()
Determines whether or not this label has free positioning. |
boolean |
hasSliderPositioning()
Determines whether the model is CENTER_SLIDER or SIDE_SLIDER . |
static java.util.Map |
modelToStringMap()
Creates a map that maps the model constants to strings. |
static java.util.Map |
positionToStringMap()
Creates a map that maps the position constants to strings. |
static java.util.Map |
preferredPlacementsToStringMap()
Creates a map that maps the preferred placement constant to strings. |
void |
read(java.io.ObjectInputStream in)
Deprecated. Use the GraphML format instead. |
void |
repaint()
Triggers a repaint of the bounds of this label in all views. |
void |
setConfiguration(java.lang.String name)
Configures this instance to use the configuration specified by the given name. |
void |
setDistance(double _distance)
Sets the distance of the label to the edge. |
void |
setLabelModel(EdgeLabelModel m)
Deprecated. Use setLabelModel(y.layout.EdgeLabelModel, Object) instead. |
void |
setLabelModel(EdgeLabelModel m,
java.lang.Object p)
Sets the edgeLabelModel implementation and a suitable
model parameter. |
void |
setModel(byte mo)
Sets the placement model for this label. |
void |
setModelParameter(java.lang.Object param)
Sets the current parameter for the edge label model. |
void |
setOffset(double x,
double y)
Deprecated. Client code should not set a label's offset directly, but rather use getBestModelParameterForBounds(y.geom.OrientedRectangle) and
setModelParameter(Object) to create and specify a parameter that
represents the desired label position in the label's model. |
void |
setOffsetDirty()
Marks the label offsets as dirty. |
void |
setPosition(byte p)
Determines which position the label should have in relation to the node. |
void |
setPreferredPlacement(byte placement)
Deprecated. use setPreferredPlacementDescriptor(y.layout.PreferredPlacementDescriptor) instead. |
void |
setPreferredPlacementDescriptor(PreferredPlacementDescriptor descriptor)
Specifies a descriptor that holds information about where, on which side of the edge, and with which orientation to place edge label, preferably. |
void |
setRatio(double rat)
Sets the source-target distance ratio of the label. |
void |
setSizeDirty()
Marks the size of the label as dirty |
void |
setText(java.lang.String text)
Sets the text of this edge label. |
void |
write(java.io.ObjectOutputStream out)
Deprecated. Use the GraphML format instead. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface y.layout.LabelLayout |
---|
getBox |
Field Detail |
---|
public static final byte HEAD
public static final byte TAIL
public static final byte CENTER
public static final byte SHEAD
public static final byte THEAD
public static final byte STAIL
public static final byte TTAIL
public static final byte SCENTR
public static final byte TCENTR
public static final byte ANYWHERE
public static final byte CENTER_RATIO
public static final byte TAIL_RATIO
public static final byte HEAD_RATIO
public static final byte DYNAMIC
SIDE_SLIDER
and CENTER_SLIDER
.
Places the label dynamically.
public static final byte UNDEFINED
public static final byte TWO_POS
HEAD
and TAIL
.
setModel(byte)
,
Constant Field Valuespublic static final byte CENTERED
CENTER
.
setModel(byte)
,
Constant Field Valuespublic static final byte SIX_POS
HEAD
, SHEAD
, THEAD
,
TAIL
, STAIL
and TTAIL
.
setModel(byte)
,
Constant Field Valuespublic static final byte THREE_CENTER
CENTER
, SCENTR
and TCENTR
.
setModel(byte)
,
Constant Field Valuespublic static final byte FREE
ANYWHERE
.
setModel(byte)
,
Constant Field Valuespublic static final byte CENTER_SLIDER
DYNAMIC
.
setModel(byte)
,
Constant Field Valuespublic static final byte SIDE_SLIDER
DYNAMIC
.
setModel(byte)
,
Constant Field Valuespublic static final byte CUSTOM_LABEL_MODEL
EdgeLabelModel
is used.
This specifier should not be used directly, rather a custom
NodeLabelModel
should be set using
setLabelModel(y.layout.EdgeLabelModel,java.lang.Object)
.
Note:
When copying/cloning an edge label (via adoptValues(YLabel)
),
custom label models are copied by reference. I.e. the original/prototype
label instance and the copied label instance will share the custom model
instance.
Constructor Detail |
---|
public EdgeLabel(java.lang.String st, byte mode)
public EdgeLabel(java.lang.String str)
public EdgeLabel()
Method Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public void adoptValues(YLabel label)
adoptValues
in class YLabel
public void calculateOffset()
calculateOffset
in class YLabel
public void setText(java.lang.String text)
setText
in class YLabel
public void setDistance(double _distance)
DiscreteEdgeLabelModel
,RotatedDiscreteEdgeLabelModel
,RotatedSliderEdgeLabelModel
,SliderEdgeLabelModel
, orAutoRotationSliderEdgeLabelModel
setDistance
(or in the case of SliderEdgeLabelModel
the setDistances
) method with the given
distance
value. All other types of label models (including
SmartEdgeLabelModel
) are ignored.
public void setOffset(double x, double y)
getBestModelParameterForBounds(y.geom.OrientedRectangle)
and
setModelParameter(Object)
to create and specify a parameter that
represents the desired label position in the label's model.
source intersection point of
the label's edge
.
Invoking this method is equivalent to calling
setOffset(new OrientedRectangle(x, y + height, width, height));
setOffset
in class YLabel
x
- the x-offset of the upper left corner of a paraxial rectangle
relative to the x-coordinate of the
source intersection point of
the label's edge
.y
- the y-offset of the upper left corner of a paraxial rectangle
relative to the y-coordinate of the
source intersection point of
the label's edge
.public double getDistance()
public void setPreferredPlacement(byte placement)
setPreferredPlacementDescriptor(y.layout.PreferredPlacementDescriptor)
instead.
Defaults to LabelLayoutConstants.PLACE_ANYWHERE
.
Note: Invoking this method will replace the edge label's
preferred placement descriptor
with an immutable
descriptor instance
corresponding
to the specified placement mask
.
placement
- an ORed combination of
LabelLayoutConstants.PLACE_ANYWHERE
, LabelLayoutConstants.PLACE_AT_SOURCE
,
LabelLayoutConstants.PLACE_AT_TARGET
, LabelLayoutConstants.PLACE_AT_SOURCE_PORT
,
LabelLayoutConstants.PLACE_AT_TARGET_PORT
or LabelLayoutConstants.PLACE_AT_CENTER
and
LabelLayoutConstants.PLACE_LEFT_OF_EDGE
, LabelLayoutConstants.PLACE_RIGHT_OF_EDGE
, or
LabelLayoutConstants.PLACE_ON_EDGE
.setPreferredPlacement(byte)
public byte getPreferredPlacement()
getPreferredPlacementDescriptor()
instead.
Defaults to LabelLayoutConstants.PLACE_ANYWHERE
.
LabelLayoutConstants.PLACE_ANYWHERE
, LabelLayoutConstants.PLACE_AT_SOURCE
,
LabelLayoutConstants.PLACE_AT_TARGET
, LabelLayoutConstants.PLACE_AT_SOURCE_PORT
,
LabelLayoutConstants.PLACE_AT_TARGET_PORT
or LabelLayoutConstants.PLACE_AT_CENTER
and
LabelLayoutConstants.PLACE_LEFT_OF_EDGE
, LabelLayoutConstants.PLACE_RIGHT_OF_EDGE
, or
LabelLayoutConstants.PLACE_ON_EDGE
.setPreferredPlacement(byte)
public PreferredPlacementDescriptor getPreferredPlacementDescriptor()
Note: The default descriptor is
immutable
.
Moreover, a cloned
label shares the original label's
descriptor instance. (Most notably, labels are cloned when
copying
an
EdgeRealizer
instance with labels.)
Therefore client code should set a new descriptor instance to adjust
preferred placement of edge labels.
getPreferredPlacementDescriptor
in interface EdgeLabelLayout
setPreferredPlacementDescriptor(y.layout.PreferredPlacementDescriptor)
public void setPreferredPlacementDescriptor(PreferredPlacementDescriptor descriptor)
descriptor
- the new preferred placement descriptor.
java.lang.IllegalArgumentException
- if the specified descriptor is
null
.getPreferredPlacementDescriptor()
public double getRatio()
setRatio(double)
public void setRatio(double rat)
getRatio()
public java.lang.Object getBestModelParameterForBounds(OrientedRectangle bounds)
oriented bounds
will match the specified bounds
as closely as possible within the label's current label model
.
This method will return null
if no suitable parameter can be
determined (e.g. if this label is not associated to a "live" edge).
getBestModelParameterForBounds
in class YLabel
bounds
- the desired label bounds in absolute world coordinates.
null
if no suitable model parameter could
be determined.public java.lang.Object getBestModelParameterForOffset(double offsetX, double offsetY)
offsetX
- the offset in x-direction from the source intersection point
of this label's associated edge to the desired label bounds.offsetY
- the offset in y-direction from the source intersection point
of this label's associated edge to the desired label bounds.
public java.lang.Object getBestModelParameterForLocation(double x, double y)
x
- the x-coordinate of the upper left corner of the desired label
bounds.y
- the y-coordinate of the upper left corner of the desired label
bounds.
public boolean hasFreePositioning()
label.setModelParameter(label.getBestModelParameterForBounds(newBounds));
with an OrientedRectangle
newBounds
that specifies the desired position (and orientation) for the label.
public boolean hasSliderPositioning()
CENTER_SLIDER
or SIDE_SLIDER
.
public void setModel(byte mo)
Note:
Client code should not use CUSTOM_LABEL_MODEL
here.
Custom edge label models should be set using
setLabelModel(y.layout.EdgeLabelModel,java.lang.Object)
.
setModel
in class YLabel
mo
- one of
public byte getPosition()
getPosition
in class YLabel
public void setPosition(byte p)
setPosition
in class YLabel
public static java.util.Map modelToStringMap()
public static java.util.Map positionToStringMap()
public static java.util.Map preferredPlacementsToStringMap()
public static final byte[] getModelPositions(byte model)
model
- An edge label model specifier.
public byte[] getModelPositions()
public static java.util.Vector availablePositions(java.lang.Byte model)
model
- A Byte whose byte value represents a valid edge label model specifier.public Edge getEdge()
protected Graph2D getGraph2D()
null
if this label is not associated with an Edge.
public EdgeRealizer getRealizer()
getOwner()
.
EdgeRealizer.addLabel(EdgeLabel)
,
bindRealizer(EdgeRealizer)
public EdgeRealizer getOwner()
EdgeRealizer.addLabel(EdgeLabel)
,
bindRealizer(EdgeRealizer)
public void bindRealizer(EdgeRealizer r)
r
- the realizer to which this label will be associated.public EdgeLabelModel getLabelModel()
getLabelModel
in interface EdgeLabelLayout
EdgeLabelModel
associated with this EdgeLabelLayout
public java.lang.Object getModelParameter()
getModelParameter
in interface LabelLayout
LabelLayout.setModelParameter(Object)
public void setModelParameter(java.lang.Object param)
setModelParameter
in interface LabelLayout
setModelParameter
in class YLabel
param
- the model parameter that determines the placement of this
label instance.public void setLabelModel(EdgeLabelModel m)
setLabelModel(y.layout.EdgeLabelModel, Object)
instead.
public void setLabelModel(EdgeLabelModel m, java.lang.Object p)
edgeLabelModel
implementation and a suitable
model parameter.
Additionally, this realizer's model
property is updated
according to the specified EdgeLabelModel
:
DiscreteEdgeLabelModel
,
the model
property will be set to one of TWO_POS
,
CENTERED
, SIX_POS
, or THREE_CENTER
as
appropriate for the model's candidate mask.FreeEdgeLabelModel
,
the model
property will be set to FREE
.SliderEdgeLabelModel
,
the model
property will be set to CENTER_SLIDER
or
SIDE_SLIDER
as appropriate for the model's mode.
For all other EdgeLabelModel
implementations (including
subclasses of the above mentioned types),
the model
property will be set to CUSTOM_LABEL_MODEL
.
m
- the EdgeLabelModel
implementation to be used.p
- a model parameter suitable for the specified label model.public void setOffsetDirty()
YLabel
setOffsetDirty
in class YLabel
public void setSizeDirty()
YLabel
setSizeDirty
in class YLabel
public OrientedRectangle getOrientedBox()
offset
relative to the
source intersection
point
of the label's associated realizer
.
The oriented box is given in absolute world coordinates.
getOrientedBox
in interface LabelLayout
getOrientedBox
in class YLabel
YLabel.getContentBox()
public void repaint()
repaint
in class YLabel
YLabel.getBox()
,
View.updateView(double, double, double, double)
public void write(java.io.ObjectOutputStream out) throws java.io.IOException
GraphML format
instead.
YLabel
write
in class YLabel
java.io.IOException
public void read(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
GraphML format
instead.
YLabel
YLabel.write(ObjectOutputStream)
method.
read
in class YLabel
java.io.IOException
java.lang.ClassNotFoundException
public void setConfiguration(java.lang.String name)
YLabel
NodeLabel.getFactory()
and getFactory()
respectively.
setConfiguration
in class YLabel
name
- the name of the configuration as it has been specified in YLabel.Factory.addConfiguration(String, java.util.Map)
YLabel.Factory
,
YLabel.Factory.addConfiguration(String, java.util.Map)
public static YLabel.Factory getFactory()
configurations
of pluggable node label behaviors.
YLabel.Factory.addConfiguration(String, java.util.Map)
,
setConfiguration(String)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |