Macaw.Frame.Transforms.Layered (macaw_frame v0.1.0)

Copy Markdown View Source

The layered step (spec/04 §5.2, §7.2): a directed graph laid out in ranks with routed edges by Macaw.Draw.Layout.Layered (macaw_draw spec/08 §11), in the plot (needs: [:frame]), for the node and edge kinds of a flowchart, a state, class or ER diagram.

A graph is two tables: its nodes (id, label, shape, by the options of those names) and its edges (fields: [source, target], label). The step reads one as its input and the other from the context's sources by naming its slot: edges: slot with the nodes as input (a node layer, so its rows keep the nodes slot's identity), or nodes: slot with the edges as input (an edge layer); with neither, the input is the edges and the nodes are the ids in order of first appearance, each labeled by its id.

Each node's box is sized from its label by the text estimate at font_size (12) with padding (8) around it (the Frame's measurer, Macaw.Draw.Text.width/3), squared for a circle, widened for a diamond; each edge label's box likewise. direction (tb, bt, lr, rl), routing (spline, polyline, orthogonal), rank_sep (50) and node_sep (20) reach the layout; the drawing is centered in the plot where it fits. diagram (flowchart, state, class, er, page_flow) names the diagram in a summary (phrase/1) and changes nothing drawn. shapes, [spelling, shape] pairs (or a map of them), reads the shape column as a kind each node is drawn by (spec/13 §7.5), [["source", "cylinder"]]: each node is sized by its kind's shape, a spelling no pair names as it is, and the nodes output gains shape, the shape each was sized by. A document writes the pairs, since a map's keys could be spelled like a document's keys. shapes that are no such pairs are {"shapes", {:type, :shapes}}.

output: "nodes" answers one row per node: the nodes table's columns (or id, label, shape, group without one) with x, y (the center), width, height, x0, y0, x1, y1, rank, order. output: "edges" answers one row per edge: the edges table's columns (or source, target, label without one) with path (a Macaw.Draw.IR.Path), reversed, label_x, label_y, and each end's place and bearing (start_x, start_y, start_angle, end_x, end_y, end_angle), so an edge layer draws its markers without reading the path. An edge naming a node the nodes table lacks is {"fields", {:unknown_node, id}}, an id given twice {"id", {:duplicate, id}}.

Summary

Functions

What the frame is called when a data layer's rows are laid out by this step (spec/11 §2.2).

What the frame is called by this step's node (spec/13 §7.3): the diagram its diagram option names, a "flowchart", "state diagram", "class diagram", "ER diagram" or "data flow diagram".

Functions

phrase()

@spec phrase() :: String.t()

What the frame is called when a data layer's rows are laid out by this step (spec/11 §2.2).

phrase(arg1)

@spec phrase(map()) :: String.t()

What the frame is called by this step's node (spec/13 §7.3): the diagram its diagram option names, a "flowchart", "state diagram", "class diagram", "ER diagram" or "data flow diagram".