From 8b76b2362fc820f7d170f80c87de6ca1bf894829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Bitteur?= Date: Fri, 24 May 2024 10:14:20 +0200 Subject: [PATCH] Fix for bug #732: Null glyph when dragging a fermata off of shape-board --- .../audiveris/omr/sig/inter/FermataInter.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/audiveris/omr/sig/inter/FermataInter.java b/app/src/main/java/org/audiveris/omr/sig/inter/FermataInter.java index f24c1b804..1c92adaa6 100644 --- a/app/src/main/java/org/audiveris/omr/sig/inter/FermataInter.java +++ b/app/src/main/java/org/audiveris/omr/sig/inter/FermataInter.java @@ -60,12 +60,13 @@ *

* 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. *

- * Such reference is implemented via a Relation instance. + * Such reference is implemented via a Relation instance: either a {@link FermataChordRelation} + * or a {@link FermataBarRelation}. *

- * 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 @@ -93,7 +94,7 @@ private FermataInter () /** * Creates a new FermataInter 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 */ @@ -101,7 +102,7 @@ public FermataInter (Glyph glyph, Shape shape, Double grade) { - super(glyph, glyph.getBounds(), shape, grade); + super(glyph, (glyph != null) ? glyph.getBounds() : null, shape, grade); } //~ Methods ------------------------------------------------------------------------------------ @@ -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) { @@ -279,9 +280,9 @@ private Link lookupChordLink (SystemInfo system, return null; } - final Collection chords = (shape == Shape.FERMATA_BELOW) ? stack - .getStandardChordsAbove(center, bounds) - : stack.getStandardChordsBelow(center, bounds); + final Collection 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); @@ -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; @@ -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) {