Interface Transition

  • All Known Implementing Classes:
    FadeTransition, SlideTransition

    public interface Transition
    Draws the frames of a page change.

    A transition is a painter, not an animator: it declares how long it lasts with getDuration() and draws one frame per render(GraphicsContext, TransitionContext, float) call. The Navigator owns the clock — it starts the animation, computes the progress, stops at the duration, and shows the incoming content live once the last frame is done. An implementation therefore holds no timer, registers no animation, and signals no completion.

    A frame draws over the pixels the previous frame left on the display: the navigator's container paints neither background nor outlines while a transition runs, so the outgoing content is simply still there, unmoved and opaque. A transition draws the incoming content over it with TransitionContext.drawIncoming(GraphicsContext, int, int, int); there is no operation to draw, move, or fade the outgoing content. Drawing the whole content area on every frame is therefore never necessary, and a frame that leaves a region untouched shows the outgoing content there.

    A transition is a parameterized object, not an enum constant, so an application can configure the shipped transitions (SlideTransition, FadeTransition) or supply its own. IMMEDIATE performs no animation and is the Navigator's initial default.

    Every method is called on the MicroUI thread. The same instance may be reused for any number of navigations, but never for two at once: the navigator snaps a running transition to its end before dispatching the next navigation.

    Since:
    0.2.0
    See Also:
    TransitionContext
    • Field Detail

      • SNAPSHOTS_CONSTANT

        static final String SNAPSHOTS_CONSTANT
        Name of the BON constant enabling the transition snapshots, true by default.

        Setting it to false in an application's .constants.list removes the snapshot buffer, and with it the ability to draw the incoming content at a partial opacity: the frames draw the incoming content widget live instead. It trades the fade for the buffer's memory.

        Since:
        2.0.0
        See Also:
        Constant Field Values
    • Method Detail

      • getDuration

        int getDuration()
        Returns how long this transition lasts, in milliseconds.

        A duration of 0 or less makes the page change instant: the navigator shows the incoming content immediately, without starting this transition and without drawing a single frame.

        Returns:
        the duration in milliseconds.
        Since:
        2.0.0
      • start

        void start​(TransitionContext context)
        Prepares this transition for the page change described by the given context.

        Called once per navigation, before the first frame, and only when getDuration() is strictly positive. The incoming content is already captured, so an implementation may read the content area size and the navigation kind here. Nothing is drawn during this call.

        Parameters:
        context - the context of the page change about to be animated.
        Since:
        2.0.0
      • render

        void render​(GraphicsContext g,
                    TransitionContext context,
                    float progress)
        Draws one frame of this transition.

        The given graphics context is translated and clipped to the content area, and already holds the pixels of the previous frame — the outgoing content. An implementation draws the incoming content over them through the given context.

        Parameters:
        g - the graphics context to draw the frame with, translated and clipped to the content area.
        context - the context of the page change being animated.
        progress - how far the transition has advanced: the elapsed time divided by the duration, at least 0 and strictly less than 1.
        Since:
        2.0.0