Provides a means of re-interpreting the coordinate system when plotting trees so that the the tree root can be top/left/bottom/right and the child order plotted anti-clockwise or clockwise.
This can convert ‘logical’ positions into ‘physical’ positions. Where a ‘logical’ position is one with the root of the tree at the top and the child nodes below in left-to-right (i.e. anti-clockwise) order. A ‘physical’ position is a plot-able position where the root of the tree is top/left/bottom or right and the child nodes are in anti-clockwise or clockwise order.
If the first suffix is ‘l’ this is the “logical” coordinate system. If the first suffix is ‘p’ this is the “physical” coordinate system.
Then:
C The canvas dimension, Cpw is "Canvas physical width"
W Width dimension, physical and logical.
D Depth dimension, physical and logical.
B Box datum position ("top-left"), physical and logical, x and y.
P Arbitrary point, physical and logical, x and y.
So this “logical view” of the tree graph (‘top’ and ‘-‘): i.e. Root(s) is a top and children are written in an anti-clockwise.
---> x
|
\/
y
<------------------------ Clw ------------------------>
| To Parent
| |
| Blx, Bly -->*************************
| * | *
Cld * Dl *
| *<-------- Wl -----|--->*
| * | *
| Plx, Ply ->. * | *
| *************************
| | | |
| To C[0] To C[c] To C[C-1]
Or:
Origin | Cpw | Cpd | Wp | Dp | Bpx | Bpy | Ppx | Ppy |
---|---|---|---|---|---|---|---|---|
top | Clw | Cld | Wl | Dl | Blx | Bly | Plx | Ply |
left | Cld | Clw | Dl | Wl | Bly | (Clw-Plx-Wl) | Ply | Clw-Plx |
bottom | Clw | Cld | Wl | Dl | (Clw-Plx-Wl) | (Cld-Ply-Dl) | Clw-Plx | Cld-Ply |
right | Cld | Clw | Dl | Wl | (Cld-Ply-Dl) | Blx | Cld-Ply | Plx |
Note the diagonal top-right to bottom-left transference between each pair of columns. That is because with each successive line we are doing a 90 degree rotation (anti-clockwise) plus a +ve y translation by Clw (top->left or bottom->right) or Cld (left->bottom or right->top).
Moving from one child to another is done in the following combinations:
Origin | ‘-‘ | ‘+’ |
---|---|---|
top | right | left |
left | up | down |
bottom | left | right |
right | down | up |
Exception class for TreePlotTransform.
Exception class for out of range input on construction.
Provides a means of re-interpreting the coordinate system when plotting trees.
rootPosition = frozenset([‘top’, ‘bottom’, ‘left’, ‘right’]) default: ‘top’
sweepDirection = frozenset([‘+’, ‘-‘]) default: ‘-‘
Has functionality for interpreting width/depth to actual postions given rootPostion.
Given a logical datum (logical top left) and a logical box this returns logical bottom dead centre of a box.
Given a logical datum (logical top left) and a logical box this returns physical bottom dead centre of a box.
Given a logical point and logical box this returns a physical point that is the box datum (“upper left”).
Given a logical box this returns a Coord.Box that describes the physical box.
Returns a Coord.Box that describes the physical canvass.
Yield all possible root positions.
Yield all possible root positions.
Given a child physical datum point and a distance to next child this returns the next childs physical datum point. TODO: Remove this as redundant?
Given a logical datum (logical top left) and a logical box this returns logical ‘next’ dead centre of a box.
True if positive sweep, false otherwise.
Post-incrempents the child logical datum point (‘top-left’) given the child logical datum point and the child.bbSigma. Returns a Coord.Pt(). This takes into account the sweep direction.
Pre-incrempents the child logical datum point (‘top-left’) given the child logical datum point and the child.bbSigma. Returns a Coord.Pt(). This takes into account the sweep direction.
Given a logical datum (logical top left) and a logical box this returns logical ‘previous’ dead centre of a box.
Given an arbitrary logical point as a Coord.Pt(), this returns the physical point as a Coord.Pt(). If units is supplied then the return value will be in those units.
Returns the starting child logical datum point (‘top-left’) given the children logical datum point and the children.bbSigma. Returns a Coord.Pt(). This takes into account the sweep direction.
Given a logical datum (logical top left) and a logical box this returns logical top dead centre of a box.
Given a logical datum (logical top left) and a logical box this returns physical top dead centre of a box.