Class EdgeLabelQuery
java.lang.Object
org.yakindu.base.xtext.utils.gmf.routing.EdgeLabelQuery
Utility class used to compute the position of a label according to its edge
move (old points and new points list).
-
Constructor Summary
ConstructorDescriptionEdgeLabelQuery
(org.eclipse.draw2d.geometry.PointList oldBendPointList, org.eclipse.draw2d.geometry.PointList newBendPointList, boolean isEdgeWithObliqueRoutingStyle, org.eclipse.draw2d.geometry.Point oldLabelOffset, org.eclipse.draw2d.geometry.Dimension labelSize, Integer keyPoint, boolean isOnBracketEdge) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.draw2d.geometry.Point
Calculate the new GMF label offset: the label offset defines the position of the label compared to labelAnchor point.static org.eclipse.draw2d.geometry.Point
getSnapBackPosition
(Integer keyPoint) Return the default snap back position according to the keyPoint of the label.static org.eclipse.draw2d.geometry.Point
offsetFromRelativeCoordinate
(org.eclipse.draw2d.geometry.Point labelCenter, org.eclipse.draw2d.geometry.PointList points, org.eclipse.draw2d.geometry.Point ref) Calculates the label offset from the reference point given the label center and a points list.
LabelHelper.offsetFromRelativeCoordinate(org.eclipse.draw2d.IFigure, org.eclipse.draw2d.geometry.Rectangle, Point)
static org.eclipse.draw2d.geometry.Point
relativeCenterCoordinateFromOffset
(org.eclipse.draw2d.geometry.PointList points, org.eclipse.draw2d.geometry.Point ref, org.eclipse.draw2d.geometry.Point offset) Calculates the relative coordinate that is equivalent to the offset from the reference point, that can be used to set the label center location.
-
Constructor Details
-
EdgeLabelQuery
public EdgeLabelQuery(org.eclipse.draw2d.geometry.PointList oldBendPointList, org.eclipse.draw2d.geometry.PointList newBendPointList, boolean isEdgeWithObliqueRoutingStyle, org.eclipse.draw2d.geometry.Point oldLabelOffset, org.eclipse.draw2d.geometry.Dimension labelSize, Integer keyPoint, boolean isOnBracketEdge) Default constructor.- Parameters:
oldBendPointList
- Bendpoint list before the edge modificationnewBendPointList
- Bendpoint list after the edge modificationisEdgeWithObliqueRoutingStyle
- status of the edge from which to get the previous position of the bendpoints and from which to get the three labelsoldLabelOffset
- The old offset.labelSize
- The size of the labelkeyPoint
- The keyPoint of the label (LabelEditPart.getKeyPoint()
)isOnBracketEdge
- True if the parent's label is a bracketEdge (specific locator for center label and possibility to rotate the middle segment), false otherwise.
-
-
Method Details
-
getSnapBackPosition
Return the default snap back position according to the keyPoint of the label.- Parameters:
keyPoint
- The keyPoint of the label (LabelEditPart.getKeyPoint()
).- Returns:
- the default snap back position according to the keyPoint.
-
offsetFromRelativeCoordinate
public static org.eclipse.draw2d.geometry.Point offsetFromRelativeCoordinate(org.eclipse.draw2d.geometry.Point labelCenter, org.eclipse.draw2d.geometry.PointList points, org.eclipse.draw2d.geometry.Point ref) Calculates the label offset from the reference point given the label center and a points list.
LabelHelper.offsetFromRelativeCoordinate(org.eclipse.draw2d.IFigure, org.eclipse.draw2d.geometry.Rectangle, Point)
- Parameters:
labelCenter
- the label center for theIFigure
to calculate the offset forpoints
- thePointList
of the edge that contains the label. The label offset is relative to thisPointList
.ref
- thePoint
that is the reference point that the offset is based on.- Returns:
- a
Point
which represents a value offset from theref
point oriented based on the nearest line segment.
-
relativeCenterCoordinateFromOffset
public static org.eclipse.draw2d.geometry.Point relativeCenterCoordinateFromOffset(org.eclipse.draw2d.geometry.PointList points, org.eclipse.draw2d.geometry.Point ref, org.eclipse.draw2d.geometry.Point offset) Calculates the relative coordinate that is equivalent to the offset from the reference point, that can be used to set the label center location.
This is another implementation ofLabelHelper.relativeCoordinateFromOffset(org.eclipse.draw2d.IFigure, Point, Point)
. See bugzilla 476305 for more detail.- Parameters:
points
- thePointList
of the edge that contains the label. The label offset is relative to thisPointList
.ref
- aPoint
located on the parent which the offset value is relative to.offset
- aPoint
which represents a value offset from theref
point oriented based on the nearest line segment.- Returns:
- a
Point
that is the relative coordinate of the label that can be used to set it's center location.
-
calculateGMFLabelOffset
public org.eclipse.draw2d.geometry.Point calculateGMFLabelOffset()Calculate the new GMF label offset: the label offset defines the position of the label compared to labelAnchor point.
The new Label offset is computed taking into account:
- the label anchor point move (start, center or end)
- the orientation of the segment owning the label anchor. Indeed, the label offset is displayed by draw2D relatively to the direction of the edge segment including the anchor of the label
- the expected move of the label according to the functional specification
- Returns:
- the new offset of the label
-