Interface NtxPageLifecycle


public interface NtxPageLifecycle
Live, per-page lifecycle state exposed to components by renderers that show pages interactively (typically the screen renderer).

A NtxPageLifecycle is owned by the view that hosts a page and is made available to the render pipeline through NTxRendererContext.pageLifecycle() (stored as the CAPABILITY_PAGE_LIFECYCLE capability). Static renders (PDF, image, HTML) do not provide one, so NTxRendererContext.isPageShowing() stays true there and requestFrame() is never invoked.

Why it exists

Before this contract, animated components had to spin their own javax.swing.Timer to call NTxRendererContext.repaint(). With more than one animated component on a slide that meant one timer (and one full-page repaint) per component, and nothing stopped those timers when the slide was left. Instead, components should:
  • read showElapsedSeconds() to compute their animation phase (stable across frames, starts at 0 each time the page is shown);
  • call requestFrame() once per render while they still want to animate. The hosting view runs a single, throttled frame driver and idles as soon as no component requests a frame.
See Also:
  • Field Details

  • Method Details

    • pageIndex

      int pageIndex()
      Index of the page this lifecycle belongs to.
    • isShowing

      boolean isShowing()
      Whether this page is the one currently shown by the hosting view. false for a page that is only prefetched or already hidden.
    • showStartTime

      long showStartTime()
      Wall-clock time (in milliseconds, System.currentTimeMillis() frame) at which the page became visible, or 0 if it has never been shown. This is the anchor used by showElapsedMillis().
    • showElapsedMillis

      default long showElapsedMillis()
      Milliseconds elapsed since this page became visible, or 0 while it is not showing. The value is stable across frames so animations keep a continuous phase.
    • showElapsedSeconds

      default double showElapsedSeconds()
      Seconds elapsed since this page became visible; see showElapsedMillis().
    • requestFrame

      void requestFrame()
      Asks the hosting view to render another animation frame soon. Components call this once per render for as long as they want to keep animating. It is a no-op when there is no live view driving the page.
    • newTimer

      default NtxAnimationTimer newTimer(Object owner, long periodMs, Runnable tick)
      Registers a periodic animation tick, owned by the page.

      The hosting view runs tick every periodMs while the page is showing, stops it when the page stops showing and disposes it when the page is discarded, so callers never have to clean up. Ticks that share the same periodMs are grouped and driven by a single underlying timer.

      Registration is keyed by owner: calling again with the same owner replaces the previous tick (typically used to refresh the callback on every render), so it is safe to call from every render. The callback runs on the UI thread; it should not capture a transient render context.

      Parameters:
      owner - stable identity of the registrant; typically the node
      periodMs - desired period between ticks in milliseconds (> 0)
      tick - callback invoked on the UI thread while the page is showing
      Returns:
      a handle to cancel the tick early; never null