import { Note } from "../VoiceData/Note" ; import { Fraction } from "../../Common/DataObjects/Fraction" ; import { KeyInstruction } from "../VoiceData/Instructions/KeyInstruction" ; import { ClefInstruction } from "../VoiceData/Instructions/ClefInstruction" ; import { OctaveEnum } from "../VoiceData/Expressions/ContinuousExpressions/OctaveShift" ; import { AccidentalEnum , Pitch } from "../../Common/DataObjects/Pitch" ; import { GraphicalObject } from "./GraphicalObject" ; import { MusicSheetCalculator } from "./MusicSheetCalculator" ; import { BoundingBox } from "./BoundingBox" ; import { GraphicalVoiceEntry } from "./GraphicalVoiceEntry" ; import { GraphicalMusicPage } from "./GraphicalMusicPage" ; import { EngravingRules } from "./EngravingRules" ; /**
 * The graphical counterpart of a [[Note]]
 */ export class GraphicalNote extends GraphicalObject { constructor ( note , parent , rules , graphicalNoteLength = undefined ) { super ( ) ; this . sourceNote = note ; this . parentVoiceEntry = parent ; this . PositionAndShape = new BoundingBox ( this , parent . PositionAndShape ) ; if ( graphicalNoteLength ) { this . graphicalNoteLength = graphicalNoteLength ; } else { this . graphicalNoteLength = note . Length ; } this . numberOfDots = this . calculateNumberOfNeededDots ( this . graphicalNoteLength ) ; this . rules = rules ; this . rules . addGraphicalNoteToNoteMap ( note , this ) ; } public sourceNote : Note ; public DrawnAccidental : AccidentalEnum = AccidentalEnum . NONE ; public graphicalNoteLength : Fraction ; public parentVoiceEntry : GraphicalVoiceEntry ; public numberOfDots : number ; public rules : EngravingRules ; public staffLine : number ; public baseFingeringXOffset : number ; public baseStringNumberXOffset : number ; public lineShift : number = 0 ; public Transpose ( keyInstruction , activeClef , halfTones , octaveEnum ) { let transposedPitch = this . sourceNote . Pitch ; if ( MusicSheetCalculator . transposeCalculator ) { transposedPitch = MusicSheetCalculator . transposeCalculator . transposePitch ( this . sourceNote . Pitch , keyInstruction , halfTones ) ; } return transposedPitch ; } param fraction returns { number } private calculateNumberOfNeededDots ( fraction ) { if ( ! this . sourceNote || ! this . sourceNote . NoteTuplet ) { return fraction . calculateNumberOfNeededDots ( ) ; } return 0 ; } public get ParentMusicPage ( ) : GraphicalMusicPage { return this . parentVoiceEntry . parentStaffEntry . parentMeasure . ParentMusicSystem . Parent ; } /** Get a GraphicalNote from a Note. Use osmd.rules as the second parameter (instance reference).
     *  Also more easily available via osmd.rules.GNote(note). */ public static FromNote ( note , rules ) { return rules . NoteToGraphicalNoteMap . getValue ( note . NoteToGraphicalNoteObjectId ) ; } }