MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / DispatchBox

Class DispatchBox

src/main/java/fieldbox/boxes/plugins/DispatchBox.java:28–298  ·  view source on GitHub ↗

A Box with a custom drawer for holding onto and drawning a connection between two other boxes. Automatically deletes itself should either of its two ends disappears. head() is the parent of tail() is the dispatch graph

Source from the content-addressed store, hash-verified

26 * head() is the parent of tail() is the dispatch graph
27 */
28public class DispatchBox extends Box implements IO.Loaded // the drawer is initialized after all the properties are loaded
29{
30
31 static public final Dict.Prop<BoxRef> head = new Dict.Prop<>("head").type()
32 .toCanon()
33 .doc("the head of this topology arrow box");
34 static public final Dict.Prop<BoxRef> tail = new Dict.Prop<>("tail").type()
35 .toCanon()
36 .doc("the tail of this topology arrow box");
37
38
39 static public final Dict.Prop<FunctionOfBoxValued<Collection<Missing.Log>>> logThrough = new Dict.Prop<>("logThrough").type()
40 .toCanon()
41 .doc("property transcript filtered to include only property access that's _through_ this connection");
42
43 static {
44 // these properties need to be saved in our document
45 IO.persist(head);
46 IO.persist(tail);
47 }
48
49 static private final boolean notForInsert = true; // tell FileBrowser not to bother offering us for insertion
50 Rect cache_h = null;
51 Rect cache_t = null;
52
53 public DispatchBox(Box head, Box tail) {
54 this.properties.put(DispatchBox.head, new BoxRef(head));
55 this.properties.put(DispatchBox.tail, new BoxRef(tail));
56 this.properties.put(Chorder.nox, true);
57
58 loaded();
59 this.properties.put(Boxes.dontSave, true);
60 }
61
62
63 /**
64 * custom constructor, call init after you are done
65 */
66 protected DispatchBox() {
67 this.properties.put(Boxes.dontSave, true);
68 }
69
70 static public Pair<FLine, Vec3> arc(Rect from, Rect to, float d1, float d2, boolean selected) {
71
72 return Dispatch.arc(from, to, d1, d2, selected);
73
74 /*FLine f = new FLine();
75
76 Vec2 a = new Vec2(from.x + from.w / 2, from.y + from.h / 2);
77 Vec2 b = new Vec2(to.x + to.w / 2, to.y + to.h / 2);
78
79 float d = (float) b.distance(a);
80
81 Vec2 normal = Vec2.sub(b, a, new Vec2());
82
83 Vec2 tan = new Vec2(-normal.y, normal.x).normalize().mul(d * 0.15f);
84 if (normal.x > 0) tan.mul(-1);
85

Callers

nothing calls this directly

Calls 4

persistMethod · 0.95
docMethod · 0.80
toCanonMethod · 0.80
typeMethod · 0.80

Tested by

no test coverage detected