Custom Edges, BlowBaseEdge & Edge Toolbar
An EdgeTemplate draws every edge itself: BlowBaseEdge lays down the path and its
arrowheads in a colour taken from the edge's data, and BlowEdgeText puts the label on a plate of
the same colour. Selecting an edge opens a BlowEdgeToolbar to recolour or delete it.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Click an edge to select it: it thickens, and a toolbar opens above its label. ๐จ gives it the next colour - path, arrowheads and label plate together - and ร deletes it.
- Untick Pass on arrowheads: the edges lose their heads, although every edge still asks for one. Tick it again and the yes edge has one at each end.
- Untick Coloured label plates to fall back to
BlowBaseEdge's own label on the theme's plate. - Tick Wide hit area, then click a little beside an edge: it is selected from further away than before.
- Drag from a handle to another node: the line you drag is a smooth step, and the new edge is drawn by the same template, in the theme's colour until you recolour it.
How it works
EdgeTemplatereceives aBlowEdgeContextper edge - theEdge, its computedPathand label point (LabelX,LabelY), andMarkerStartUrl/MarkerEndUrl- and renders SVG. Around it the canvas still draws the focusable, selectable edge group and its own invisible click path.BlowBaseEdgetakes thePath, aStroke(here fromEdge.Data) andStrokeWidth(1.5 by default; 2 here, 3 when selected).MarkerStartandMarkerEndtake aurl(#...)reference: passing the context's on draws the heads the edge'sMarkerStartandMarkerEndask for, in the edge's stroke colour; passing null draws none.InteractionWidth(14) is the width ofBlowBaseEdge's invisible click path, in screen pixels at any zoom. The canvas's own click path,BlowEdge.InteractionWidthwide, stays underneath, so only a wider value makes a difference.BlowEdgeTextdraws a label at any point:X,YandLabel, withStylefor the text,BgStylefor the plate, andPaddingX,PaddingYandBorderRadiusto shape it (4, 2 and 3 by default).BlowBaseEdge'sLabeluses it with those defaults.EdgeLabelTemplaterenders HTML at each label point in a layer that is not zoomed, so the toolbar keeps its size;BlowEdgeToolbarstyles it and keeps its clicks from reaching the pane.DefaultEdgeTypeandConnectionLineTypemake the edges you draw, and the line you draw them with, smooth steps.