Interface DrawCaption

All Known Implementing Classes:
DrawCaption.FixedPoint, DrawCaption.Literal, DrawCaption.None

public sealed interface DrawCaption permits DrawCaption.Literal, DrawCaption.FixedPoint, DrawCaption.None
The words a captioned command draws, and the style to draw them in.

The wire has three spellings of one payload — text on a text command, label on a component highlight, and value plus decimals for a number the producer formats — and exactly one is legal per command. Sending two is an error rather than a precedence rule, because "which one wins" is not something a caller could guess from a reply that succeeded.

This type is that rule made structural: a command holds one caption, so there is no way to express two. DrawCaption.None covers the highlight that carries no caption at all. The producer's errors stay as the contract for other clients; they are simply not reachable from here.

Why a caption is not part of DrawStyle. A caption and a font are legal only on text and component commands — the producer rejects both on a rect, ellipse, line or poly with only text and component commands take text, label or value and only text and component commands take a font. Keeping them here rather than on the shared style means a shape cannot carry one in the first place. The producer's own spec warns callers who build from a shared style object to strip font for the shapes; this host has nothing to strip.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A fixed-point number the producer formats.
    static final record 
    Literal text.
    static final record 
    The absence of a caption.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final DrawCaption
    No caption.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    True when there is nothing to draw.
    of(long value, int decimals)
    A number, scaled.
    of(long value, int decimals, DrawFont font)
    A number, scaled, in a named style.
    of(String text)
    A caption drawn as-is.
    of(String text, DrawFont font)
    A caption drawn as-is, in a named style.
    This caption in a different style.
  • Field Details

    • NONE

      static final DrawCaption NONE
      No caption. Valid on a component highlight; not on a text command.
  • Method Details

    • of

      static DrawCaption of(String text)
      A caption drawn as-is.
    • of

      static DrawCaption of(String text, DrawFont font)
      A caption drawn as-is, in a named style.
    • of

      static DrawCaption of(long value, int decimals)
      A number, scaled. of(1234, 2) draws "12.34"; of(-5, 2) draws "-0.05"; of(-4200, 0) draws "-4200".

      There is no float anywhere on this wire, deliberately, so a script that wants to caption a distance or a percentage sends a scaled integer and says what it scaled by. The integer part is zero-padded by the producer, so nothing renders as a bare .05.

    • of

      static DrawCaption of(long value, int decimals, DrawFont font)
      A number, scaled, in a named style.
    • withFont

      DrawCaption withFont(DrawFont font)
      This caption in a different style.
    • isEmpty

      default boolean isEmpty()
      True when there is nothing to draw.