Package com.gluonhq.attach.accelerometer
Interface AccelerometerService
-
- All Known Implementing Classes:
AndroidAccelerometerService
,DummyAccelerometerService
,IOSAccelerometerService
public interface AccelerometerService
An accelerometer measures the acceleration force that is applied to a device in all three physical axes (x, y and z).The AccelerometerService provides a read-only
acceleration property
that is updated at regular intervals by the underlying platform implementation. A user of the AccelerometerService can listen to changes of the acceleration force, by registering aChangeListener
to theacceleration property
.Example
AccelerometerService.create().ifPresent(service -> { Acceleration acceleration = service.getCurrentAcceleration(); System.out.printf("Current acceleration: %.2f, %.2f, %.2f", acceleration.getX(), acceleration.getY(), acceleration.getZ()); });
Android Configuration: none
iOS Configuration: none
- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
FILTER_GRAVITY
static int
FREQUENCY
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description javafx.beans.property.ReadOnlyObjectProperty<Acceleration>
accelerationProperty()
A frequently-updated reading from the accelerometer.static java.util.Optional<AccelerometerService>
create()
Returns an instance ofAccelerometerService
.Acceleration
getCurrentAcceleration()
Returns a single reading from the accelerometer.
-
-
-
Field Detail
-
FILTER_GRAVITY
static final boolean FILTER_GRAVITY
- See Also:
- Constant Field Values
-
FREQUENCY
static final int FREQUENCY
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
static java.util.Optional<AccelerometerService> create()
Returns an instance ofAccelerometerService
.- Returns:
- An instance of
AccelerometerService
.
-
getCurrentAcceleration
Acceleration getCurrentAcceleration()
Returns a single reading from the accelerometer.- Returns:
- the current accelerometer reading
-
accelerationProperty
javafx.beans.property.ReadOnlyObjectProperty<Acceleration> accelerationProperty()
A frequently-updated reading from the accelerometer.- Returns:
- A property containing a frequently-updated accelerometer reading.
-
-