Class FlexibleRotatableLocator
java.lang.Object
org.eclipse.draw2d.AbstractLocator
org.eclipse.graphiti.ui.internal.figures.FlexibleRotatableLocator
- All Implemented Interfaces:
org.eclipse.draw2d.Locator
public class FlexibleRotatableLocator
extends org.eclipse.draw2d.AbstractLocator
This is a very flexible Locator, which places a
RotatableDecoration
or a non-rotatable IFigure on a Connection
. The location is
determined using a relative distance on the connection (e.g. "0.5" is the
middle of the connection) and/or using an absolute distance on the connection
(e.g. "100" is 100 pixel from the anchor).-
Constructor Summary
ConstructorDescriptionFlexibleRotatableLocator
(org.eclipse.draw2d.Connection connection, boolean distanceToStart, double relativeDistance, int absoluteDistance, double rotateDegrees) Creates a new FlexibleRotabableLocator. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.graphiti.ui.internal.figures.FlexibleRotatableLocator.CalculationResult
Calculates the location based on the current distance values and the connection.final int
Returns the absolute distance of the location to the start/end-point.protected final org.eclipse.draw2d.Connection
Returns the connection, on which this Locator places the location.final boolean
Returns true, if the distance values (seegetRelativeDistance()
andgetAbsoluteDistance()
) refer to the start point of the connection.protected org.eclipse.draw2d.geometry.Point
Returns the location on the connection, which is calculated based on the current distance values and the connection.final double
Returns the relative distance of the location to the start/end-point.final double
Returns the degrees, around which the figure shall be rotated, if it is a RotatableDecoration.void
relocate
(org.eclipse.draw2d.IFigure target) Rotates the figure, if it is a RotatableDecoration.protected void
rotatePoint
(org.eclipse.draw2d.geometry.Point center, org.eclipse.draw2d.geometry.Point rotate, double degrees) final void
setAbsoluteDistance
(int absoluteDistance) Sets the absolute distance of the location to the start/end-point.final void
setDistanceToStart
(boolean distanceToStart) Sets, If the distance values refer to the start-point or the end-point.final void
setRelativeDistance
(double relativeDistance) Sets the relative distance of the location to the start/end-point.final void
setRotateDegrees
(double rotateDegrees) Sets the degrees, around which the figure shall be rotated, if it is a RotatableDecoration.Methods inherited from class org.eclipse.draw2d.AbstractLocator
getGap, getNewBounds, getRelativePosition, setGap, setRelativePosition
-
Constructor Details
-
FlexibleRotatableLocator
public FlexibleRotatableLocator(org.eclipse.draw2d.Connection connection, boolean distanceToStart, double relativeDistance, int absoluteDistance, double rotateDegrees) Creates a new FlexibleRotabableLocator.- Parameters:
connection
- The connection, as described ingetConnection()
.distanceToStart
- If the distance values refer to the start-point or the end-point. SeegetDistanceToStart()
.relativeDistance
- The relative distance, as described ingetRelativeDistance()
.absoluteDistance
- The absolute distance, as described ingetAbsoluteDistance()
.rotateDegrees
- The degrees to rotate, as described ingetRotateDegrees()
.
-
-
Method Details
-
getConnection
protected final org.eclipse.draw2d.Connection getConnection()Returns the connection, on which this Locator places the location.- Returns:
- The connection, on which this Locator places the location.
-
getDistanceToStart
public final boolean getDistanceToStart()Returns true, if the distance values (seegetRelativeDistance()
andgetAbsoluteDistance()
) refer to the start point of the connection. Returns false, if the distance values refer to the end point of the connection. For example if a relative and absolute distance are "0", then returning true will place the location on the start point and returning false on the end point.- Returns:
- If the distance values refer to the start-point or the end-point.
-
setDistanceToStart
public final void setDistanceToStart(boolean distanceToStart) Sets, If the distance values refer to the start-point or the end-point. For details seegetDistanceToStart()
.- Parameters:
distanceToStart
- If true, the distance values refer to the start-point.
-
getRelativeDistance
public final double getRelativeDistance()Returns the relative distance of the location to the start/end-point. The total distance is calculated by ([relative distance] * [length of connection] + [absolute distance]).- Returns:
- The relative distance of the location to the start/end-point.
- See Also:
-
setRelativeDistance
public final void setRelativeDistance(double relativeDistance) Sets the relative distance of the location to the start/end-point. For details seegetRelativeDistance()
.- Parameters:
relativeDistance
- The relative distance of the location to the start/end-point.
-
getAbsoluteDistance
public final int getAbsoluteDistance()Returns the absolute distance of the location to the start/end-point. The total distance is calculated by ([relative distance] * [length of connection] + [absolute distance]).- Returns:
- The absolute distance of the location to the start/end-point.
- See Also:
-
setAbsoluteDistance
public final void setAbsoluteDistance(int absoluteDistance) Sets the absolute distance of the location to the start/end-point. For details seegetAbsoluteDistance()
.- Parameters:
absoluteDistance
- The absolute distance of the location to the start/end-point.
-
getRotateDegrees
public final double getRotateDegrees()Returns the degrees, around which the figure shall be rotated, if it is a RotatableDecoration. This rotation around a fixed value is done additionally to the dynamic rotation depending on the connection.- Returns:
- The degrees, around which the figure shall be rotated, if it is a RotatableDecoration.
-
setRotateDegrees
public final void setRotateDegrees(double rotateDegrees) Sets the degrees, around which the figure shall be rotated, if it is a RotatableDecoration. For details seegetRotateDegrees()
.- Parameters:
rotateDegrees
- The degrees, around which the figure shall be rotated, if it is a RotatableDecoration.
-
calculateLocation
protected org.eclipse.graphiti.ui.internal.figures.FlexibleRotatableLocator.CalculationResult calculateLocation()Calculates the location based on the current distance values and the connection.- Returns:
- The location based on the current distance values and the connection.
-
getReferencePoint
protected org.eclipse.draw2d.geometry.Point getReferencePoint()Returns the location on the connection, which is calculated based on the current distance values and the connection.- Specified by:
getReferencePoint
in classorg.eclipse.draw2d.AbstractLocator
- Returns:
- The location on the connection.
-
relocate
public void relocate(org.eclipse.draw2d.IFigure target) Rotates the figure, if it is a RotatableDecoration.- Specified by:
relocate
in interfaceorg.eclipse.draw2d.Locator
- Overrides:
relocate
in classorg.eclipse.draw2d.AbstractLocator
- Parameters:
target
- The figure to rotate.
-
rotatePoint
protected void rotatePoint(org.eclipse.draw2d.geometry.Point center, org.eclipse.draw2d.geometry.Point rotate, double degrees)
-