Interface Transition
-
- All Known Implementing Classes:
FadeTransition,SlideTransition
public interface TransitionDraws 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 perrender(GraphicsContext, TransitionContext, float)call. TheNavigatorowns 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.IMMEDIATEperforms no animation and is theNavigator'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 Summary
Fields Modifier and Type Field Description static intDEFAULT_DURATION_MILLISDefault duration of the shipped animated transitions (FadeTransition,SlideTransition), in milliseconds.static TransitionIMMEDIATEThe instant transition: the incoming content replaces the outgoing content in a single frame.static StringSNAPSHOTS_CONSTANTName of the BON constant enabling the transition snapshots,trueby default.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetDuration()Returns how long this transition lasts, in milliseconds.voidrender(GraphicsContext g, TransitionContext context, float progress)Draws one frame of this transition.voidstart(TransitionContext context)Prepares this transition for the page change described by the given context.
-
-
-
Field Detail
-
SNAPSHOTS_CONSTANT
static final String SNAPSHOTS_CONSTANT
Name of the BON constant enabling the transition snapshots,trueby default.Setting it to
falsein an application's.constants.listremoves 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
-
DEFAULT_DURATION_MILLIS
static final int DEFAULT_DURATION_MILLIS
Default duration of the shipped animated transitions (FadeTransition,SlideTransition), in milliseconds.- See Also:
- Constant Field Values
-
IMMEDIATE
static final Transition IMMEDIATE
The instant transition: the incoming content replaces the outgoing content in a single frame.This is the
Navigator's initial default transition; it reproduces a non-animated page change. Its duration is0, so the navigator completes it synchronously and never callsstart(TransitionContext)norrender(GraphicsContext, TransitionContext, float)on it.
-
-
Method Detail
-
getDuration
int getDuration()
Returns how long this transition lasts, in milliseconds.A duration of
0or 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 least0and strictly less than1.- Since:
- 2.0.0
-
-