import Vex from "vexflow" ; import { GraphicalOctaveShift } from "../GraphicalOctaveShift" ; import { OctaveShift , OctaveEnum } from "../../VoiceData/Expressions/ContinuousExpressions/OctaveShift" ; import { BoundingBox } from "../BoundingBox" ; import { GraphicalStaffEntry } from "../GraphicalStaffEntry" ; import { VexFlowVoiceEntry } from "./VexFlowVoiceEntry" ; import log from "loglevel" ; /**
 * The vexflow adaptation of a graphical shift.
 */ export class VexFlowOctaveShift extends GraphicalOctaveShift { /** Defines the note where the octave shift starts */ public startNote : Vex . Flow . StemmableNote ; /** Defines the note where the octave shift ends */ public endNote : Vex . Flow . StemmableNote ; /** Top or bottom of the staffline */ private position : Vex . Flow . TextBracket . Positions ; /** Supscript is a smaller text after the regular text (e.g. va after 8) */ private supscript : string ; /** Main text element */ private text : string ; param octaveShift param parent constructor ( octaveShift , parent ) { super ( octaveShift , parent ) ; switch ( octaveShift . Type ) { case OctaveEnum . VA8 : this . position = Vex . Flow . TextBracket . Positions . TOP ; this . supscript = "va" ; this . text = "8" ; break ; case OctaveEnum . MA15 : this . position = Vex . Flow . TextBracket . Positions . TOP ; this . supscript = "ma" ; this . text = "15" ; break ; case OctaveEnum . VB8 : this . position = Vex . Flow . TextBracket . Positions . BOTTOM ; this . supscript = "vb" ; this . text = "8" ; break ; case OctaveEnum . MB15 : this . position = Vex . Flow . TextBracket . Positions . BOTTOM ; this . supscript = "mb" ; this . text = "15" ; break ; default : log . error ( "Unknown or NONE octaveshift. This should not be called!" ) ; break ; } } param graphicalStaffEntry public setStartNote ( graphicalStaffEntry ) { for ( const gve of graphicalStaffEntry . graphicalVoiceEntries ) { const vve = ( gve as VexFlowVoiceEntry ) ; if ( vve ?. vfStaveNote ) { this . startNote = vve . vfStaveNote ; return true ; } } return false ; } param graphicalStaffEntry public setEndNote ( graphicalStaffEntry ) { for ( const gve of graphicalStaffEntry . graphicalVoiceEntries ) { const vve = ( gve as VexFlowVoiceEntry ) ; if ( vve ?. vfStaveNote ) { this . endNote = vve . vfStaveNote ; return true ; } } return false ; } /**
     * Get the actual vexflow text bracket used for drawing
     */ public getTextBracket ( ) { return new Vex . Flow . TextBracket ( { position : this . position , start : this . startNote , stop : this . endNote , superscript : this . supscript , text : this . text , } ) ; } }