Skip to content

Commit

Permalink
Fix for bug #732: Null glyph when dragging a fermata off of shape-board
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed May 24, 2024
1 parent d621754 commit 8b76b23
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions app/src/main/java/org/audiveris/omr/sig/inter/FermataInter.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@
* <p>
* An upright fermata refers to the chord in the staff right below in the containing part.
* An inverted fermata refers to the chord in the staff right above in the containing part.
* A fermata may also refer to a single or double barline, to indicate the end of a phrase.
* A fermata may also refer to a single or double bar-line, to indicate the end of a phrase.
* <p>
* Such reference is implemented via a Relation instance.
* Such reference is implemented via a Relation instance: either a {@link FermataChordRelation}
* or a {@link FermataBarRelation}.
* <p>
* Initially, the fermata arc and the fermata dot were kept as separated inters because they were
* often too distant to be grabbed by the {@link SymbolsBuilder}.
* History: Initially, the fermata arc and the fermata dot were kept as separated inters
* because they were often too distant to be grabbed by the {@link SymbolsBuilder}.
* Since the SymbolsBuilder now accepts larger gaps, there is no more need for these member inters.
*
* @author Hervé Bitteur
Expand Down Expand Up @@ -93,15 +94,15 @@ private FermataInter ()
/**
* Creates a new <code>FermataInter</code> object.
*
* @param glyph the fermata glypg (arc + dot)
* @param glyph the fermata glyph (arc + dot)
* @param shape the fermata shape (FERMATA or FERMATA_BELOW)
* @param grade the interpretation quality
*/
public FermataInter (Glyph glyph,
Shape shape,
Double grade)
{
super(glyph, glyph.getBounds(), shape, grade);
super(glyph, (glyph != null) ? glyph.getBounds() : null, shape, grade);
}

//~ Methods ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -244,8 +245,8 @@ private Link lookupBarlineLink (SystemInfo system,

// Check vertical distance to bar/staff
final Scale scale = system.getSheet().getScale();
final int maxDy = scale.toPixels(
(Scale.Fraction) constants.getConstant(constants.maxFermataDy, profile));
final int maxDy = scale
.toPixels((Scale.Fraction) constants.getConstant(constants.maxFermataDy, profile));
final int dyStaff = staff.distanceTo(center);

if (dyStaff > maxDy) {
Expand Down Expand Up @@ -279,9 +280,9 @@ private Link lookupChordLink (SystemInfo system,
return null;
}

final Collection<AbstractChordInter> chords = (shape == Shape.FERMATA_BELOW) ? stack
.getStandardChordsAbove(center, bounds)
: stack.getStandardChordsBelow(center, bounds);
final Collection<AbstractChordInter> chords =
(shape == Shape.FERMATA_BELOW) ? stack.getStandardChordsAbove(center, bounds)
: stack.getStandardChordsBelow(center, bounds);

// Look for a suitable chord related to this fermata
AbstractChordInter chord = AbstractChordInter.getClosestChord(chords, center);
Expand All @@ -294,8 +295,8 @@ private Link lookupChordLink (SystemInfo system,

// If chord is mirrored, select the closest vertically
if (chord.getMirror() != null) {
double dyMirror = Math.sqrt(
GeoUtil.ptDistanceSq(chord.getMirror().getBounds(), center.x, center.y));
double dyMirror = Math
.sqrt(GeoUtil.ptDistanceSq(chord.getMirror().getBounds(), center.x, center.y));

if (dyMirror < dyChord) {
dyChord = dyMirror;
Expand All @@ -306,13 +307,13 @@ private Link lookupChordLink (SystemInfo system,

// Check vertical distance between fermata and chord
final Scale scale = system.getSheet().getScale();
final int maxDy = scale.toPixels(
(Scale.Fraction) constants.getConstant(constants.maxFermataDy, profile));
final int maxDy = scale
.toPixels((Scale.Fraction) constants.getConstant(constants.maxFermataDy, profile));

if (dyChord > maxDy) {
// Check vertical distance between fermata and staff
final Staff chordStaff = (shape == Shape.FERMATA) ? chord.getTopStaff()
: chord.getBottomStaff();
final Staff chordStaff =
(shape == Shape.FERMATA) ? chord.getTopStaff() : chord.getBottomStaff();
final int dyStaff = chordStaff.distanceTo(center);

if (dyStaff > maxDy) {
Expand Down

0 comments on commit 8b76b23

Please sign in to comment.