How a parent view can control the drawing of it's children when they are not aware of each other but must share a common canvas
<p>My apologies if the question title is not very clear.  Difficult to describe in a sentence!</p>

<p>I have a view which contains a custom view which implements a graph plot.  It also contains a cursor which the user can drag over the graph to get further data about the points of the graph.  Imagine a sine wave with a cross hair which draws vertical and horizantal lines which intersect the graph.  By dragging the vertical line, the user can see detailed information about the data point which is intersected by the horizantal line. </p>

<p>My problem is that my current design follows good OOP principles, which I'd like to maintain, in that the graph and the cross hair have no knowledge of each other.  The only common point is the parent view class.  </p>

<p>a.  The cross hair ideally should draw on the canvas of the graph.  </p>

<p>b.  When the graph redraws, the cross hair should also redraw.  </p>

<p>I can create an Interface to describe an onDrawListener which I would fire from within the onDraw method of the graph.  Any declared callbacks to the interface would be passed a reference to the graph canvas.  The parent view can then call the draw method of the cross hair, passing the canvas reference in as an argument.</p>

<p>However, this just feels wrong and I'm wondering if there is a more elegant pattern to achieve this.  The only alternative I can see is to make the cross hair a private class of the graph but I lose some elegance and reusability.</p>

<p>I'm hoping it's nothing obvious as I've spent quite some time thinking this through :)</p>
