OUTLINE
Overview
Alignment
Adjustments within a sync
	noteheads within a chord
	noteheads between different voices
	accidentals
Adjustments between non-sync events
Adjustments between syncs
	within a voice
	between voices
		in the meter
		not in the meter
	graphical adjustments
Stretching measures
	user specified end-of-lines
Determining number of staffs per page







One of the hardest parts of notating music is laying out the score; deciding how many measures should fall on each line, and where each note should go.  

A crucial algorithm in the Mockingbird music editor is the algorithm that automatically justifies the music notation.  When the composer has entered a rough draft of his compositition, he can cause the editor to move things around so that an integral number of measures appear on each line.  As a part of the process, the editor also spaces the elements within each measure aesthetically.

The justifier is thus responsible for the horizontal placement of all of the elements of the score.  It is not responsible for any of the vertical elements, such as the height of the beams.  Nor will it do anything that changes the meaning of the score, like changing the directions of a stem or the staff which a note falls on. 

The composer can justify the entire score, or just a few measures.  He can control the density of the justification and indicate measures that must fall at the end of a line.  The justifier will take the score as given and transform it without changing its meaning.  In particular it is restricted to only moving the horizontal position of an entity, and it must preserve the order of entities.  (There is one exception to this, which is discussed later.)

The basic algorithm of the justifier is to compact the score as densely as possible and then stretch it line by line so that an integral number of measures falls on each line.  If the composer has just selected a section of the score, only that section will be justified.  (The part that follows may be moved to the left or right, but it won't be compacted or stretched.)  

Compaction consists of two parts: rearranging the notes within a sync so that the notational symbols don't overlap, and determining the spacing between the syncs.  The first part involves exploiting a bunch of notational tricks used when note heads and accidentals are too close together to display without overlapping.  The second part involves looking at the relationship between the notes in the different syncs and trying to come up with a spacing that will be aesthetically pleasing.