View Single Post
[This script has now been replaced by a more general-purpose tool, which does not require Launchbar]

The hierarchical option in Automatic Layout currently bunches parents towards each other, skewing them artificially and asymmetrically away from the centres of their child ranges.

For hierarchies with straight-line connections between nodes, this may give a pleasingly unbuttoned 'botanical' style.

For orthogonal connections, however, it simply damages the signal-to-noise ratio:
  1. Introducing artifacts like jagged three stage connections between a parent and a single child,
  2. imposing asymmetries which are not present in the user's data,
  3. sometimes even making connectors overlap, so that it becomes unclear which parent is attached to which child.
This draft script aims to make orthogonal hierarchies clearer and more legible by properly centring parents over their child ranges, eliminating spurious asymmetries, and ensuring that the link between a parent and a single child is always a simple straight line.

Automatic Layout's standard result – the noise, asymmetries and ambiguities are rooted in the fact that this is a non-orthogonal layout merely decorated with orthogonal connectors – a diagram in drag:



Converted (by the script) to a true orthogonal layout – the structure of the user's data is revealed clearly, without noise, distortion or ambiguity:



The script first runs the built-in Automatic Layout, so that it can discover the order of siblings (the OG Applescript library doesn't offer us this information).
The layout of the tree is then improved by moving shapes to left or right (up and down in the case of a left-to-right tree), to eliminate the unfortunate 'bunching', artifacts, occasional ambiguity, and imposed asymmetry introduced by the Graphviz layout engine.

(Note that OmniGraffle has a bug in which connectors are not always automatically updated after shapes have been moved by applescript - the final flickering is a nudging of each shape to force OG to update all the connectors. This can be switched off by editing:
property pblnUpdateLinks : true
to
property pblnUpdateLinks : false

To force an update manually - use Cmd A to select the whole diagram, and move it slightly with the mouse. Any misplaced connectors will then jump to their correct position).

Still a draft script, and it has only been tested on the templates and styles which I work with personally, so it's important to back up your diagrams before testing it.

LaunchBar

If the script is selected in LaunchBar, you can speed up tree-work by tapping the space bar and entering one or more commands, using the following syntax to:
  1. Adjust the width and/or height of all shapes in visible layers,
  2. switch link updating on or off (i.e. override the default value of pblnUpdateLinks),
  3. adjust the amount of space between rows (rank separation) (in points, not inches),
  4. adjust the object separation (also in points),
  5. change the direction of the layout – from top, left, right, or bottom,
  6. change the type of all lines in visible layers, e.g. switch between straight lines and orthogonal links,
  7. change the magnets of all shapes in visible layers (magnets are adjusted automatically by the script when orthogonal trees switch between vertical and horizontal directions).

s={150,100} or size={150,100}
w=150 or width=150
h=100 or height=100

u=f or updatelinks=false
u=t or updatelinks=true

rank separation: r=30 or rank=30 (NB in points, not inches)
object separation: o=15 or object=15 (ditto)

link type: l=[b|c|o|s] or links=[bezier|curved|orthogonal|straight]

direction of layout d=t|l|r|b or direction=(from) top|left|right|bottom

magnets: m={} or just m= will clear all magnets from all shapes in the visible layers.
m=[ns|ew|nsew|corners|c|8] will set magnets of shapes in visible layers to North-South, East-West, NSEW, all four corners, or all corners + all sides.

arrow heads on the lines in the visible layers:
a=[h|t|b|n] or arrows=[head|tail|both|none]

multiple commands should be separated by a single space
e.g.
d=l l=o r=30 o=0
Relative values:

Values for the w, h, r, and o commands can be prefixed with "+" or "-" to make them relative.
To increase the rank separation by 10 points:
r=+10
or to shrink the height of all shapes (in visible layers) by 10 points:
h=-10

--

Last edited by RobTrew; 2011-11-03 at 06:23 AM.. Reason: Script replaced by a more general tool