Interface ComplicationDataSource


  • public interface ComplicationDataSource
    Represents a source of data that can be displayed on a watchface complication.
    • Method Detail

      • hasText

        boolean hasText()
        Returns whether this source provides a text.
        Returns:
        whether this source provides a text.
      • hasIcon

        boolean hasIcon()
        Returns whether this source provides an icon.
        Returns:
        whether this source provides an icon.
      • hasProgress

        boolean hasProgress()
        Returns whether this source provides a progress.
        Returns:
        whether this source provides a progress.
      • getText

        String getText()
        Returns the text.
        Returns:
        the text.
        Throws:
        IllegalStateException - if this source does not provide a text.
      • onIconAttached

        void onIconAttached()
        Called when the icon is scheduled for imminent rendering.

        For example, this method can load the resources necessary for rendering.

      • onIconDetached

        void onIconDetached()
        Called when the icon is no longer scheduled for imminent rendering.

        For example, this method can dispose of the resources loaded in onIconAttached().

      • renderIcon

        void renderIcon​(GraphicsContext g,
                        int x,
                        int y,
                        int width,
                        int height)
        Renders the icon.
        Parameters:
        g - the graphics context to draw with.
        x - the x coordinate of the region to draw in.
        y - the y coordinate of the region to draw in.
        width - the width of the region to draw in.
        height - the height of the region to draw in.
        Throws:
        IllegalStateException - if this source does not provide an icon.
      • getProgress

        float getProgress()
        Returns the progress.
        Returns:
        the progress (between 0.0f and 1.0f).
        Throws:
        IllegalStateException - if this source does not provide a progress.