- All Known Implementing Classes:
AndroidCompassService
,DummyCompassService
,IOSCompassService
,MobileCompassService
public interface CompassService
The compass service provides a compass heading in degrees as a value between 0.0 and 359.99,
where a value of 0.0 represents north.
The CompassService provides a read-only heading property
that is updated at regular intervals by the underlying platform implementation. A user of the
CompassService can listen to changes of the heading, by registering a
ChangeListener
to the
heading property
.
Example
CompassService.create().ifPresent(service -> {
service.start();
double heading = service.getHeading();
System.out.printf("Current heading: %.2f", heading);
});
Android Configuration: none
iOS Configuration: none
- Since:
- 3.0.0
-
Property Summary
TypePropertyDescriptionjavafx.beans.property.ReadOnlyDoubleProperty
A frequently-updated heading of the compass. -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<CompassService>
create()
Returns an instance ofCompassService
.double
Returns the compass heading, represented as a value between 0.0 and 359.99, where 0.0 is north.javafx.beans.property.ReadOnlyDoubleProperty
A frequently-updated heading of the compass.void
start()
Starts the service.void
stop()
Stops the service.
-
Property Details
-
heading
javafx.beans.property.ReadOnlyDoubleProperty headingPropertyA frequently-updated heading of the compass.- See Also:
-
-
Method Details
-
create
Returns an instance ofCompassService
.- Returns:
- An instance of
CompassService
.
-
getHeading
double getHeading()Returns the compass heading, represented as a value between 0.0 and 359.99, where 0.0 is north. If there is no heading data available, -1.0 will be returned to represent this error state.- Returns:
- The current compass heading.
-
headingProperty
javafx.beans.property.ReadOnlyDoubleProperty headingProperty()A frequently-updated heading of the compass.- See Also:
-
start
void start()Starts the service.- Since:
- 4.0.11
-
stop
void stop()Stops the service.- Since:
- 4.0.11
-