Class DrawCaptionBuilder
text command and
a captioned component highlight.
draw.component(1473, 5).color(Colors.CYAN).label("Inventory").submit();
draw.text("state", 40, 140, "banking").font(DrawFont.SMALL).submit();
draw.value("dps", 40, 160, 1234, 2).font(DrawFont.LARGE).submit(); // "12.34"
Why this is a separate type from DrawBuilder. A caption and a
font are legal only on these two kinds; the producer rejects both on a rect,
ellipse, line or poly. Splitting the chain means draw.rect(...).font(...)
does not compile, rather than compiling and being refused at run time on a
round-trip the script has already paid for. The producer's spec warns callers
who build commands from a shared style object to strip font for the
shapes — there is nothing to strip here, because a shape's builder never had
one.
The styling half is delegated to a DrawBuilder rather than copied,
so there is one implementation of what color or ttl mean. Only
the return types differ, which is what keeps the chain typed.
-
Method Summary
Modifier and TypeMethodDescriptionalpha(int alpha) The current colour at a different 0..255 alpha.build()The command as configured, without sending it.caption()The caption as configured.color(int argb) Packed0xAARRGGBB.filled()Fill rather than stroke.filled(boolean fill) Fill or stroke explicitly.Draw the caption in a named style.Draw this text.screen()Client-area pixels, origin top-left.submit()Send the command, and answer the key it is stored under.thickness(int pixels) Stroke width, for the box a component highlight draws around its rect.ttl(long milliseconds) Lifetime in milliseconds.Lifetime as aDuration, truncated to whole milliseconds.Keep until replaced, cleared, or the script's connection closes.value(long value) Draw this whole number.value(long value, int decimals) Draw this scaled number:value(1234, 2)renders"12.34".world()Game-world coordinates, projected by the producer.z(int order) Draw order; higher is drawn in front.
-
Method Details
-
label
Draw this text. Replaces any caption already set — the wire allows exactly one caption per command, so these are alternatives rather than additions. -
value
Draw this scaled number:value(1234, 2)renders"12.34". Replaces any caption already set.There is no float on this wire, deliberately. Send a scaled integer and say what you scaled it by.
-
value
Draw this whole number. -
font
Draw the caption in a named style. A style name, not a size.Order-independent: the style is remembered and applied to whatever caption the chain ends up with, as well as to one already set.
font(...)beforelabel(...)and after it mean the same thing — which they would not if the style lived only on the caption value, becauseDrawCaption.NONEhas nowhere to keep it.A font on a command that never gains a caption draws nothing and sends nothing: a highlight with no label has no words to style. That is deliberately not an error, because setting the style up front and the caption conditionally is a reasonable thing to write:
DrawCaptionBuilder box = draw.component(iface, comp).font(DrawFont.HEADING); if (showName) { box.label(npcName); } box.submit();- Throws:
IllegalArgumentException- iffontis null. Rejected here rather than carried, because a null survives theDrawCaption.NONEpath —None.withFontignores its argument — and would otherwise surface from inside a laterlabel()orvalue(), naming the wrong call.
-
caption
The caption as configured. -
color
Packed0xAARRGGBB. SeeColors. -
alpha
The current colour at a different 0..255 alpha. -
thickness
Stroke width, for the box a component highlight draws around its rect. -
filled
Fill rather than stroke. Meaningful for a component highlight's box. -
filled
Fill or stroke explicitly. -
z
Draw order; higher is drawn in front. The only way to control which of several overlapping highlights is visible where they cross. -
ttl
Lifetime in milliseconds. Defaults toDrawLimits.DEFAULT_TTL_MS. -
ttl
Lifetime as aDuration, truncated to whole milliseconds. -
untilCleared
Keep until replaced, cleared, or the script's connection closes. -
screen
Client-area pixels, origin top-left. The default. -
world
Game-world coordinates, projected by the producer. SeeDrawSpace.WORLD. -
build
The command as configured, without sending it.The return type narrowed from
DrawCommandtoDrawCommand.Primitive, for the same reason and with the same consequences asDrawBuilder.build(): source-compatible, not binary compatible, so a script compiled against an olderbot-apineeds a rebuild. -
submit
Send the command, and answer the key it is stored under.
-