|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.SmartNodeLabelModel
public class SmartNodeLabelModel
A node label model that allows free placement of labels and provides smart dynamic behavior. Labels using this model are anchored to a specific point in their associated nodes. In other words, labels will usually retain the relative position with respect to the bounds of their associated node when the node is resized. E.g. a label anchored to the lower right corner of a node will stay in the lower right when the node is resized.
Field Summary | |
---|---|
static int |
ALIGNMENT_BOTTOM
Symbolic anchor specifier. |
static int |
ALIGNMENT_BOTTOM_LEFT
Symbolic anchor specifier. |
static int |
ALIGNMENT_BOTTOM_RIGHT
Symbolic anchor specifier. |
static int |
ALIGNMENT_LEFT
Symbolic anchor specifier. |
static int |
ALIGNMENT_RIGHT
Symbolic anchor specifier. |
static int |
ALIGNMENT_TOP
Symbolic anchor specifier. |
static int |
ALIGNMENT_TOP_LEFT
Symbolic anchor specifier. |
static int |
ALIGNMENT_TOP_RIGHT
Symbolic anchor specifier. |
static int |
POSITION_BOTTOM
Symbolic position specifier. |
static int |
POSITION_BOTTOM_LEFT
Symbolic position specifier. |
static int |
POSITION_BOTTOM_RIGHT
Symbolic position specifier. |
static int |
POSITION_CENTER
Symbolic position specifier. |
static int |
POSITION_EAST
Symbolic position specifier. |
static int |
POSITION_LEFT
Symbolic position specifier. |
static int |
POSITION_NORTH
Symbolic position specifier. |
static int |
POSITION_NORTH_EAST
Symbolic position specifier. |
static int |
POSITION_NORTH_WEST
Symbolic position specifier. |
static int |
POSITION_RIGHT
Symbolic position specifier. |
static int |
POSITION_SOUTH
Symbolic position specifier. |
static int |
POSITION_SOUTH_EAST
Symbolic position specifier. |
static int |
POSITION_SOUTH_WEST
Symbolic position specifier. |
static int |
POSITION_TOP
Symbolic position specifier. |
static int |
POSITION_TOP_LEFT
Symbolic position specifier. |
static int |
POSITION_TOP_RIGHT
Symbolic position specifier. |
static int |
POSITION_WEST
Symbolic position specifier. |
Constructor Summary | |
---|---|
SmartNodeLabelModel()
Returns a new instance of SmartNodeLabelModel . |
|
SmartNodeLabelModel(double distance)
Returns a new instance of SmartNodeLabelModel . |
Method Summary | |
---|---|
java.lang.Object |
createAlignedModelParameter(OrientedRectangle labelBox,
NodeLayout nodeLayout,
int alignment)
Creates a model parameter which is aligned to the given sides of the node. |
java.lang.Object |
createDiscreteModelParameter(int position)
Creates a model parameter for a label at a given position. |
java.lang.Object |
createModelParameter(OrientedRectangle labelBounds,
NodeLayout nodeLayout)
Creates a model parameter for a free positioned label. |
java.lang.Object |
createSpecificModelParameter(double nodeRatioX,
double nodeRatioY,
double labelRatioX,
double labelRatioY,
double offsetX,
double offsetY,
double upX,
double upY)
Creates a model parameter where all values are specified manually. |
java.lang.Object |
getDefaultParameter()
Returns a model parameter that encodes the default position in the center of the node. |
double |
getDistance()
Returns the distance between the bounding boxes of label and node. |
YList |
getLabelCandidates(NodeLabelLayout nl,
NodeLayout nodeLayout)
Returns a list of candidate candidates for the given node label. |
OrientedRectangle |
getLabelPlacement(YDimension labelSize,
NodeLayout nodeLayout,
java.lang.Object param)
Returns the the oriented label position and bounds encoded by the given model parameter. |
void |
setDistance(double distance)
Sets the distance between the bounding boxes of label and node in the manner of an inset. |
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_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 Valuespublic static final int POSITION_TOP
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_TOP_LEFT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_TOP_RIGHT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_BOTTOM
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_BOTTOM_LEFT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_BOTTOM_RIGHT
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_EAST
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_WEST
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_NORTH
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_NORTH_EAST
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_NORTH_WEST
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_SOUTH
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_SOUTH_EAST
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int POSITION_SOUTH_WEST
createDiscreteModelParameter(int)
,
Constant Field Valuespublic static final int ALIGNMENT_TOP
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_BOTTOM
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_LEFT
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_RIGHT
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_TOP_LEFT
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_TOP_RIGHT
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_BOTTOM_LEFT
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field Valuespublic static final int ALIGNMENT_BOTTOM_RIGHT
createAlignedModelParameter(y.geom.OrientedRectangle, y.layout.NodeLayout, int)
,
Constant Field ValuesConstructor Detail |
---|
public SmartNodeLabelModel()
SmartNodeLabelModel
. The distance between label and node is set to 4.0
[pixel].
setDistance(double)
public SmartNodeLabelModel(double distance)
SmartNodeLabelModel
.
distance
- The distance between label and nodesetDistance(double)
Method Detail |
---|
public OrientedRectangle getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, java.lang.Object param)
getLabelPlacement
in interface NodeLabelModel
labelSize
- The size of the labelnodeLayout
- The geometric description of the label's nodeparam
- A model parameter that encodes a label position that is valid in this model
public YList getLabelCandidates(NodeLabelLayout nl, NodeLayout nodeLayout)
DiscreteNodeLabelModel
.
getLabelCandidates
in interface NodeLabelModel
nl
- the label for which candidates should be generatednodeLayout
- the layout of the node to which the label belongs
NodeLabelCandidate
instancespublic java.lang.Object createModelParameter(OrientedRectangle labelBounds, NodeLayout nodeLayout)
createModelParameter
in interface NodeLabelModel
labelBounds
- The bounds of the label for which a parameter representation is sought.nodeLayout
- The layout of the node to which the label belongs.
NodeLabelModel.getLabelPlacement(YDimension, NodeLayout, Object)
public double getDistance()
Note: This value has no influence on how the parameter is interpreted. It only affects the placement of the candidate positions when moving the label.
setDistance(double)
public void setDistance(double distance)
getLabelCandidates(NodeLabelLayout, NodeLayout)
,
except the center position. Note: This setting has no influence on how the parameter is interpreted. It only affects the placement of the candidate positions when moving the label.
distance
- A non-negative valuegetDistance()
public java.lang.Object getDefaultParameter()
getDefaultParameter
in interface NodeLabelModel
public java.lang.Object createSpecificModelParameter(double nodeRatioX, double nodeRatioY, double labelRatioX, double labelRatioY, double offsetX, double offsetY, double upX, double upY)
(0, -1)
is the up-vector of an unrotated
label. When a label is rotated, the ratios and offsets are interpreted in relation to its paraxial bounding box.
nodeRatioX
- The relative position of the anchor point on the node in x-direction. The values -0.5 and 0.5
are at the left and right border of the node and 0 lies in the center.nodeRatioY
- The relative position of the anchor point on the node in y-direction. The values -0.5 and 0.5
are at the top and bottom border of the node and 0 lies in the center.labelRatioX
- The relative position of the anchor point on the label in x-direction. The values -0.5 and 0.5
are at the left and right border of the label and 0 lies in the center.labelRatioY
- The relative position of the anchor point on the label in y-direction. The values -0.5 and 0.5
are at the top and bottom border of the label and 0 lies in the center.offsetX
- The absolute distance between the node anchor point and the label anchor point in x-direction.offsetY
- The absolute distance between the node anchor point and the label anchor point in y-direction.upX
- The x-coordinate of the up-vector of the label boxupY
- The y-coordinate of the up-vector of the label box
public java.lang.Object createDiscreteModelParameter(int position)
position
- one of the following positions:
POSITION_CENTER
,
POSITION_LEFT
,
POSITION_RIGHT
,
POSITION_TOP
,
POSITION_TOP_LEFT
,
POSITION_TOP_RIGHT
,
POSITION_BOTTOM
,
POSITION_BOTTOM_LEFT
,
POSITION_BOTTOM_RIGHT
,
POSITION_WEST
,
POSITION_EAST
,
POSITION_NORTH
,
POSITION_NORTH_WEST
,
POSITION_NORTH_EAST
,
POSITION_SOUTH
,
POSITION_SOUTH_WEST
,
and POSITION_SOUTH_EAST
DiscreteNodeLabelModel.INTERNAL_MASK
public java.lang.Object createAlignedModelParameter(OrientedRectangle labelBox, NodeLayout nodeLayout, int alignment)
createModelParameter(y.geom.OrientedRectangle, NodeLayout)
were called.
labelBox
- the label geometrynodeLayout
- the node geometryalignment
- one of the following alignments:
ALIGNMENT_LEFT
,
ALIGNMENT_RIGHT
,
ALIGNMENT_TOP
,
ALIGNMENT_TOP_LEFT
,
ALIGNMENT_TOP_RIGHT
,
ALIGNMENT_BOTTOM
,
ALIGNMENT_BOTTOM_LEFT
,
and ALIGNMENT_BOTTOM_RIGHT
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |