Module javafx.graphics
Package javafx.animation

# Class RotateTransition

java.lang.Object
javafx.animation.Animation
javafx.animation.Transition
javafx.animation.RotateTransition

public final class RotateTransition extends Transition
This `Transition` creates a rotation animation that spans its `duration`. This is done by updating the `rotate` variable of the `node` at regular interval. The angle value is specified in degrees.

It starts from the `fromAngle` if provided else uses the `node`'s `rotate` value.

It stops at the `toAngle` value if provided else it will use start value plus `byAngle`.

The `toAngle` takes precedence if both `toAngle` and `byAngle` are specified.

Code Segment Example:

     import javafx.scene.shape.*;
     import javafx.animation.*;

     ...

         Rectangle rect = new Rectangle (100, 40, 100, 100);
         rect.setArcHeight(50);
         rect.setArcWidth(50);
         rect.setFill(Color.VIOLET);

         RotateTransition rt = new RotateTransition(Duration.millis(3000), rect);
         rt.setByAngle(180);
         rt.setCycleCount(4);
         rt.setAutoReverse(true);

         rt.play();

     ...

Since:
  JavaFX 2.0
See Also:
  - `Transition`
  - `Animation`

## Property Summary

Properties
Type
Property
Description
`final ObjectProperty<Point3D>`
`axis`
Specifies the axis of rotation for this `RotateTransition`.
`final DoubleProperty`
`byAngle`
Specifies the incremented stop angle value, from the start, of this `RotateTransition`.
`final ObjectProperty<Duration>`
`duration`
The duration of this `RotateTransition`.
`final DoubleProperty`
`fromAngle`
Specifies the start angle value for this `RotateTransition`.
`final ObjectProperty<Node>`
`node`
The target node of this `RotateTransition`.
`final DoubleProperty`
`toAngle`
Specifies the stop angle value for this `RotateTransition`.

### Properties inherited from class javafx.animation.Transition

`interpolator`

### Properties inherited from class javafx.animation.Animation

`autoReverse, currentRate, currentTime, cycleCount, cycleDuration, delay, onFinished, rate, status, totalDuration`

## Nested Class Summary

## Nested classes/interfaces inherited from class javafx.animation.Animation

`Animation.Status`

## Field Summary

### Fields inherited from class javafx.animation.Animation

`INDEFINITE`

## Constructor Summary

Constructors
Constructor
Description
`RotateTransition()`
The constructor of `RotateTransition`
`RotateTransition(Duration duration)`
The constructor of `RotateTransition`
`RotateTransition(Duration duration, Node node)`
The constructor of `RotateTransition`

## Method Summary

Modifier and Type
Method
Description
`final ObjectProperty<Point3D>`
`axisProperty()`
Specifies the axis of rotation for this `RotateTransition`.
`final DoubleProperty`
`byAngleProperty()`
Specifies the incremented stop angle value, from the start, of this `RotateTransition`.
`final ObjectProperty<Duration>`
`durationProperty()`
The duration of this `RotateTransition`.
`final DoubleProperty`
`fromAngleProperty()`
Specifies the start angle value for this `RotateTransition`.
`final Point3D`
`getAxis()`
Gets the value of the `axis` property.
`final double`
`getByAngle()`
Gets the value of the `byAngle` property.
`final Duration`
`getDuration()`
Gets the value of the `duration` property.
`final double`
`getFromAngle()`
Gets the value of the `fromAngle` property.
`final Node`
`getNode()`
Gets the value of the `node` property.
`final double`
`getToAngle()`
Gets the value of the `toAngle` property.
`protected void`
`interpolate(double frac)`
The method `interpolate()` has to be provided by implementations of `Transition`.
`final ObjectProperty<Node>`
`nodeProperty()`
The target node of this `RotateTransition`.
`final void`
`setAxis(Point3D value)`
Sets the value of the `axis` property.
`final void`
`setByAngle(double value)`
Sets the value of the `byAngle` property.
`final void`
`setDuration(Duration value)`
Sets the value of the `duration` property.
`final void`
`setFromAngle(double value)`
Sets the value of the `fromAngle` property.
`final void`
`setNode(Node value)`
Sets the value of the `node` property.
`final void`
`setToAngle(double value)`
Sets the value of the `toAngle` property.
`final DoubleProperty`
`toAngleProperty()`
Specifies the stop angle value for this `RotateTransition`.

### Methods inherited from class javafx.animation.Transition

`getCachedInterpolator, getInterpolator, getParentTargetNode, interpolatorProperty, setInterpolator`

### Methods inherited from class javafx.animation.Animation

`autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, getCuePoints, getCurrentRate, getCurrentTime, getCycleCount, getCycleDuration, getDelay, getOnFinished, getRate, getStatus, getTargetFramerate, getTotalDuration, isAutoReverse, jumpTo, jumpTo, onFinishedProperty, pause, play, playFrom, playFrom, playFromStart, rateProperty, setAutoReverse, setCycleCount, setCycleDuration, setDelay, setOnFinished, setRate, setStatus, statusProperty, stop, totalDurationProperty`

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

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

## Property Details

### node

public final ObjectProperty<Node> nodeProperty
The target node of this `RotateTransition`.

It is not possible to change the target `node` of a running `RotateTransition`. If the value of `node` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

See Also:
  - `getNode()`
  - `setNode(Node)`
  - `nodeProperty()`

### duration

public final ObjectProperty<Duration> durationProperty
The duration of this `RotateTransition`.

It is not possible to change the `duration` of a running `RotateTransition`. If the value of `duration` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Note: While the unit of `duration` is a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms. Setting duration to value lower than `Duration.ZERO` will result in `IllegalArgumentException`.

Default value:
  400ms
See Also:
  - `getDuration()`
  - `setDuration(Duration)`
  - `durationProperty()`

### axis

public final ObjectProperty<Point3D> axisProperty
Specifies the axis of rotation for this `RotateTransition`. Use `node.rotationAxis` for axis of rotation if this `axis` is null.

It is not possible to change the `axis` of a running `RotateTransition`. If the value of `axis` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  null
See Also:
  - `getAxis()`
  - `setAxis(Point3D)`
  - `axisProperty()`

### fromAngle

public final DoubleProperty fromAngleProperty
Specifies the start angle value for this `RotateTransition`.

It is not possible to change `fromAngle` of a running `RotateTransition`. If the value of `fromAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
See Also:
  - `getFromAngle()`
  - `setFromAngle(double)`
  - `fromAngleProperty()`

### toAngle

public final DoubleProperty toAngleProperty
Specifies the stop angle value for this `RotateTransition`.

It is not possible to change `toAngle` of a running `RotateTransition`. If the value of `toAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
See Also:
  - `getToAngle()`
  - `setToAngle(double)`
  - `toAngleProperty()`

### byAngle

public final DoubleProperty byAngleProperty
Specifies the incremented stop angle value, from the start, of this `RotateTransition`.

It is not possible to change `byAngle` of a running `RotateTransition`. If the value of `byAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

See Also:
  - `getByAngle()`
  - `setByAngle(double)`
  - `byAngleProperty()`

## Constructor Details

### RotateTransition

public RotateTransition(Duration duration, Node node)
The constructor of `RotateTransition`

Parameters:
  `duration` - The duration of the `RotateTransition`
  `node` - The `node` which will be rotated

### RotateTransition

public RotateTransition(Duration duration)
The constructor of `RotateTransition`

Parameters:
  `duration` - The duration of the `RotateTransition`

### RotateTransition

public RotateTransition()
The constructor of `RotateTransition`

## Method Details

### setNode

public final void setNode(Node value)
Sets the value of the `node` property.

Property description:
  The target node of this `RotateTransition`.

  It is not possible to change the target `node` of a running `RotateTransition`. If the value of `node` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Parameters:
  `value` - the value for the `node` property
See Also:
  - `getNode()`
  - `nodeProperty()`

### getNode

public final Node getNode()
Gets the value of the `node` property.

Property description:
  The target node of this `RotateTransition`.

  It is not possible to change the target `node` of a running `RotateTransition`. If the value of `node` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Returns:
  the value of the `node` property
See Also:
  - `setNode(Node)`
  - `nodeProperty()`

### nodeProperty

public final ObjectProperty<Node> nodeProperty()
The target node of this `RotateTransition`.

It is not possible to change the target `node` of a running `RotateTransition`. If the value of `node` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Returns:
  the `node` property
See Also:
  - `getNode()`
  - `setNode(Node)`

### setDuration

public final void setDuration(Duration value)
Sets the value of the `duration` property.

Property description:
  The duration of this `RotateTransition`.

  It is not possible to change the `duration` of a running `RotateTransition`. If the value of `duration` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

  Note: While the unit of `duration` is a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms. Setting duration to value lower than `Duration.ZERO` will result in `IllegalArgumentException`.

Default value:
  400ms
Parameters:
  `value` - the value for the `duration` property
See Also:
  - `getDuration()`
  - `durationProperty()`

### getDuration

public final Duration getDuration()
Gets the value of the `duration` property.

Property description:
  The duration of this `RotateTransition`.

  It is not possible to change the `duration` of a running `RotateTransition`. If the value of `duration` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

  Note: While the unit of `duration` is a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms. Setting duration to value lower than `Duration.ZERO` will result in `IllegalArgumentException`.

Default value:
  400ms
Returns:
  the value of the `duration` property
See Also:
  - `setDuration(Duration)`
  - `durationProperty()`

### durationProperty

public final ObjectProperty<Duration> durationProperty()
The duration of this `RotateTransition`.

It is not possible to change the `duration` of a running `RotateTransition`. If the value of `duration` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Note: While the unit of `duration` is a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms. Setting duration to value lower than `Duration.ZERO` will result in `IllegalArgumentException`.

Default value:
  400ms
Returns:
  the `duration` property
See Also:
  - `getDuration()`
  - `setDuration(Duration)`

### setAxis

public final void setAxis(Point3D value)
Sets the value of the `axis` property.

Property description:
  Specifies the axis of rotation for this `RotateTransition`. Use `node.rotationAxis` for axis of rotation if this `axis` is null.

  It is not possible to change the `axis` of a running `RotateTransition`. If the value of `axis` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  null
Parameters:
  `value` - the value for the `axis` property
See Also:
  - `getAxis()`
  - `axisProperty()`

### getAxis

public final Point3D getAxis()
Gets the value of the `axis` property.

Property description:
  Specifies the axis of rotation for this `RotateTransition`. Use `node.rotationAxis` for axis of rotation if this `axis` is null.

  It is not possible to change the `axis` of a running `RotateTransition`. If the value of `axis` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  null
Returns:
  the value of the `axis` property
See Also:
  - `setAxis(Point3D)`
  - `axisProperty()`

### axisProperty

public final ObjectProperty<Point3D> axisProperty()
Specifies the axis of rotation for this `RotateTransition`. Use `node.rotationAxis` for axis of rotation if this `axis` is null.

It is not possible to change the `axis` of a running `RotateTransition`. If the value of `axis` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  null
Returns:
  the `axis` property
See Also:
  - `getAxis()`
  - `setAxis(Point3D)`

### setFromAngle

public final void setFromAngle(double value)
Sets the value of the `fromAngle` property.

Property description:
  Specifies the start angle value for this `RotateTransition`.

  It is not possible to change `fromAngle` of a running `RotateTransition`. If the value of `fromAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
Parameters:
  `value` - the value for the `fromAngle` property
See Also:
  - `getFromAngle()`
  - `fromAngleProperty()`

### getFromAngle

public final double getFromAngle()
Gets the value of the `fromAngle` property.

Property description:
  Specifies the start angle value for this `RotateTransition`.

  It is not possible to change `fromAngle` of a running `RotateTransition`. If the value of `fromAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
Returns:
  the value of the `fromAngle` property
See Also:
  - `setFromAngle(double)`
  - `fromAngleProperty()`

### fromAngleProperty

public final DoubleProperty fromAngleProperty()
Specifies the start angle value for this `RotateTransition`.

It is not possible to change `fromAngle` of a running `RotateTransition`. If the value of `fromAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
Returns:
  the `fromAngle` property
See Also:
  - `getFromAngle()`
  - `setFromAngle(double)`

### setToAngle

public final void setToAngle(double value)
Sets the value of the `toAngle` property.

Property description:
  Specifies the stop angle value for this `RotateTransition`.

  It is not possible to change `toAngle` of a running `RotateTransition`. If the value of `toAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
Parameters:
  `value` - the value for the `toAngle` property
See Also:
  - `getToAngle()`
  - `toAngleProperty()`

### getToAngle

public final double getToAngle()
Gets the value of the `toAngle` property.

Property description:
  Specifies the stop angle value for this `RotateTransition`.

  It is not possible to change `toAngle` of a running `RotateTransition`. If the value of `toAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
Returns:
  the value of the `toAngle` property
See Also:
  - `setToAngle(double)`
  - `toAngleProperty()`

### toAngleProperty

public final DoubleProperty toAngleProperty()
Specifies the stop angle value for this `RotateTransition`.

It is not possible to change `toAngle` of a running `RotateTransition`. If the value of `toAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Default value:
  `Double.NaN`
Returns:
  the `toAngle` property
See Also:
  - `getToAngle()`
  - `setToAngle(double)`

### setByAngle

public final void setByAngle(double value)
Sets the value of the `byAngle` property.

Property description:
  Specifies the incremented stop angle value, from the start, of this `RotateTransition`.

  It is not possible to change `byAngle` of a running `RotateTransition`. If the value of `byAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Parameters:
  `value` - the value for the `byAngle` property
See Also:
  - `getByAngle()`
  - `byAngleProperty()`

### getByAngle

public final double getByAngle()
Gets the value of the `byAngle` property.

Property description:
  Specifies the incremented stop angle value, from the start, of this `RotateTransition`.

  It is not possible to change `byAngle` of a running `RotateTransition`. If the value of `byAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Returns:
  the value of the `byAngle` property
See Also:
  - `setByAngle(double)`
  - `byAngleProperty()`

### byAngleProperty

public final DoubleProperty byAngleProperty()
Specifies the incremented stop angle value, from the start, of this `RotateTransition`.

It is not possible to change `byAngle` of a running `RotateTransition`. If the value of `byAngle` is changed for a running `RotateTransition`, the animation has to be stopped and started again to pick up the new value.

Returns:
  the `byAngle` property
See Also:
  - `getByAngle()`
  - `setByAngle(double)`

### interpolate

protected void interpolate(double frac)
The method `interpolate()` has to be provided by implementations of `Transition`. While a `Transition` is running, this method is called in every frame. The parameter defines the current position with the animation. At the start, the fraction will be `0.0` and at the end it will be `1.0`. How the parameter increases, depends on the `interpolator`, e.g. if the `interpolator` is `Interpolator.LINEAR`, the fraction will increase linear. This method must not be called by the user directly.

Specified by:
  `interpolate` in class `Transition`
Parameters:
  `frac` - The relative position