Yeah, I've done some similar calculations. I think it might be a good idea to structure this in a custom control. That way you would do these calculations in the
getPreferredXXX
functions, and you get forced into a structure that then makes the drawing very easy.