How do we position labels using linear algebra? My save/updateTextPosition() code is buggy.
The general problem is this: given a label $L$ of a moveable / repositionable arrow $A : x \to y$ how do you position $L$ when $x$ or $y$ move so that overall the movement of $L$ is linearly proportional, and continuous movement of $A$ means continuous movement of $L$.
I guess we need a map of the plane $f : \Bbb{R}^2 \to \Bbb{R}^2$ such that $f(x) = x', f(y) = y'$ where $A' : x' \to y'$ is a copy of the arrow with updated position (whether that means the user dragged it with the mouse or user code called x.setPos(new_pos). What other properties must $f$ have other than linearity to achieve a good label movement?
And what does the full algorithm look like to handle any $(x,y)$, $(x', y')$ in an visually elegant manner? For example, how would you handle the case when $x = y$ because if you take a measurement then of "proportionality" of the label position, you'll get divide-by-zeros.
Or am I doing this all wrong and there's a much better way to do it?

I don't see how you can possibly solve this with a single map of the plane to itself. The positioning of a label in a diagram ought to depend not only on the position and orientation of what you're labelling, but on the positions of the other elements of the diagram, avoiding collisions and ambiguity.