Diagram
基本信息
api.diagram.Diagram —— 一张完整的图 = 若干 Layout 骨架 +
插进槽位的 DisplayComponent。
抽象成员
| 成员 | 行 | 说明 |
|---|---|---|
slotInsertions() |
62 | ImmutableMultiset<Layout.Key> —— 插入计数(多重集,非 Set) |
interactables(DiagramState) |
66 | |
dimension(DiagramState) |
71 | 供 AdaptiveWidthDiagramGroup 取宽度 |
drawBackground(DiagramState) |
75 | |
drawForeground(DiagramState) |
79 | |
builder() |
83 | 工厂 |
slotInsertions()是ImmutableMultiset而不是Set—— 重复插入同一键要能被计数,因为空图判定 (buildEmptyDiagramPredicate)比较的是slotInsertions().size()。
Builder 的插入入口(11 个)
| 方法 | 行 | 说明 |
|---|---|---|
addLayout(Layout) |
155 | 加骨架 |
addAllLayouts(Iterable<Layout>) |
166 | |
addOptionalLayout(Layout) |
177 | |
addAllOptionalLayouts(...) |
188 | |
insertIntoSlot(SlotKey, DisplayComponent...) |
199 | 单槽插入 |
insertIntoSlot(SlotKey, Iterable<DisplayComponent>) |
217 | |
autoInsertIntoSlotGroup(SlotGroupKey) |
236 | 自动分配到组内下一个空槽 |
manualInsertIntoSlotGroup(SlotGroupKey) |
256 | 手动指定 x,y |
addInteractable(Interactable) |
261 | |
build() |
266 |
子 Builder 三种填充分支
| 分支 | 入口 | 行为 |
|---|---|---|
SlotGroupAutoSubBuilder |
autoInsertIntoSlotGroup |
insertIntoNextSlot / insertEach / insertEachSafe / insertEachGroup / insertEachGroupSafe |
SlotGroupManualSubBuilder |
manualInsertIntoSlotGroup |
insertIntoSlot(int x, int y, ...) |
| — | 直接 insertIntoSlot(SlotKey, ...) |
不经组 |
Safe 后缀的语义差异
insertEachSafe(第 333 行)/insertEachGroupSafe(第 369 行)吞掉异常,
非 Safe 版本会向上抛。这是「未调用则行为不同」的一类字段 ——
不能凭默认值推断,需要逐个读实现。
相关条目
源码
src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/Diagram.java