The glyph package deals with assemblies of sections of foreground pixels that are matched against predefined shapes, knowing that these glyphs can be self-standing symbols (such as a clef) or leaves in larger constructions (such as hote heads and stem in a chord).

Glyph Data Model

Glyph Data Model

Glyph Life Cycle

Creation
Insertion

This is done by {@link omr.glyph.GlyphsBuilder#addGlyph} which performs the following actions:

  1. If the glyph is a compound (made of other glyphs) then its parts are made pointing back to the compound, they are removed from the system collection of glyphs, and their member sections are made pointing to the compound. Doing so, the former parts are no longer "active", only the compound is "active".
  2. The glyph is recorded in the lag, and if found identical to some existing glyph, the existing glyph is returned, otherwise this new glyph is recorded and assigned a lag-based unique ID.
  3. Finally, the glyph is recorded in the system collection of glyphs.
Deletion

A (recorded) glyph is never totally deleted, it can be reused then by chance an identical glyph is inserted into the lag. This allows to cache the glyph parameters, moments, forbidden shapes, OCR content, etc.

What {@link omr.glyph.GlyphsBuilder#removeGlyph} does is simply:

  1. Removing the glyph from the system collection of glyphs.
  2. Cutting the link from its member sections, making this glyph "inactive".

Glyph display

A glyph is made visible via its member sections (except for the "selected" glyph(s) which use a specific highlighting mode). Several glyphs may contain the same section, but since the section can point back to at most one glyph, there is at most one "active" glyph for any given section, the other glyphs are thus "inactive".

While stand-alone (i.e. non-member) sections are displayed using a set of 3 different colors, so that adjacent sections can be differentiated, member-sections are colorized with the same color imposed by their containing glyph. Usually, the glyph color is determined by the glyph assigned shape.