import { Note } from "../../Note" ; import { Fraction } from "../../../../Common/DataObjects/Fraction" ; import { PlacementEnum } from "../AbstractExpression" ; export class Slur { constructor ( ) { } private startNote : Note ; private endNote : Note ; public PlacementXml : PlacementEnum ; public get StartNote ( ) : Note { return this . startNote ; } public set StartNote ( value ) { this . startNote = value ; } public get EndNote ( ) : Note { return this . endNote ; } public set EndNote ( value ) { this . endNote = value ; } public startNoteHasMoreStartingSlurs ( ) { if ( ! this . startNote ) { return false ; } for ( let idx = 0 , len = this . startNote . NoteSlurs . length ; idx < len ; ++ idx ) { const slur = this . startNote . NoteSlurs [ idx ] ; if ( slur !== this && slur . StartNote === this . startNote ) { return true ; } } return false ; } public endNoteHasMoreEndingSlurs ( ) { if ( ! this . endNote ) { return false ; } for ( let idx = 0 , len = this . endNote . NoteSlurs . length ; idx < len ; ++ idx ) { const slur = this . endNote . NoteSlurs [ idx ] ; if ( slur !== this && slur . EndNote === this . endNote ) { return true ; } } return false ; } public isCrossed ( ) { return ( this . startNote . ParentStaffEntry . ParentStaff !== this . endNote . ParentStaffEntry . ParentStaff ) ; } public isSlurLonger ( ) { if ( ! this . endNote || ! this . startNote ) { return false ; } const length = Fraction . minus ( this . endNote . getAbsoluteTimestamp ( ) , this . startNote . getAbsoluteTimestamp ( ) ) ; for ( let idx = 0 , len = this . startNote . NoteSlurs . length ; idx < len ; ++ idx ) { const slur = this . startNote . NoteSlurs [ idx ] ; if ( slur !== this && slur . EndNote !== undefined && slur . StartNote !== undefined && Fraction . minus ( slur . EndNote . getAbsoluteTimestamp ( ) , slur . StartNote . getAbsoluteTimestamp ( ) ) . CompareTo ( length ) === - 1 ) { return true ; } } for ( let idx = 0 , len = this . endNote . NoteSlurs . length ; idx < len ; ++ idx ) { const slur = this . endNote . NoteSlurs [ idx ] ; if ( slur !== this && slur . EndNote !== undefined && slur . StartNote !== undefined && Fraction . minus ( slur . EndNote . getAbsoluteTimestamp ( ) , slur . StartNote . getAbsoluteTimestamp ( ) ) . CompareTo ( length ) ) { return true ; } } return false ; } }