Module

Hylograph.Flow.Render.Laws

Package
purescript-hylograph-flow-render
Repository
afcondon/purescript-hylograph-flow-render

What must hold of a layout, as functions that return what does not. Here, and not in a test directory, so that every adapter's tests can hold the layout of its own real flows to it, and every engine's author can hold the engine to it.

THE LAWS ARE SPLIT BY WHAT THEY ARE TRUE OF. In 0.2 there was one list, and it was the Sankey layout's: an edge as wide as its quantity says, a node as tall as its wider side. A correct layout by another engine was reported as dozens of faults. Now:

General laws hold of any layout of any projection under any picture, whichever engine made it (generalFaults):

  • Placed: each node of the projection has exactly one place, in the projection's order, and each edge one;
  • Finite: every number is finite (boxes, ports, routes, outlines, the picture's size) and no box has a negative side;
  • Within: every node's box and every outline is inside the picture;
  • Apart: no two node boxes overlap;
  • Ported: a placed port is one of its node's own (an input of that name, or an output), is placed once, and is within its side's length;
  • Routed: every route starts on the box of the node its edge is from and ends on the box of the node it is to (on the boundary, to within meeting), and where the edge names a port and the node has that port placed, at the port; and a polyline's jumps are on the polyline;
  • Lettered: where the picture sets words, every node has its words set, within the lines allowed; no line is wider than the node's own breadth has room for, as the estimate has it (a single character too wide for the room aside); and the node is tall enough for them. Where it sets none, no node has any;
  • Outlined: there is one outline for each open group that holds a node, and none where the picture tells of no group; its members are the nodes the grouping puts in it, however deep; every member is inside its outline, under the strip for its name; an outline's parent is the nearest open group over it, and the outline is inside its parent's, under the parent's strip; the outlines of two groups overlap only where one holds the other; and no node that is not a member is in an outline, or partly in it.

Promised laws hold of the layouts of an engine that promises them (Hylograph.Flow.Render.Engine.Promise), and are asked of no other (promiseFaults):

  • FlowForward (FlowsForward): an edge not turned back ends further along the flow than it starts (to the right, or below, by the layout's direction), and in a later layer where both its nodes have one; and where the projection has no cycle no edge is turned back;
  • LayerAlignment (LayersAligned): the nodes of one layer have their middles in one line across the flow, and a later layer's line is further along it;
  • Orthogonality (RoutesOrthogonal): every route is a polyline, each leg of which runs along an axis;
  • Conservation (WidthsConserved): every route is a ribbon, as broad as its width says at the promise's scale; the ribbons on one side of a node stand inside the node and beside one another; and the node is as tall as the broader side, or as its words need where that is more. (Checked where every width is positive.)

check engine picture projection layout is the general laws and exactly the engine's promises. A fault says which law it is of (Law, a closed ADT, so a test can say "this engine breaks Apart and nothing else" without reading words) and what is wrong, in words.

faults and layoutFaults are 0.2's, of the Sankey engine with no words and no groups, and say what they said.

#Fault Source

type Fault = { law :: Law, words :: String }

What is wrong, and which law it is against.

#generalLaws Source

generalLaws :: Array Law

The laws every layout is held to.

#isGeneral Source

#lawOf Source

lawOf :: forall wire. Promise wire -> Law

The law a promise is a promise of.

#generalFaults Source

generalFaults :: forall wire. Picture -> Projection wire -> Layout wire -> Array Fault

Every fault against a general law; none is the law.

#promiseFaults Source

promiseFaults :: forall wire. Promise wire -> Picture -> Projection wire -> Layout wire -> Array Fault

Every fault against the law a promise is of; none is the law.

#check Source

check :: forall wire. Engine wire -> Picture -> Projection wire -> Layout wire -> Array Fault

The general laws and exactly the laws the engine promises, of a layout said to be the engine's of the projection under the picture.

#broken Source

broken :: Array Fault -> Array Law

The laws some fault is against, each once, in Law's order.

#faultsOf Source

faultsOf :: forall wire. Engine wire -> Picture -> Projection wire -> Layout wire -> Array String

check, in words alone.

#layoutFaultsOf Source

layoutFaultsOf :: forall wire. Engine wire -> Picture -> Projection wire -> Array String

The faults of the layout an engine makes of a projection.

#faults Source

faults :: forall wire. Metrics -> Widths wire -> Projection wire -> Layout wire -> Array String

Every fault in a layout of a projection by the Sankey engine, with no words set and no group outlined (as in 0.2).

#layoutFaults Source

layoutFaults :: forall wire. Metrics -> Widths wire -> Projection wire -> Array String

The faults of the layout the Sankey engine makes of a projection (as in 0.2).

#strangers Source

strangers :: forall wire. Layout wire -> Array { group :: GroupId, node :: PlacedNode }

The nodes that are in an outline's box, or partly in it, and are no member of its group: each with the group. The law is that there are none; this is the list, for a caller that wants the number.

#acyclic Source

acyclic :: forall wire. Projection wire -> Boolean

No path of edges returns to where it began (an edge from a node to itself is such a path).

#varied Source

varied :: forall wire. Widths wire

Widths that differ from edge to edge and mean nothing, for holding the Sankey engine to its laws on a flow whose wires carry no quantity: the number of wires an edge stands for, and a half more where its source's key is below its target's.

#meeting Source

meeting :: Number

How near a route's end must be to the box, or the port, it is said to be on: a hundredth of a pixel. (Every engine held to this so far meets to within a millionth; the room is for an engine whose ports and routes are worked out on different grids.)