Class EdgeLabelQuery

java.lang.Object
org.yakindu.base.xtext.utils.gmf.routing.EdgeLabelQuery

public class EdgeLabelQuery extends Object
Utility class used to compute the position of a label according to its edge move (old points and new points list).
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 modification
      newBendPointList - Bendpoint list after the edge modification
      isEdgeWithObliqueRoutingStyle - status of the edge from which to get the previous position of the bendpoints and from which to get the three labels
      oldLabelOffset - The old offset.
      labelSize - The size of the label
      keyPoint - 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

      public static org.eclipse.draw2d.geometry.Point getSnapBackPosition(Integer keyPoint)
      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 the IFigure to calculate the offset for
      points - the PointList of the edge that contains the label. The label offset is relative to this PointList.
      ref - the Point that is the reference point that the offset is based on.
      Returns:
      a Point which represents a value offset from the ref 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 of LabelHelper.relativeCoordinateFromOffset(org.eclipse.draw2d.IFigure, Point, Point) . See bugzilla 476305 for more detail.
      Parameters:
      points - the PointList of the edge that contains the label. The label offset is relative to this PointList.
      ref - a Point located on the parent which the offset value is relative to.
      offset - a Point which represents a value offset from the ref 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