Factor out some drawing code into a superclass