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

Class Dispatch

src/main/java/fieldbox/boxes/plugins/Dispatch.java:31–483  ·  view source on GitHub ↗

Adds: Hold down G to change the box-graph network. Also draws the current graph topology. This is like Topology.java, but simpler, since the connections that it produces are not reified as new boxes.

Source from the content-addressed store, hash-verified

29 * This is like Topology.java, but simpler, since the connections that it produces are not reified as new boxes.
30 */
31public class Dispatch extends Box implements Mouse.OnMouseDown, Mouse.OnMouseMove, Keyboard.OnKeyDown {
32
33 static public final Dict.Prop<Boolean> shyConnections = new Dict.Prop<>("shyConnections").type()
34 .toCanon()
35 .doc("boxes with this property set to true only show connections when they are selected").set(IO.persistent, true);
36
37 private final Box root;
38 boolean on = false;
39
40 long allFrameHashSalt = 0;
41
42 public Dispatch(Box root) {
43 this.root = root;
44 this.properties.put(Planes.plane, "__always__");
45 this.properties.putToMap(Mouse.onMouseDown, "__dispatch__", this);
46 this.properties.putToMap(Mouse.onMouseMove, "__dispatch__", this);
47 this.properties.putToMap(Keyboard.onKeyDown, "__dispatch__", this);
48
49 this.properties.putToMap(FLineDrawing.frameDrawing, "__allTopology__", FrameChangedHash.getCached(this,
50 (b, was) -> {
51
52 FLine f = new FLine();
53
54 breadthFirst(both()).filter(x -> x.properties.has(Box.frame))
55 .filter(x -> !x.properties.isTrue(
56 Box.hidden, false))
57 .forEach(x -> {
58 if (Planes.on(root, x) < 1) return;
59 if (x.properties.isTrue(shyConnections, false))
60 return;
61
62 int n = 0;
63 for (Box x2 : new ArrayList<>(x.children())) {
64 if (x2.properties.has(Box.frame) && Planes.on(root, x2) >= 1 && (!x2.properties.isTrue(shyConnections, false))) {
65
66
67 ensureBox(x, x2);
68
69 if (n++ > 25)
70 break; // TODO: indicate that we're giving up making boxes for things with more than 25 children
71 }
72
73 }
74
75 });
76
77 return f;
78
79// }, b -> allFrameHash()));
80 }, () -> allFrameHashSalt));
81 this.properties.putToMap(FLineDrawing.frameDrawing, "__allTopologySelected__", FrameChangedHash.getCached(this, (b, was) -> {
82
83 FLine f = new FLine();
84
85 breadthFirst(both()).filter(x -> x.properties.has(Box.frame))
86 .filter(x -> !x.properties.isTrue(Box.hidden, false))
87 .filter(x -> x.properties.isTrue(Mouse.isSelected, false))
88 .forEach(x -> {

Callers

nothing calls this directly

Calls 4

docMethod · 0.80
toCanonMethod · 0.80
typeMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected