Interface DrawCaption
- All Known Implementing Classes:
DrawCaption.FixedPoint, DrawCaption.Literal, DrawCaption.None
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 ClassesModifier and TypeInterfaceDescriptionstatic final recordA fixed-point number the producer formats.static final recordLiteral text.static final recordThe absence of a caption. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanisEmpty()True when there is nothing to draw.static DrawCaptionof(long value, int decimals) A number, scaled.static DrawCaptionA number, scaled, in a named style.static DrawCaptionA caption drawn as-is.static DrawCaptionA caption drawn as-is, in a named style.This caption in a different style.
-
Field Details
-
NONE
No caption. Valid on a component highlight; not on a text command.
-
-
Method Details
-
of
A caption drawn as-is. -
of
A caption drawn as-is, in a named style. -
of
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
A number, scaled, in a named style. -
withFont
This caption in a different style. -
isEmpty
default boolean isEmpty()True when there is nothing to draw.
-