Interface NTxRendererContext

All Superinterfaces:
net.thevpc.nuts.log.NLogger, NTxResolutionContext

public interface NTxRendererContext extends NTxResolutionContext
  • Field Details

    • CAPABILITY_PRINT

      static final String CAPABILITY_PRINT
      See Also:
    • CAPABILITY_ANIMATE

      static final String CAPABILITY_ANIMATE
      See Also:
    • CAPABILITY_SEARCH_HIGHLIGHTS

      static final String CAPABILITY_SEARCH_HIGHLIGHTS
      Host paints on-canvas search highlights (screen viewer); absent in PDF/HTML/image exports so they never appear there.
      See Also:
  • Method Details

    • sizeRequirementsOf

      default NTxSizeRequirements sizeRequirementsOf()
    • pageLifecycle

      default net.thevpc.nuts.util.NOptional<NtxPageLifecycle> pageLifecycle()
      Live lifecycle of the page currently being rendered, when the hosting renderer knows about page visibility (typically the screen renderer). Static renderers (PDF/image/HTML) return an empty optional.
      See Also:
    • isPageShowing

      default boolean isPageShowing()
      Whether the page being rendered is currently shown to the user. When the host does not track page visibility (PDF/image/HTML or an ad-hoc render) this returns true so components keep their usual behaviour.
      See Also:
    • requestFrame

      default void requestFrame()
      Requests one more animation frame from the hosting view (no-op when there is none). Prefer this over repaint() for continuous animation so a single page-level frame driver can throttle all components together.
      See Also:
    • pageElapsedSeconds

      default double pageElapsedSeconds()
      Seconds elapsed since the page being rendered became visible; 0 while the page is hidden or when the host does not track page visibility (static PDF/image/HTML renders).

      This is the shared animation clock. A component's animation state should be a pure function of this value and the component's own rate (speed / period property), so any number of components can animate at different speeds while sharing a single page-level frame driver (FPS). Do not use System.currentTimeMillis() directly in a component.

      See Also:
    • requestAnimationFrame

      default void requestAnimationFrame(boolean wantsAnimation)
      Convenience for animated components: requests one animation frame only when the component itself wants to animate (wantsAnimation), the host is actually animating (isAnimate()) and the page is currently showing (isPageShowing()). Otherwise it is a no-op, so it is always safe to call once at the end of a render method.

      This requests the page's frame rate (FPS); it does not define an animation speed. Speed is the component's own rate applied to pageElapsedSeconds(). The frame period is owned by the hosting view, so several animated components on the same page share a single throttled frame driver.

      Parameters:
      wantsAnimation - whether this node instance wants animation (its own flag)
      See Also:
    • newTimer

      default NtxAnimationTimer newTimer(long periodMs, Runnable tick)
      Registers a page-owned periodic animation tick for the current node; see NtxPageLifecycle.newTimer(Object, long, Runnable). The tick runs on the UI thread every periodMs while the page is showing, and is disposed with the page. Ticks with the same period share one underlying timer. Returns NtxAnimationTimer.NONE for static renders (PDF/image/HTML), so it is always safe to call.

      Prefer pageElapsedSeconds() + requestFrame() for animations whose state is a pure function of time; use a timer only for genuinely stateful stepping that must happen independently of repaint.

      Parameters:
      periodMs - desired period between ticks in milliseconds (> 0)
      tick - callback invoked on the UI thread while the page is showing
    • clippedGraphics

      default NTxGraphics clippedGraphics(NTxBounds2D bounds)
      Returns a disposable copy of the current graphics whose clip is intersected with bounds. The caller is responsible for calling NTxGraphics.dispose() on the result. Prefer withinClip(NTxBounds2D, Consumer) which does it automatically.

      This is the reusable low-level primitive behind the NTxPropName.OVERFLOW policy and the manual crop used by components (for example the antenna panels) that must never paint outside their own box.

    • clippedGraphics

      default NTxGraphics clippedGraphics(Shape shape)
      Returns a disposable copy of the current graphics whose clip is intersected with shape; see clippedGraphics(NTxBounds2D).
    • withinClip

      default void withinClip(NTxBounds2D bounds, Consumer<NTxRendererContext> body)
      Runs body with a renderer context whose graphics is clipped to bounds, then restores (disposes) the clip. The current context is left untouched, so sibling nodes are never affected by the crop.

      The clip is applied to a private copy of the graphics; anything the component paints outside bounds is discarded, exactly like a Swing JPanel painting into its own rectangle.

    • withinClip

      default void withinClip(Shape shape, Consumer<NTxRendererContext> body)
      Same as withinClip(NTxBounds2D, Consumer) but clips to an arbitrary shape.
    • buildContext

      NTxNodeBuilderContext buildContext()
    • isSomeChange

      boolean isSomeChange()
    • selfBounds2D

      NTxBounds2D selfBounds2D()
    • globalBounds2D

      NTxBounds2D globalBounds2D()
    • parentBounds2D

      NTxBounds2D parentBounds2D()
    • realBounds2D

      NTxBounds2D realBounds2D()
    • realGlobalBounds2D

      NTxBounds2D realGlobalBounds2D()
    • defaultSelfBounds2D

      NTxBounds2D defaultSelfBounds2D()
    • selfBounds3D

      NTxBounds3D selfBounds3D()
    • globalBounds3D

      NTxBounds3D globalBounds3D()
    • parentBounds3D

      NTxBounds3D parentBounds3D()
    • realBounds3D

      NTxBounds3D realBounds3D()
    • realGlobalBounds3D

      NTxBounds3D realGlobalBounds3D()
    • defaultSelfBounds3D

      NTxBounds3D defaultSelfBounds3D()
    • dryMode

    • pageStartTime

      long pageStartTime()
    • imageObserver

      ImageObserver imageObserver()
    • isDry

      boolean isDry()
    • graphics

      NTxGraphics graphics()
    • render

      void render()
    • computePropertyValue

      net.thevpc.nuts.util.NOptional<net.thevpc.nuts.elem.NElement> computePropertyValue(String s, String... synonyms)
    • computeProperties

      List<NTxProp> computeProperties()
    • withBuilderContext

      NTxRendererContext withBuilderContext(NTxNodeBuilderContext builderContext)
    • resolveNode

      NTxRendererContext resolveNode(NTxNode node, NTxBounds2D parentBounds)
    • withDefaultStyles

      NTxRendererContext withDefaultStyles(NTxProperties defaultStyles)
    • withParentBounds

      NTxRendererContext withParentBounds(NTxBounds2D bounds2)
    • withGraphics

      NTxRendererContext withGraphics(NTxGraphics graphics)
    • withRealBounds3D

      NTxRendererContext withRealBounds3D(NTxBounds3D realBounds3D)
    • withRealGlobalBounds3D

      NTxRendererContext withRealGlobalBounds3D(NTxBounds3D realGlobalBounds3D)
    • sizeRef

      NTxSizeRef sizeRef()
    • isPrint

      boolean isPrint()
    • isAnimate

      boolean isAnimate()
    • repaint

      void repaint()
    • getCapability

      Object getCapability(String name)
    • hasCapability

      boolean hasCapability(String name)
    • isCapability

      boolean isCapability(String name)
    • highlightNutsText

      void highlightNutsText(String lang, String rawText, net.thevpc.nuts.text.NText parsedText, NTxTextRendererBuilder result)
    • getColorProperty

      net.thevpc.nuts.util.NOptional<Paint> getColorProperty(String propName)
    • getOrigin

      NTxDouble2 getOrigin(NTxDouble2 a)
    • getPosition

      NTxDouble2 getPosition(NTxDouble2 a)
    • getStroke

      net.thevpc.nuts.elem.NElement getStroke()
    • selfBounds2D

      NTxBounds2D selfBounds2D(NTxDouble2 selfSize, NTxDouble2 minSize)
    • isVisible

      boolean isVisible()
    • isLayoutNone

      boolean isLayoutNone()
    • getFontSize

      double getFontSize()
    • getFontFamily

      String getFontFamily()
    • isFontUnderlined

      boolean isFontUnderlined()
    • isFontStrike

      boolean isFontStrike()
    • isFontBold

      boolean isFontBold()
    • isFontItalic

      boolean isFontItalic()
    • getFont

      Font getFont()
    • getRoundCornerArcs

      NTxDouble2 getRoundCornerArcs()
    • getColSpan

      int getColSpan()
    • getRowSpan

      int getRowSpan()
    • get3D

      Boolean get3D()
    • getRaised

      Boolean getRaised()
    • readStyleAsShadow

      net.thevpc.nuts.util.NOptional<NTxShadow> readStyleAsShadow(String s)
    • getForegroundColor

      Paint getForegroundColor(boolean force)
    • getLineColor

      Paint getLineColor(boolean force)
    • resolveGridColor

      Paint resolveGridColor()
    • resolveBackgroundColor

      Paint resolveBackgroundColor()
    • resolveLineColor

      Paint resolveLineColor(boolean force)
    • isDrawContour

      boolean isDrawContour()
    • requireDrawGrid

      boolean requireDrawGrid()
    • requireFillBackground

      boolean requireFillBackground()
    • getColumns

      int getColumns()
    • getRows

      int getRows()
    • isDebug

      boolean isDebug()
    • getDebugLevel

      int getDebugLevel()
    • getDebugColor

      Color getDebugColor()
    • getStyleAsShadowDistance

      net.thevpc.nuts.util.NOptional<NTxPoint2D> getStyleAsShadowDistance(Object sv)
    • mapDim

      NTxSizeD mapDim(NTxSizeD d, NTxSizeD base)
    • resolveStroke

      Stroke resolveStroke()
    • withStroke

      boolean withStroke(Runnable r)
    • applyStroke

      boolean applyStroke()
    • applyFont

      void applyFont()
    • mapDim

      NTxSizeD mapDim(double w, double h)
    • bounds

    • applyForeground

      boolean applyForeground(boolean force)
    • applyBackgroundColor

      boolean applyBackgroundColor()
    • applyGridColor

      boolean applyGridColor(boolean force)
    • applyLineColor

      boolean applyLineColor(boolean force)
    • applyContourColor

      boolean applyContourColor(boolean force)
    • colorFromPaint

      net.thevpc.nuts.util.NOptional<Color> colorFromPaint(Paint p)
    • paintBorderLine

      void paintBorderLine(NTxBounds2D a)
    • paintBackground

      void paintBackground(NTxBounds2D a)
    • compiledPage

      NTxCompiledPage compiledPage()
      Specified by:
      compiledPage in interface NTxResolutionContext
    • compiledDocument

      NTxCompiledDocument compiledDocument()
      Specified by:
      compiledDocument in interface NTxResolutionContext
    • sourceMonitor

      NTxSourceMonitor sourceMonitor()
    • drawContour

      void drawContour()
    • renderDetachedNode

      void renderDetachedNode(net.thevpc.nuts.elem.NElement childNode, NTxBounds2D relativeBounds)
    • renderDetachedNode

      void renderDetachedNode(NTxNode childNode, NTxBounds2D relativeBounds)
    • resolveNode

      NTxRendererContext resolveNode(NTxNode node)
      ///////
      Specified by:
      resolveNode in interface NTxResolutionContext
    • withElement

      NTxRendererContext withElement(net.thevpc.nuts.elem.NElement element)
      Specified by:
      withElement in interface NTxResolutionContext
    • withNode

      NTxRendererContext withNode(NTxNode parent)
      Specified by:
      withNode in interface NTxResolutionContext
    • pushNode

      NTxRendererContext pushNode(NTxNode node)
      Specified by:
      pushNode in interface NTxResolutionContext
    • popNode

      Specified by:
      popNode in interface NTxResolutionContext