Interface TransitionContext


  • public interface TransitionContext
    The page change a Transition draws: the content area it draws in, the navigation that caused it, and the incoming content it draws.

    The outgoing content is deliberately absent. It is not a widget nor an image the transition can reach: it is the frame already on the display, which the navigator's container leaves untouched for the whole transition. A frame therefore starts from the outgoing content and can only add to it, which is why a shipped slide moves the incoming content over a stationary outgoing one rather than pushing both.

    All coordinates are relative to the top-left corner of the content area.

    The navigator supplies the implementation; an application consumes this interface from its Transition and is not expected to implement it.

    Since:
    0.2.0
    See Also:
    Transition
    • Method Detail

      • getContentWidth

        int getContentWidth()
        Returns the width of the content area the frames are drawn in.
        Returns:
        the content width in pixels.
      • getContentHeight

        int getContentHeight()
        Returns the height of the content area the frames are drawn in.
        Returns:
        the content height in pixels.
      • getNavigationKind

        int getNavigationKind()
        Returns which navigation is being animated.
        Returns:
        FORWARD, BACK, or REPLACE.
        Since:
        2.0.0
      • drawIncoming

        void drawIncoming​(GraphicsContext g,
                          int x,
                          int y,
                          int alpha)
        Draws the incoming content with its top-left corner at the given coordinates and at the given opacity.

        The coordinates are relative to the top-left corner of the content area, and may place the content partly or wholly outside it: what falls outside is clipped away. The pixels the drawing does not cover keep showing the outgoing content.

        When the snapshots are disabled through Transition.SNAPSHOTS_CONSTANT, the incoming content widget is drawn live and the given opacity is ignored.

        Parameters:
        g - the graphics context of the frame being drawn.
        x - the x coordinate of the incoming content's top-left corner.
        y - the y coordinate of the incoming content's top-left corner.
        alpha - the opacity to draw with, from GraphicsContext.TRANSPARENT to GraphicsContext.OPAQUE.
        Since:
        2.0.0
      • getIncomingImage

        @Nullable
        Image getIncomingImage()
        Returns the incoming content as an image the size of the content area.

        This is the snapshot drawIncoming(GraphicsContext, int, int, int) draws, exposed for the transitions that need more than a blit — drawing it region by region, for instance. The returned image belongs to the navigator: it is reused by the following transitions and must never be closed nor drawn into.

        Returns:
        the incoming content image, or null when the snapshots are disabled through Transition.SNAPSHOTS_CONSTANT.
        Since:
        2.0.0