import { MusicSystem } from "../MusicSystem" ; import { SystemLinesEnum } from "../SystemLinesEnum" ; import { SystemLinePosition } from "../SystemLinePosition" ; import { GraphicalMeasure } from "../GraphicalMeasure" ; import { SystemLine } from "../SystemLine" ; import { VexFlowStaffLine } from "./VexFlowStaffLine" ; import { VexFlowMeasure } from "./VexFlowMeasure" ; import { VexFlowConverter } from "./VexFlowConverter" ; import { StaffLine } from "../StaffLine" ; import { EngravingRules } from "../EngravingRules" ; import { VexFlowInstrumentBracket } from "./VexFlowInstrumentBracket" ; import { VexFlowInstrumentBrace } from "./VexFlowInstrumentBrace" ; import { SkyBottomLineCalculator } from "../SkyBottomLineCalculator" ; export class VexFlowMusicSystem extends MusicSystem { constructor ( id , rules ) { super ( id ) ; this . rules = rules ; } public calculateBorders ( rules ) { if ( this . staffLines . length === 0 ) { return ; } const width = this . calcBracketsWidth ( ) ; this . boundingBox . BorderLeft = - width ; this . boundingBox . BorderMarginLeft = - width ; this . boundingBox . XBordersHaveBeenSet = true ; const topSkyBottomLineCalculator = this . staffLines [ 0 ] . SkyBottomLineCalculator ; const top = topSkyBottomLineCalculator . getSkyLineMin ( ) ; this . boundingBox . BorderTop = top ; this . boundingBox . BorderMarginTop = top ; const lastStaffLine = this . staffLines [ this . staffLines . length - 1 ] ; const bottomSkyBottomLineCalculator = lastStaffLine . SkyBottomLineCalculator ; const bottom = bottomSkyBottomLineCalculator . getBottomLineMax ( ) + lastStaffLine . PositionAndShape . RelativePosition . y ; this . boundingBox . BorderBottom = bottom ; this . boundingBox . BorderMarginBottom = bottom ; this . boundingBox . XBordersHaveBeenSet = true ; this . boundingBox . YBordersHaveBeenSet = true ; } param xPosition param lineWidth param lineType param linePosition param musicSystem param topMeasure param bottomMeasure protected createSystemLine ( xPosition , lineWidth , lineType , linePosition , musicSystem , topMeasure , bottomMeasure = undefined ) { const vfTopMeasure = topMeasure as VexFlowMeasure ; let renderInitialLine = false ; if ( bottomMeasure ) { renderInitialLine = true ; ( bottomMeasure as VexFlowMeasure ) . lineTo ( topMeasure as VexFlowMeasure , VexFlowConverter . line ( lineType , linePosition ) ) ; ( bottomMeasure as VexFlowMeasure ) . addMeasureLine ( lineType , linePosition ) ; if ( lineType === SystemLinesEnum . DotsBoldBoldDots ) { const nextIndex = bottomMeasure . ParentStaffLine . Measures . indexOf ( bottomMeasure ) + 1 ; const nextBottomMeasure = bottomMeasure . ParentStaffLine . Measures [ nextIndex ] as VexFlowMeasure ; const nextTopMeasure = topMeasure . ParentStaffLine . Measures [ nextIndex ] as VexFlowMeasure ; if ( nextBottomMeasure && nextTopMeasure ) { nextBottomMeasure . lineTo ( nextTopMeasure , VexFlowConverter . line ( SystemLinesEnum . BoldThinDots , linePosition ) ) ; nextBottomMeasure . addMeasureLine ( SystemLinesEnum . BoldThinDots , linePosition ) ; } } } if ( vfTopMeasure ) { vfTopMeasure . addMeasureLine ( lineType , linePosition , renderInitialLine ) ; } return new SystemLine ( lineType , linePosition , this , topMeasure , bottomMeasure ) ; } param firstStaffLine param lastStaffLine protected createInstrumentBracket ( firstStaffLine , lastStaffLine ) { const firstVexStaff = ( firstStaffLine as VexFlowStaffLine ) ; const lastVexStaff = ( lastStaffLine as VexFlowStaffLine ) ; const vexFlowBracket = new VexFlowInstrumentBrace ( firstVexStaff , lastVexStaff ) ; this . InstrumentBrackets . push ( vexFlowBracket ) ; return ; } param firstStaffLine param lastStaffLine param recursionDepth protected createGroupBracket ( firstStaffLine , lastStaffLine , recursionDepth ) { const firstVexStaff = ( firstStaffLine as VexFlowStaffLine ) ; const lastVexStaff = ( lastStaffLine as VexFlowStaffLine ) ; if ( recursionDepth === 0 ) { const vexFlowBracket = new VexFlowInstrumentBracket ( firstVexStaff , lastVexStaff , recursionDepth ) ; this . GroupBrackets . push ( vexFlowBracket ) ; } else { const vexFlowBrace = new VexFlowInstrumentBrace ( firstVexStaff , lastVexStaff , recursionDepth ) ; this . GroupBrackets . push ( vexFlowBrace ) ; } return ; } }