import { StaffEntryLink } from "../VoiceData/StaffEntryLink" ; import { GraphicalStaffEntry } from "./GraphicalStaffEntry" ; import { GraphicalNote } from "./GraphicalNote" ; /**
 * The graphical counterpart of a [[StaffEntryLink]].
 * Used for linked voices.
 */ export class GraphicalStaffEntryLink { private staffEntryLink : StaffEntryLink ; private graphicalLinkedStaffEntries : GraphicalStaffEntry [ ] = [ ] ; constructor ( staffEntryLink ) { this . staffEntryLink = staffEntryLink ; this . initialize ( ) ; } public get GetStaffEntryLink ( ) : StaffEntryLink { return this . staffEntryLink ; } public get GraphicalLinkedStaffEntries ( ) : GraphicalStaffEntry [ ] { return this . graphicalLinkedStaffEntries ; } public set GraphicalLinkedStaffEntries ( value ) { this . graphicalLinkedStaffEntries = value ; } public isFilled ( ) { for ( let i = 0 ; i < this . graphicalLinkedStaffEntries . length ; i ++ ) { if ( ! this . graphicalLinkedStaffEntries [ i ] ) { return false ; } } return true ; } param graphicalStaffEntry returns { any } public getLinkedStaffEntriesGraphicalNotes ( graphicalStaffEntry ) { if ( this . graphicalLinkedStaffEntries . indexOf ( graphicalStaffEntry ) !== - 1 ) { const notes = [ ] ; for ( let idx = 0 , len = this . graphicalLinkedStaffEntries . length ; idx < len ; ++ idx ) { const graphicalLinkedStaffEntry = this . graphicalLinkedStaffEntries [ idx ] ; for ( const gve of graphicalLinkedStaffEntry . graphicalVoiceEntries ) { for ( const graphicalNote of gve . notes ) { if ( graphicalNote . sourceNote . ParentStaffEntry . Link && graphicalNote . sourceNote . ParentVoiceEntry === this . staffEntryLink . GetVoiceEntry ) { notes . push ( graphicalNote ) ; } } } } return notes ; } return undefined ; } private initialize ( ) { for ( let idx = 0 , len = this . staffEntryLink . LinkStaffEntries . length ; idx < len ; ++ idx ) { this . graphicalLinkedStaffEntries . push ( undefined ) ; } } }