-
- 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 aChangeListener
to theheading 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
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static java.util.Optional<CompassService>
create()
Returns an instance ofCompassService
.double
getHeading()
Returns the compass heading, represented as a value between 0.0 and 359.99, where 0.0 is north.javafx.beans.property.ReadOnlyDoubleProperty
headingProperty()
A frequently-updated heading of the compass.void
start()
Starts the service.void
stop()
Stops the service.
-
-
-
Method Detail
-
create
static java.util.Optional<CompassService> 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.- Returns:
- A property containing a frequently-updated compass heading.
-
start
void start()
Starts the service.- Since:
- 4.0.11
-
stop
void stop()
Stops the service.- Since:
- 4.0.11
-
-