Layout

基本信息

api.diagram.layout.Layout implements Drawable —— 一张图的静态骨架: 线、文字标签、可交互图元、槽位与槽位组的集合。内容(图上放什么)由 Diagram 决定。

两个键类型

类型 说明
SlotKey(抽象静态类,implements Key) 单个槽位的键,方法 key()
SlotGroupKey 槽位组的键,方法 key()

抽象成员

成员 行 类型
lines() 59 ImmutableList<Lines>
labels() 61 ImmutableList<Drawable>
interactables() 63 ImmutableList<Interactable>
slots() 65 ImmutableMap<SlotKey, Slot>
slotGroups() 67 ImmutableMap<SlotGroupKey, SlotGroup>
paddingBottom() 69 int
toPrettyString() 110 String —— 调试输出
toBuilder() / Builder 116 / 119 —

⚠️ 键名是 API 契约的一部分

Debug Ruler 用格式串 "slot(%d,%d)" 生成槽位键(行号、列号 1 基),再传给 Diagram.Builder.insertIntoSlot(...)。 各生成器的 LayoutHandler 各自定义键格式,键名对不上会导致组件插不进槽位。

协作组件

  • Grid —— 像素坐标基准(见 Grid)
  • Slot / SlotGroup —— 槽位定位
  • Lines / ComponentLabel / Text —— 文字
  • ComponentLabel 同时生成槽位 tooltip

相关条目

源码

  • src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/layout/Layout.java
  • src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/layout/Grid.java
  • src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/layout/Slot.java
  • src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/layout/SlotGroup.java
  • src/main/java/com/github/dcysteine/neicustomdiagram/api/diagram/layout/ComponentLabel.java