import Vex from "vexflow" ; import { IGraphicalSymbolFactory } from "../../Interfaces/IGraphicalSymbolFactory" ; import { MusicSystem } from "../MusicSystem" ; import { VexFlowMusicSystem } from "./VexFlowMusicSystem" ; import { Staff } from "../../VoiceData/Staff" ; import { StaffLine } from "../StaffLine" ; import { SourceMeasure } from "../../VoiceData/SourceMeasure" ; import { GraphicalMeasure } from "../GraphicalMeasure" ; import { VexFlowMeasure } from "./VexFlowMeasure" ; import { SourceStaffEntry } from "../../VoiceData/SourceStaffEntry" ; import { GraphicalStaffEntry } from "../GraphicalStaffEntry" ; import { VexFlowStaffEntry } from "./VexFlowStaffEntry" ; import { Note } from "../../VoiceData/Note" ; import { ClefInstruction } from "../../VoiceData/Instructions/ClefInstruction" ; import { OctaveEnum } from "../../VoiceData/Expressions/ContinuousExpressions/OctaveShift" ; import { GraphicalNote } from "../GraphicalNote" ; import { Pitch } from "../../../Common/DataObjects/Pitch" ; import { VexFlowGraphicalNote } from "./VexFlowGraphicalNote" ; import { Fraction } from "../../../Common/DataObjects/Fraction" ; import { GraphicalChordSymbolContainer } from "../GraphicalChordSymbolContainer" ; import { GraphicalLabel } from "../GraphicalLabel" ; import { EngravingRules } from "../EngravingRules" ; import { TechnicalInstruction } from "../../VoiceData/Instructions/TechnicalInstruction" ; import { GraphicalVoiceEntry } from "../GraphicalVoiceEntry" ; import { VoiceEntry } from "../../VoiceData/VoiceEntry" ; import { VexFlowVoiceEntry } from "./VexFlowVoiceEntry" ; import { VexFlowConverter } from "./VexFlowConverter" ; import { VexFlowTabMeasure } from "./VexFlowTabMeasure" ; import { VexFlowStaffLine } from "./VexFlowStaffLine" ; import { KeyInstruction } from "../../VoiceData/Instructions/KeyInstruction" ; import { VexFlowMultiRestMeasure } from "./VexFlowMultiRestMeasure" ; export class VexFlowGraphicalSymbolFactory implements IGraphicalSymbolFactory { param page param systemIndex returns { VexFlowMusicSystem } public createMusicSystem ( systemIndex , rules ) { return new VexFlowMusicSystem ( systemIndex , rules ) ; } param parentSystem param parentStaff returns { VexFlowStaffLine } public createStaffLine ( parentSystem , parentStaff ) { return new VexFlowStaffLine ( parentSystem , parentStaff ) ; } param sourceMeasure param staff returns { VexFlowMeasure } public createGraphicalMeasure ( sourceMeasure , staff , isTabMeasure = false ) { return new VexFlowMeasure ( staff , sourceMeasure , undefined ) ; } param sourceMeasure param staff returns { VexFlowMultiRestMeasure } public createMultiRestMeasure ( sourceMeasure , staff , staffLine ? ) { return new VexFlowMultiRestMeasure ( staff , sourceMeasure , staffLine ) ; } param sourceMeasure param staff returns { VexFlowTabMeasure } public createTabStaffMeasure ( sourceMeasure , staff ) { return new VexFlowTabMeasure ( staff , sourceMeasure ) ; } param staffLine returns { VexFlowMeasure } public createExtraGraphicalMeasure ( staffLine ) { const extraGraphicalMeasure = new VexFlowMeasure ( staffLine . ParentStaff , undefined , staffLine ) ; extraGraphicalMeasure . IsExtraGraphicalMeasure = true ; extraGraphicalMeasure . ExtraGraphicalMeasurePreviousMeasure = staffLine . Measures . last ( ) ; return extraGraphicalMeasure ; } param sourceStaffEntry param measure returns { VexFlowStaffEntry } public createStaffEntry ( sourceStaffEntry , measure ) { return new VexFlowStaffEntry ( < VexFlowMeasure > measure , sourceStaffEntry , undefined ) ; } public createVoiceEntry ( parentVoiceEntry , parentStaffEntry ) { return new VexFlowVoiceEntry ( parentVoiceEntry , parentStaffEntry ) ; } param note param numberOfDots param graphicalStaffEntry param activeClef param octaveShift returns { GraphicalNote } public createNote ( note , graphicalVoiceEntry , activeClef , octaveShift = OctaveEnum . NONE , rules , graphicalNoteLength = undefined ) { return new VexFlowGraphicalNote ( note , graphicalVoiceEntry , activeClef , octaveShift , rules , graphicalNoteLength ) ; } param note param numberOfDots param graphicalVoiceEntry param activeClef param octaveShift returns { GraphicalNote } public createGraceNote ( note , graphicalVoiceEntry , activeClef , rules , octaveShift = OctaveEnum . NONE ) { return new VexFlowGraphicalNote ( note , graphicalVoiceEntry , activeClef , octaveShift , rules ) ; } param graphicalNote param pitch public addGraphicalAccidental ( graphicalNote , pitch ) { const note = ( graphicalNote as VexFlowGraphicalNote ) ; note . setAccidental ( pitch ) ; } param tiedNote param graphicalStaffEntry public addFermataAtTiedEndNote ( tiedNote , graphicalStaffEntry ) { return ; } param graphicalStaffEntry param clefInstruction public createInStaffClef ( graphicalStaffEntry , clefInstruction ) { const se = graphicalStaffEntry as VexFlowStaffEntry ; const vfClefParams = VexFlowConverter . Clef ( clefInstruction , "small" ) ; se . vfClefBefore = new Vex . Flow . ClefNote ( vfClefParams . type , vfClefParams . size , vfClefParams . annotation ) ; return ; } param sourceStaffEntry param graphicalStaffEntry param transposeHalftones public createChordSymbols ( sourceStaffEntry , graphicalStaffEntry , keyInstruction , transposeHalftones ) { const rules = graphicalStaffEntry . parentMeasure . parentSourceMeasure . Rules ; let xShift = 0 ; const chordSymbolSpacing = rules . ChordSymbolXSpacing ; for ( const chordSymbolContainer of sourceStaffEntry . ChordContainers ) { const graphicalChordSymbolContainer = new GraphicalChordSymbolContainer ( chordSymbolContainer , graphicalStaffEntry . PositionAndShape , rules . ChordSymbolTextHeight , keyInstruction , transposeHalftones , graphicalStaffEntry . parentMeasure . parentSourceMeasure . Rules ) ; const graphicalLabel = graphicalChordSymbolContainer . GraphicalLabel ; graphicalLabel . PositionAndShape . RelativePosition . y -= rules . ChordSymbolYOffset ; graphicalLabel . PositionAndShape . RelativePosition . x += xShift ; graphicalLabel . setLabelPositionAndShapeBorders ( ) ; graphicalChordSymbolContainer . PositionAndShape . calculateBoundingBox ( ) ; graphicalStaffEntry . graphicalChordContainers . push ( graphicalChordSymbolContainer ) ; xShift += graphicalLabel . PositionAndShape . Size . width + chordSymbolSpacing ; } } param technicalInstruction param graphicalStaffEntry public createGraphicalTechnicalInstruction ( technicalInstruction , graphicalStaffEntry ) { return ; } }