|
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.NodeLabel
public class NodeLabel
This class represents a label associated with a NodeRealizer.
NodeLabel has special label models and positions that are suitable for placing the label relative to a node.
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
Node label position specifier for label model FREE . |
static byte |
AUTOSIZE_NODE_HEIGHT
Automatic size calculation policy specifier. |
static byte |
AUTOSIZE_NODE_SIZE
Automatic size calculation policy specifier. |
static byte |
AUTOSIZE_NODE_WIDTH
Automatic size calculation policy specifier. |
static byte |
BOTTOM
Node label position specifier for label model INTERNAL . |
static byte |
BOTTOM_LEFT
Node label position specifier for label model INTERNAL . |
static byte |
BOTTOM_RIGHT
Node label position specifier for label model INTERNAL . |
static byte |
CENTER
Node label position specifier for label model INTERNAL . |
static byte |
CENTER_X
Deprecated. |
static byte |
CORNERS
Node label model specifier. |
static byte |
CUSTOM_LABEL_MODEL
Node label model specifier that signals that a user-defined, custom NodeLabelModel is used. |
static byte |
DYNAMIC
Node label position specifier for label model EDGE_OPPOSITE . |
static byte |
E
Node label position specifier for label model SIDES and
EIGHT_POS . |
static byte |
EDGE_OPPOSITE
Node label model specifier. |
static byte |
EIGHT_POS
Node label model specifier. |
static byte |
FREE
Node label model specifier. |
static byte |
INTERNAL
Node label model specifier. |
static byte |
LEFT
Node label position specifier for label model INTERNAL . |
static byte |
N
Node label position specifier for label model SIDES ,
SANDWICH and EIGHT_POS . |
static byte |
NE
Node label position specifier for label model CORNERS and
EIGHT_POS . |
static byte |
NW
Node label position specifier for label model CORNERS and
EIGHT_POS . |
static byte |
RIGHT
Node label position specifier for label model INTERNAL . |
static byte |
S
Node label position specifier for label model SIDES ,
SANDWICH and EIGHT_POS . |
static byte |
SANDWICH
Node label model specifier. |
static byte |
SE
Node label position specifier for label model CORNERS and
EIGHT_POS . |
static byte |
SIDES
Node label model specifier. |
static byte |
SW
Node label position specifier for label model CORNERS and
EIGHT_POS . |
static byte |
TOP
Node label position specifier for label model INTERNAL . |
static byte |
TOP_LEFT
Node label position specifier for label model INTERNAL . |
static byte |
TOP_RIGHT
Node label position specifier for label model INTERNAL . |
static byte |
UNDEFINED
Dummy node label position specifier. |
static byte |
W
Node label position specifier for label model SIDES and
EIGHT_POS . |
Constructor Summary | |
---|---|
NodeLabel()
Instantiates a new NodeLabel. |
|
NodeLabel(java.lang.String str)
Instantiates a new NodeLabel with the given text and centered label position. |
|
NodeLabel(java.lang.String st,
byte mode)
Instantiates a new NodeLabel with a given text and model. |
Method Summary | |
---|---|
void |
adoptValues(YLabel label)
Adopts the values from the given label. |
static java.util.Vector |
availablePositions(java.lang.Byte model)
Returns a vector of all valid positions for the given model The positions are wrapped in Byte objects. |
void |
bindRealizer(NodeRealizer r)
Binds the given node realizer to this label. |
void |
calculateOffset()
Calculates the offset of this label. |
void |
calcUnionRect(java.awt.geom.Rectangle2D r)
Enlarges the given rectangle such that it will contain the bounding box of this label. |
java.lang.Object |
clone()
Creates an unbound copy of this NodeLabel. |
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 . |
double |
getDistance()
Returns the distance of the label to the node. |
static YLabel.Factory |
getFactory()
Retrieves the factory instance that can be used to store different configurations
of pluggable node label behaviors. |
Graph2D |
getGraph2D()
Returns the graph this node label is bound to. |
NodeLabelModel |
getLabelModel()
NodeLabelModel implementation. |
java.lang.Object |
getModelParameter()
Returns the current parameter of the node label model. |
static byte[] |
getModelPositions(byte model)
Returns a byte array containing all valid positions for the given model specifier. |
Node |
getNode()
Returns the node that is bound to this node label |
OrientedRectangle |
getOrientedBox()
Returns the label's oriented bounding box. |
byte |
getPosition()
Returns the position of this label. |
NodeRealizer |
getRealizer()
Returns the node realizer that is bound to this node label. |
boolean |
hasFreePositioning()
Determines whether or not this label has free positioning. |
boolean |
intersects(double x,
double y,
double width,
double height)
Returns true iff the bounding box of this label
intersects with the given box. |
boolean |
isOffsetDirty()
Returns true if the label offset is
not valid yet. |
static java.util.Map |
modelToStringMap()
Returns a map that whose keys are the known label model specifiers wrapped in Byte objects. |
static java.util.Map |
positionToStringMap()
Returns a map that whose keys are the known label position specifiers wrapped in Byte objects. |
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 |
setAutoSizePolicy(byte autoSize)
Sets the automatic size calculation policy for this label. |
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 node. |
void |
setFreeOffset(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 |
setLabelModel(NodeLabelModel m)
Deprecated. Use setLabelModel(y.layout.NodeLabelModel, Object)
instead. |
void |
setLabelModel(NodeLabelModel m,
java.lang.Object p)
Sets the NodeLabelModel implementation and a suitable
model parameter. |
void |
setModel(byte mo)
Sets the label model. |
void |
setModelParameter(java.lang.Object param)
Sets the current parameter for the node 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)
Sets the position of this label. |
void |
setSizeDirty()
Marks the size of the label as dirty |
void |
setText(java.lang.String text)
Sets the text of this node 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 CENTER
INTERNAL
.
Places the label in the center of the node.
public static final byte BOTTOM
INTERNAL
.
Places the label inside the node at the bottom of it.
public static final byte TOP
INTERNAL
.
Places the label inside the node at the top of it.
public static final byte TOP_LEFT
INTERNAL
.
Places the label in the top left corner of a node.
public static final byte TOP_RIGHT
INTERNAL
.
Places the label in the top right corner of a node.
public static final byte BOTTOM_LEFT
INTERNAL
.
Places the label in the bottom left corner of a node.
public static final byte BOTTOM_RIGHT
INTERNAL
.
Places the label in the bottom right corner of a node.
public static final byte LEFT
INTERNAL
.
Places the label inside the node to the left of it.
public static final byte RIGHT
INTERNAL
.
Places the label inside the node at the right of it.
public static final byte CENTER_X
INTERNAL
.
UNCLEAR YET.
public static final byte NW
CORNERS
and
EIGHT_POS
. Places the label north west of the node.
public static final byte NE
CORNERS
and
EIGHT_POS
. Places the label north east of the node.
public static final byte SE
CORNERS
and
EIGHT_POS
. Places the label south east of the node.
public static final byte SW
CORNERS
and
EIGHT_POS
. Places the label south west of the node.
public static final byte N
SIDES
,
SANDWICH
and EIGHT_POS
.
Places the label north of the node.
public static final byte S
SIDES
,
SANDWICH
and EIGHT_POS
.
Places the label south of the node.
public static final byte E
SIDES
and
EIGHT_POS
. Places the label east of the node.
public static final byte W
SIDES
and
EIGHT_POS
. Places the label west of the node.
public static final byte DYNAMIC
EDGE_OPPOSITE
.
Places the label dynamically.
public static final byte ANYWHERE
FREE
.
Places the label at an arbitrary position.
public static final byte UNDEFINED
public static final byte CORNERS
NW
, NE
,
SE
, SW
as valid positions.
setModel(byte)
,
Constant Field Valuespublic static final byte INTERNAL
CENTER
, BOTTOM
, TOP
, LEFT
, RIGHT
,
TOP_LEFT
, TOP_RIGHT
, BOTTOM_LEFT
, and BOTTOM_RIGHT
as valid positions.
setModel(byte)
,
Constant Field Valuespublic static final byte SANDWICH
N
and S
as valid positions.
setModel(byte)
,
Constant Field Valuespublic static final byte SIDES
N
, E
,
S
, W
as valid positions.
setModel(byte)
,
Constant Field Valuespublic static final byte FREE
ANYWHERE
as valid position.
setModel(byte)
,
Constant Field Valuespublic static final byte EIGHT_POS
SIDES
and CORNERS
setModel(byte)
,
Constant Field Valuespublic static final byte EDGE_OPPOSITE
setModel(byte)
,
Constant Field Valuespublic static final byte CUSTOM_LABEL_MODEL
NodeLabelModel
is used.
This specifier should not be used directly, rather a custom
NodeLabelModel
should be set using
setLabelModel(y.layout.NodeLabelModel,java.lang.Object)
.
Note:
When copying/cloning a node 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.
public static final byte AUTOSIZE_NODE_WIDTH
public static final byte AUTOSIZE_NODE_SIZE
public static final byte AUTOSIZE_NODE_HEIGHT
Constructor Detail |
---|
public NodeLabel(java.lang.String st, byte mode)
public NodeLabel(java.lang.String str)
public NodeLabel()
Method Detail |
---|
public void setAutoSizePolicy(byte autoSize)
YLabel.AUTOSIZE_CONTENT
is set.
setAutoSizePolicy
in class YLabel
autoSize
- one of the specifiers YLabel.AUTOSIZE_CONTENT
, AUTOSIZE_NODE_WIDTH
, AUTOSIZE_NODE_SIZE
, YLabel.AUTOSIZE_NONE
or
AUTOSIZE_NODE_HEIGHT
.public void setConfiguration(java.lang.String name)
YLabel
getFactory()
and EdgeLabel.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)
public java.lang.Object clone()
clone
in class java.lang.Object
public void adoptValues(YLabel label)
adoptValues
in class YLabel
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.
NodeRealizer.getX()
and NodeRealizer.getY()
.
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 NodeRealizer.getX()
.y
- the y-offset of the upper left corner of a paraxial rectangle
relative to NodeRealizer.getY()
.public void setOffsetDirty()
YLabel
setOffsetDirty
in class YLabel
public void setSizeDirty()
YLabel
setSizeDirty
in class YLabel
public void setText(java.lang.String text)
setText
in class YLabel
public void setDistance(double _distance)
DiscreteNodeLabelModel
this method calls the model's setDistance
method with the
given distance
value. All other types of label models
(including SmartNodeLabelModel
) are ignored.
public double getDistance()
public NodeLabelModel getLabelModel()
getLabelModel
in interface NodeLabelLayout
NodeLabelModel
associated with this NodeLabelLayout
public void setLabelModel(NodeLabelModel m)
setLabelModel(y.layout.NodeLabelModel, Object)
instead.
NodeLabelModel
implementation.
Additionally, this realizer's model
property is updated
according to the specified NodeLabelModel
:
DiscreteNodeLabelModel
,
the model
property will be set to one of CORNERS
,
INTERNAL
, SANDWICH
, or EIGHT_POS
as appropriate
for the model's candidate mask.FreeNodeLabelModel
,
the model
property will be set to FREE
.EdgeOppositeNodeLabelModel
,
the model
property will be set to EIGHT_POS
.
For all other NodeLabelModel
implementations (including
subclasses of the above mentioned types),
the model
property will be set to CUSTOM_LABEL_MODEL
.
m
- the NodeLabelModel
implementation to be used.public void setLabelModel(NodeLabelModel m, java.lang.Object p)
NodeLabelModel
implementation and a suitable
model parameter.
Additionally, this realizer's model
property is updated
according to the specified NodeLabelModel
:
DiscreteNodeLabelModel
,
the model
property will be set to one of CORNERS
,
INTERNAL
, SANDWICH
, or EIGHT_POS
as appropriate
for the model's candidate mask.FreeNodeLabelModel
,
the model
property will be set to FREE
.EdgeOppositeNodeLabelModel
,
the model
property will be set to EIGHT_POS
.
For all other NodeLabelModel
implementations (including
subclasses of the above mentioned types),
the model
property will be set to CUSTOM_LABEL_MODEL
.
m
- the NodeLabelModel
implementation to be used.p
- a model parameter suitable for the specified label model.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 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 bound to a realizer).
getBestModelParameterForBounds
in class YLabel
bounds
- the desired label bounds in absolute world coordinates.
null
if no suitable model parameter could
be determined.public void setModel(byte mo)
Note:
Client code should not use CUSTOM_LABEL_MODEL
here.
Custom node label models should be set using
setLabelModel(y.layout.NodeLabelModel,java.lang.Object)
.
setModel
in class YLabel
public boolean hasFreePositioning()
label.setModelParameter(label.getBestModelParameterForBounds(newBounds));
with an OrientedRectangle
newBounds
that specifies the desired position (and orientation) for the label.
public void setPosition(byte p)
setPosition
in class YLabel
public byte getPosition()
getPosition
in class YLabel
public void setFreeOffset(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.
FREE
.
x
- the x-offset relative to NodeRealizer.getX()
.y
- the y-offset relative to NodeRealizer.getY()
.public static java.util.Map modelToStringMap()
public static java.util.Map positionToStringMap()
public static byte[] getModelPositions(byte model)
public static java.util.Vector availablePositions(java.lang.Byte model)
public boolean isOffsetDirty()
true
if the label offset is
not valid yet.
isOffsetDirty
in class YLabel
public void calculateOffset()
YLabel
calculateOffset
in class YLabel
public Node getNode()
public NodeRealizer getRealizer()
NodeRealizer.addLabel(NodeLabel)
,
bindRealizer(NodeRealizer)
public Graph2D getGraph2D()
public void bindRealizer(NodeRealizer r)
r
- the realizer to which this label will be associated.public OrientedRectangle getOrientedBox()
offset
relative to the
location 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 boolean intersects(double x, double y, double width, double height)
YLabel
true
iff the bounding box of this label
intersects with the given box.
intersects
in class YLabel
public void calcUnionRect(java.awt.geom.Rectangle2D r)
YLabel
YLabel.BoundsProvider
instance
registered with this instance's configuration
.
calcUnionRect
in class YLabel
public void write(java.io.ObjectOutputStream out) throws java.io.IOException
GraphML format
instead.
write
in class YLabel
java.io.IOException
public void read(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
GraphML format
instead.
write(ObjectOutputStream)
method.
read
in class YLabel
java.io.IOException
java.lang.ClassNotFoundException
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |