Package org.eclipse.graphiti.ui.internal.figures

# 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

Constructors
Constructor
Description
`FlexibleRotatableLocator(org.eclipse.draw2d.Connection connection, boolean distanceToStart, double relativeDistance, int absoluteDistance, double rotateDegrees)`
Creates a new FlexibleRotabableLocator.

## Method Summary

Modifier and Type
Method
Description
`protected org.eclipse.graphiti.ui.internal.figures.FlexibleRotatableLocator.CalculationResult`
`calculateLocation()`
Calculates the location based on the current distance values and the connection.
`final int`
`getAbsoluteDistance()`
Returns the absolute distance of the location to the start/end-point.
`protected final org.eclipse.draw2d.Connection`
`getConnection()`
Returns the connection, on which this Locator places the location.
`final boolean`
`getDistanceToStart()`
Returns true, if the distance values (see `getRelativeDistance()` and `getAbsoluteDistance()`) refer to the start point of the connection.
`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.
`final double`
`getRelativeDistance()`
Returns the relative distance of the location to the start/end-point.
`final double`
`getRotateDegrees()`
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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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 in `getConnection()`.
  `distanceToStart` - If the distance values refer to the start-point or the end-point. See `getDistanceToStart()`.
  `relativeDistance` - The relative distance, as described in `getRelativeDistance()`.
  `absoluteDistance` - The absolute distance, as described in `getAbsoluteDistance()`.
  `rotateDegrees` - The degrees to rotate, as described in `getRotateDegrees()`.

## 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 (see `getRelativeDistance()` and `getAbsoluteDistance()`) 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 see `getDistanceToStart()`.

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:
  - `getAbsoluteDistance()`
  - `getDistanceToStart()`

### setRelativeDistance

public final void setRelativeDistance(double relativeDistance)
Sets the relative distance of the location to the start/end-point. For details see `getRelativeDistance()`.

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:
  - `getRelativeDistance()`
  - `getDistanceToStart()`

### setAbsoluteDistance

public final void setAbsoluteDistance(int absoluteDistance)
Sets the absolute distance of the location to the start/end-point. For details see `getAbsoluteDistance()`.

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 see `getRotateDegrees()`.

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 class `org.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 interface `org.eclipse.draw2d.Locator`
Overrides:
  `relocate` in class `org.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)