Package com.gluonhq.attach.accelerometer
Interface AccelerometerService
- All Known Implementing Classes:
AndroidAccelerometerService
,DummyAccelerometerService
,IOSAccelerometerService
,MobileAccelerometerService
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 a
ChangeListener
to the
acceleration property
.
Example
AccelerometerService.create().ifPresent(service -> {
service.start();
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
-
Property Summary
TypePropertyDescriptionjavafx.beans.property.ReadOnlyObjectProperty<Acceleration>
A frequently-updated reading from the accelerometer. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Parameters
Default frequency is 50 Hz (50 samples per second). -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ReadOnlyObjectProperty<Acceleration>
A frequently-updated reading from the accelerometer.static Optional<AccelerometerService>
create()
Returns an instance ofAccelerometerService
.Returns a single reading from the accelerometer.void
start()
Starts the service withDEFAULT_PARAMETERS
.void
start
(Parameters parameters) Starts the service with given parameters.void
stop()
Stops the service.
-
Property Details
-
acceleration
javafx.beans.property.ReadOnlyObjectProperty<Acceleration> accelerationPropertyA frequently-updated reading from the accelerometer.
-
-
Field Details
-
DEFAULT_PARAMETERS
Default frequency is 50 Hz (50 samples per second). By default, gravity is not filtered.
-
-
Method Details
-
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. -
start
void start()Starts the service withDEFAULT_PARAMETERS
.- Since:
- 4.0.11
-
start
Starts the service with given parameters.- Parameters:
parameters
- Parameters for configuring the service- Since:
- 4.0.11
-
stop
void stop()Stops the service.- Since:
- 4.0.11
-