0xfe/vexflow — pull request #191 by Silverwolf90 (2014-03-27 05:35:00+00:00)
Title: StaveNote parts refactor - convert NoteHead to first class element

So I did some refactoring in `StaveNote`... I know you mentioned you're out of town, so no rush to review this :)

`NoteHead`s are now created on construction through a `buildNoteHeads()` method. Note that this method has to be called in `setKeyStyle()` because all the style data for each notehead lives in `StaveNote` and so the noteheads have to be rebuilt everytime they change. I should add a `NoteHead.setStyle()` and have `StaveNote.setKeyStyle()` delegate rather than storing indices of each key with the corresponding style.

The `NoteHeads` get their `y` value provided when `setStave()` is called. Ultimately, I think that the `ys` array should be removed from `StaveNote` and that `getYs()` and `setYs()` should access and mutate the `NoteHead`s directly rather than maintaining the y values in two separate places.

The `x` value for each `NoteHead` is added applied within `StaveNote.draw()`, trying to put this in preformat doesn't work because it's preformats before the `TickContexts` have x values.

I had to refactor `StaveNote.draw()` significantly. Which led me to extracting a bunch of functions:
* `getNoteHeadBeginX()`
* `getNoteHeadEndX()`
* `getNoteHeadBounds()` - returns an object with the y value and staff line for the top and bottom notehead
* `drawLedgerLines()`
* `drawNoteHeads()`
* `drawFlag()`
* `drawModifiers()`

I extracted methods out of `StaveNote.init()` as well:
* `calculateKeyProps()`
* `autoStem()`

I plan on implementing `Stem` and `Flag` as first class elements as well. But I figure I'd throw this up as a preliminary request so you can code review and tell me if I'm on the right/wrong track.