Move the 2D shape creation code into a separate method.

Change-Id: I38ccb7f98f404540f5cf3c32be27da19394475a0
Reduce scope by early bailout.

Change-Id: Icd344caf6e52ef568361078455d4e8d5cf0d40a8
Scope reduction.

Change-Id: Id677971ccd6959356a781a2d8c35ab864b35a62e
More scope reduction.

Change-Id: Ibaabf1122fb3e828c1b7b71e846911d77f312445
Move the code that creates shapes for axis titles to own method.

This change also creates a struct that keeps track of states during
shape creation, to make it easier to extract methods as necessary.

Change-Id: I0d84dbee9dba5b9c59d22e4a1be318c5e8c6c6c3