|
@@ -17,7 +17,7 @@ import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
|
|
|
import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
|
|
|
import {SystemLinesEnum} from "./SystemLinesEnum";
|
|
|
export class MusicSystemBuilder {
|
|
|
- private measureList: List<List<StaffMeasure>>;
|
|
|
+ private measureList: StaffMeasure[][];
|
|
|
private graphicalMusicSheet: GraphicalMusicSheet;
|
|
|
private currentMusicPage: GraphicalMusicPage;
|
|
|
private currentPageHeight: number;
|
|
@@ -32,7 +32,7 @@ export class MusicSystemBuilder {
|
|
|
private globalSystemIndex: number = 0;
|
|
|
private leadSheet: boolean = false;
|
|
|
private symbolFactory: IGraphicalSymbolFactory;
|
|
|
- public initialize(graphicalMusicSheet: GraphicalMusicSheet, measureList: List<List<StaffMeasure>>,
|
|
|
+ public initialize(graphicalMusicSheet: GraphicalMusicSheet, measureList: StaffMeasure[][],
|
|
|
numberOfStaffLines: number, symbolFactory: IGraphicalSymbolFactory): void {
|
|
|
this.leadSheet = graphicalMusicSheet.LeadSheet;
|
|
|
this.graphicalMusicSheet = graphicalMusicSheet;
|
|
@@ -40,7 +40,7 @@ export class MusicSystemBuilder {
|
|
|
this.measureList = measureList;
|
|
|
this.symbolFactory = symbolFactory;
|
|
|
this.currentMusicPage = this.createMusicPage();
|
|
|
- this.currentPageHeight = 0.0f;
|
|
|
+ this.currentPageHeight = 0.0;
|
|
|
this.numberOfVisibleStaffLines = numberOfStaffLines;
|
|
|
this.activeRhythm = new Array(this.numberOfVisibleStaffLines);
|
|
|
this.activeKeys = new Array(this.numberOfVisibleStaffLines);
|
|
@@ -48,8 +48,8 @@ export class MusicSystemBuilder {
|
|
|
initializeActiveInstructions(this.measureList[0]);
|
|
|
}
|
|
|
public buildMusicSystems(): void {
|
|
|
- var previousMeasureEndsSystem: boolean = false;
|
|
|
- var systemMaxWidth: number = this.getFullPageSystemWidth();
|
|
|
+ let previousMeasureEndsSystem: boolean = false;
|
|
|
+ let systemMaxWidth: number = this.getFullPageSystemWidth();
|
|
|
this.measureListIndex = 0;
|
|
|
this.currentSystemParams = new SystemBuildParameters();
|
|
|
this.currentSystemParams.currentSystem = this.initMusicSystem();
|
|
@@ -58,53 +58,52 @@ export class MusicSystemBuilder {
|
|
|
this.rules.SystemLabelsRightMargin,
|
|
|
this.rules.LabelMarginBorderFactor);
|
|
|
this.currentPageHeight += this.currentSystemParams.currentSystem.PositionAndShape.RelativePosition.Y;
|
|
|
- var numberOfMeasures: number = this.measureList.Count(m => m.Any());
|
|
|
+ let numberOfMeasures: number = this.measureList.length(m => m.Any());
|
|
|
while (this.measureListIndex < numberOfMeasures) {
|
|
|
- var staffMeasures: List<StaffMeasure> = this.measureList[this.measureListIndex];
|
|
|
- for (var idx: number = 0, len = staffMeasures.Count; idx < len; ++idx)
|
|
|
+ let staffMeasures: StaffMeasure[] = this.measureList[this.measureListIndex];
|
|
|
+ for (let idx: number = 0, len: number = staffMeasures.length; idx < len; ++idx)
|
|
|
staffMeasures[idx].ResetLayout();
|
|
|
- var sourceMeasure: SourceMeasure = staffMeasures[0].ParentSourceMeasure;
|
|
|
- var sourceMeasureEndsSystem: boolean = sourceMeasure.BreakSystemAfter;
|
|
|
- var isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
|
|
|
- var isFirstSourceMeasure: boolean = sourceMeasure == this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
|
|
|
- var currentMeasureBeginInstructionsWidth: number = this.rules.MeasureLeftMargin;
|
|
|
- var currentMeasureEndInstructionsWidth: number = 0;
|
|
|
- var measureStartLine: SystemLinesEnum = this.getMeasureStartLine();
|
|
|
+ let sourceMeasure: SourceMeasure = staffMeasures[0].ParentSourceMeasure;
|
|
|
+ let sourceMeasureEndsSystem: boolean = sourceMeasure.BreakSystemAfter;
|
|
|
+ let isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
|
|
|
+ let isFirstSourceMeasure: boolean = sourceMeasure === this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
|
|
|
+ let currentMeasureBeginInstructionsWidth: number = this.rules.MeasureLeftMargin;
|
|
|
+ let currentMeasureEndInstructionsWidth: number = 0;
|
|
|
+ let measureStartLine: SystemLinesEnum = this.getMeasureStartLine();
|
|
|
currentMeasureBeginInstructionsWidth += getLineWidth(staffMeasures[0], measureStartLine, isSystemStartMeasure);
|
|
|
if (!this.leadSheet) {
|
|
|
currentMeasureBeginInstructionsWidth += this.addBeginInstructions(staffMeasures, isSystemStartMeasure, isFirstSourceMeasure);
|
|
|
currentMeasureEndInstructionsWidth += this.addEndInstructions(staffMeasures);
|
|
|
}
|
|
|
- var currentMeasureVarWidth: number = 0;
|
|
|
- for (var i: number = 0; i < this.numberOfVisibleStaffLines; i++)
|
|
|
- currentMeasureVarWidth = Math.Max(currentMeasureVarWidth, staffMeasures[i].MinimumStaffEntriesWidth);
|
|
|
- var measureEndLine: SystemLinesEnum = this.getMeasureEndLine();
|
|
|
+ let currentMeasureVarWidth: number = 0;
|
|
|
+ for (let i: number = 0; i < this.numberOfVisibleStaffLines; i++)
|
|
|
+ currentMeasureVarWidth = Math.max(currentMeasureVarWidth, staffMeasures[i].MinimumStaffEntriesWidth);
|
|
|
+ let measureEndLine: SystemLinesEnum = this.getMeasureEndLine();
|
|
|
currentMeasureEndInstructionsWidth += getLineWidth(staffMeasures[0], measureEndLine, isSystemStartMeasure);
|
|
|
- var nextMeasureBeginInstructionWidth: number = this.rules.MeasureLeftMargin;
|
|
|
- if (this.measureListIndex + 1 < this.measureList.Count) {
|
|
|
- var nextStaffMeasures: List<StaffMeasure> = this.measureList[this.measureListIndex + 1];
|
|
|
- var nextSourceMeasure: SourceMeasure = nextStaffMeasures[0].ParentSourceMeasure;
|
|
|
+ let nextMeasureBeginInstructionWidth: number = this.rules.MeasureLeftMargin;
|
|
|
+ if (this.measureListIndex + 1 < this.measureList.length) {
|
|
|
+ let nextStaffMeasures: StaffMeasure[] = this.measureList[this.measureListIndex + 1];
|
|
|
+ let nextSourceMeasure: SourceMeasure = nextStaffMeasures[0].ParentSourceMeasure;
|
|
|
if (nextSourceMeasure.hasBeginInstructions()) {
|
|
|
nextMeasureBeginInstructionWidth += this.addBeginInstructions(nextStaffMeasures, false, false);
|
|
|
}
|
|
|
}
|
|
|
- var totalMeasureWidth: number = currentMeasureBeginInstructionsWidth + currentMeasureEndInstructionsWidth + currentMeasureVarWidth;
|
|
|
- var measureFitsInSystem: boolean = this.currentSystemParams.currentWidth + totalMeasureWidth + nextMeasureBeginInstructionWidth < systemMaxWidth;
|
|
|
+ let totalMeasureWidth: number = currentMeasureBeginInstructionsWidth + currentMeasureEndInstructionsWidth + currentMeasureVarWidth;
|
|
|
+ let measureFitsInSystem: boolean = this.currentSystemParams.currentWidth + totalMeasureWidth + nextMeasureBeginInstructionWidth < systemMaxWidth;
|
|
|
if (isSystemStartMeasure || measureFitsInSystem) {
|
|
|
this.addMeasureToSystem(staffMeasures, measureStartLine, measureEndLine, totalMeasureWidth, currentMeasureBeginInstructionsWidth, currentMeasureVarWidth, currentMeasureEndInstructionsWidth);
|
|
|
this.updateActiveClefs(sourceMeasure, staffMeasures);
|
|
|
this.measureListIndex++;
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
this.finalizeCurrentAndCreateNewSystem(staffMeasures, previousMeasureEndsSystem);
|
|
|
}
|
|
|
previousMeasureEndsSystem = sourceMeasureEndsSystem;
|
|
|
}
|
|
|
- finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.Count - 1], true);
|
|
|
+ finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length - 1], true);
|
|
|
}
|
|
|
- private setMeasureWidth(staffMeasures: List<StaffMeasure>, width: number, beginInstrWidth: number, endInstrWidth: number): void {
|
|
|
- for (var idx: number = 0, len = staffMeasures.Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = staffMeasures[idx];
|
|
|
+ private setMeasureWidth(staffMeasures: StaffMeasure[], width: number, beginInstrWidth: number, endInstrWidth: number): void {
|
|
|
+ for (let idx: number = 0, len: number = staffMeasures.length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = staffMeasures[idx];
|
|
|
measure.SetWidth(width);
|
|
|
if (beginInstrWidth > 0)
|
|
|
measure.BeginInstructionsWidth = beginInstrWidth;
|
|
@@ -112,7 +111,7 @@ export class MusicSystemBuilder {
|
|
|
measure.EndInstructionsWidth = endInstrWidth;
|
|
|
}
|
|
|
}
|
|
|
- private finalizeCurrentAndCreateNewSystem(measures: List<StaffMeasure>, isPartEndingSystem: boolean = false): void {
|
|
|
+ private finalizeCurrentAndCreateNewSystem(measures: StaffMeasure[], isPartEndingSystem: boolean = false): void {
|
|
|
this.adaptRepetitionLineWithIfNeeded();
|
|
|
if (!isPartEndingSystem) {
|
|
|
this.checkAndCreateExtraInstructionMeasure(measures);
|
|
@@ -124,36 +123,35 @@ export class MusicSystemBuilder {
|
|
|
this.currentMusicPage = this.createMusicPage();
|
|
|
this.currentPageHeight = this.rules.PageTopMargin + this.rules.TitleTopDistance;
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
this.currentMusicPage = this.createMusicPage();
|
|
|
this.currentPageHeight = this.rules.PageTopMargin + this.rules.TitleTopDistance;
|
|
|
}
|
|
|
this.currentSystemParams = new SystemBuildParameters();
|
|
|
- if (this.measureListIndex < this.measureList.Count) {
|
|
|
+ if (this.measureListIndex < this.measureList.length) {
|
|
|
this.currentSystemParams.currentSystem = this.initMusicSystem();
|
|
|
this.layoutSystemStaves();
|
|
|
}
|
|
|
}
|
|
|
private adaptRepetitionLineWithIfNeeded(): void {
|
|
|
- var systemMeasures: List<MeasureBuildParameters> = this.currentSystemParams.systemMeasures;
|
|
|
- if (systemMeasures.Count >= 1) {
|
|
|
- var measures: List<StaffMeasure> = this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.Count - 1];
|
|
|
- var measureParams: MeasureBuildParameters = systemMeasures[systemMeasures.Count - 1];
|
|
|
- var diff: number = 0.0f;
|
|
|
- if (measureParams.endLine == SystemLinesEnum.DotsBoldBoldDots) {
|
|
|
+ let systemMeasures: MeasureBuildParameters[] = this.currentSystemParams.systemMeasures;
|
|
|
+ if (systemMeasures.length >= 1) {
|
|
|
+ let measures: StaffMeasure[] = this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length - 1];
|
|
|
+ let measureParams: MeasureBuildParameters = systemMeasures[systemMeasures.length - 1];
|
|
|
+ let diff: number = 0.0;
|
|
|
+ if (measureParams.endLine === SystemLinesEnum.DotsBoldBoldDots) {
|
|
|
measureParams.endLine = SystemLinesEnum.DotsThinBold;
|
|
|
diff = measures[0].GetLineWidth(SystemLinesEnum.DotsBoldBoldDots) / 2 - measures[0].GetLineWidth(SystemLinesEnum.DotsThinBold);
|
|
|
}
|
|
|
this.currentSystemParams.currentSystemFixWidth -= diff;
|
|
|
- for (var idx: number = 0, len = measures.Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = measures[idx];
|
|
|
+ for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = measures[idx];
|
|
|
measure.EndInstructionsWidth -= diff;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- private addMeasureToSystem(staffMeasures: List<StaffMeasure>, measureStartLine: SystemLinesEnum, measureEndLine: SystemLinesEnum, totalMeasureWidth: number, currentMeasureBeginInstructionsWidth: number, currentVarWidth: number, currentMeasureEndInstructionsWidth: number): void {
|
|
|
- this.currentSystemParams.systemMeasures.Add(__init(new MeasureBuildParameters(), { beginLine: measureStartLine, endLine: measureEndLine }));
|
|
|
+ private addMeasureToSystem(staffMeasures: StaffMeasure[], measureStartLine: SystemLinesEnum, measureEndLine: SystemLinesEnum, totalMeasureWidth: number, currentMeasureBeginInstructionsWidth: number, currentVarWidth: number, currentMeasureEndInstructionsWidth: number): void {
|
|
|
+ this.currentSystemParams.systemMeasures.push(__init(new MeasureBuildParameters(), { beginLine: measureStartLine, endLine: measureEndLine }));
|
|
|
this.setMeasureWidth(staffMeasures, totalMeasureWidth, currentMeasureBeginInstructionsWidth,
|
|
|
currentMeasureEndInstructionsWidth);
|
|
|
this.addStaveMeasuresToSystem(staffMeasures);
|
|
@@ -163,63 +161,62 @@ export class MusicSystemBuilder {
|
|
|
this.currentSystemParams.systemMeasureIndex++;
|
|
|
}
|
|
|
private createMusicPage(): GraphicalMusicPage {
|
|
|
- var page: GraphicalMusicPage = new GraphicalMusicPage(this.graphicalMusicSheet);
|
|
|
- this.graphicalMusicSheet.MusicPages.Add(page);
|
|
|
- page.PositionAndShape.BorderLeft = 0.0f;
|
|
|
+ let page: GraphicalMusicPage = new GraphicalMusicPage(this.graphicalMusicSheet);
|
|
|
+ this.graphicalMusicSheet.MusicPages.push(page);
|
|
|
+ page.PositionAndShape.BorderLeft = 0.0;
|
|
|
page.PositionAndShape.BorderRight = this.graphicalMusicSheet.ParentMusicSheet.PageWidth;
|
|
|
- page.PositionAndShape.BorderTop = 0.0f;
|
|
|
+ page.PositionAndShape.BorderTop = 0.0;
|
|
|
page.PositionAndShape.BorderBottom = this.rules.PageHeight;
|
|
|
- page.PositionAndShape.RelativePosition = new PointF_2D(0.0f, 0.0f);
|
|
|
+ page.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
|
|
|
return page;
|
|
|
}
|
|
|
private initMusicSystem(): MusicSystem {
|
|
|
- var musicSystem: MusicSystem = this.symbolFactory.createMusicSystem(this.currentMusicPage, this.globalSystemIndex++);
|
|
|
- this.currentMusicPage.MusicSystems.Add(musicSystem);
|
|
|
- var boundingBox: BoundingBox = musicSystem.PositionAndShape;
|
|
|
- this.currentMusicPage.PositionAndShape.ChildElements.Add(boundingBox);
|
|
|
+ let musicSystem: MusicSystem = this.symbolFactory.createMusicSystem(this.currentMusicPage, this.globalSystemIndex++);
|
|
|
+ this.currentMusicPage.MusicSystems.push(musicSystem);
|
|
|
+ let boundingBox: BoundingBox = musicSystem.PositionAndShape;
|
|
|
+ this.currentMusicPage.PositionAndShape.ChildElements.push(boundingBox);
|
|
|
return musicSystem;
|
|
|
}
|
|
|
private getFullPageSystemWidth(): number {
|
|
|
return this.currentMusicPage.PositionAndShape.Size.Width - this.rules.PageLeftMargin - this.rules.PageRightMargin - this.rules.SystemLeftMargin - this.rules.SystemRightMargin;
|
|
|
}
|
|
|
private layoutSystemStaves(): void {
|
|
|
- var systemWidth: number = this.getFullPageSystemWidth();
|
|
|
- var musicSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
- var boundingBox: BoundingBox = musicSystem.PositionAndShape;
|
|
|
- boundingBox.BorderLeft = 0.0f;
|
|
|
+ let systemWidth: number = this.getFullPageSystemWidth();
|
|
|
+ let musicSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
+ let boundingBox: BoundingBox = musicSystem.PositionAndShape;
|
|
|
+ boundingBox.BorderLeft = 0.0;
|
|
|
boundingBox.BorderRight = systemWidth;
|
|
|
- boundingBox.BorderTop = 0.0f;
|
|
|
- var staffList: List<Staff> = new List<Staff>();
|
|
|
- var musicSheet: MusicSheet = this.graphicalMusicSheet.ParentMusicSheet;
|
|
|
- var instruments: Instrument[] = musicSheet.Instruments.Where(i => i.Voices.Count > 0 && i.Voices[0].Visible).ToArray();
|
|
|
- for (var idx: number = 0, len = instruments.length; idx < len; ++idx) {
|
|
|
- var instrument: Instrument = instruments[idx];
|
|
|
- for (var idx2: number = 0, len2 = instrument.Staves.Count; idx2 < len2; ++idx2) {
|
|
|
- var staff: Staff = instrument.Staves[idx2];
|
|
|
- staffList.Add(staff);
|
|
|
+ boundingBox.BorderTop = 0.0;
|
|
|
+ let staffList: Staff[] = [];
|
|
|
+ let musicSheet: MusicSheet = this.graphicalMusicSheet.ParentMusicSheet;
|
|
|
+ let instruments: Instrument[] = musicSheet.Instruments.Where(i => i.Voices.length > 0 && i.Voices[0].Visible);
|
|
|
+ for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
|
|
|
+ let instrument: Instrument = instruments[idx];
|
|
|
+ for (let idx2: number = 0, len2: number = instrument.Staves.length; idx2 < len2; ++idx2) {
|
|
|
+ let staff: Staff = instrument.Staves[idx2];
|
|
|
+ staffList.push(staff);
|
|
|
}
|
|
|
}
|
|
|
- var multiLyrics: boolean = false;
|
|
|
+ let multiLyrics: boolean = false;
|
|
|
if (this.leadSheet) {
|
|
|
- for (var idx: number = 0, len = staffList.Count; idx < len; ++idx) {
|
|
|
- var staff: Staff = staffList[idx];
|
|
|
- if (staff.ParentInstrument.LyricVersesNumbers.Count > 1) {
|
|
|
+ for (let idx: number = 0, len: number = staffList.length; idx < len; ++idx) {
|
|
|
+ let staff: Staff = staffList[idx];
|
|
|
+ if (staff.ParentInstrument.LyricVersesNumbers.length > 1) {
|
|
|
multiLyrics = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- var yOffsetSum: number = 0;
|
|
|
- for (var i: number = 0; i < staffList.Count; i++) {
|
|
|
+ let yOffsetSum: number = 0;
|
|
|
+ for (let i: number = 0; i < staffList.length; i++) {
|
|
|
this.addStaffLineToMusicSystem(musicSystem, yOffsetSum, staffList[i]);
|
|
|
yOffsetSum += this.rules.StaffHeight;
|
|
|
- if (i + 1 < staffList.Count) {
|
|
|
- var yOffset: number = 0;
|
|
|
+ if (i + 1 < staffList.length) {
|
|
|
+ let yOffset: number = 0;
|
|
|
if (this.leadSheet && !multiLyrics) {
|
|
|
- yOffset = 2.5f;
|
|
|
- }
|
|
|
- else {
|
|
|
- if (staffList[i].ParentInstrument == staffList[i + 1].ParentInstrument)
|
|
|
+ yOffset = 2.5;
|
|
|
+ } else {
|
|
|
+ if (staffList[i].ParentInstrument === staffList[i + 1].ParentInstrument)
|
|
|
yOffset = this.rules.BetweenStaffDistance;
|
|
|
else yOffset = this.rules.StaffDistance;
|
|
|
}
|
|
@@ -229,28 +226,28 @@ export class MusicSystemBuilder {
|
|
|
boundingBox.BorderBottom = yOffsetSum;
|
|
|
}
|
|
|
private addStaffLineToMusicSystem(musicSystem: MusicSystem, relativeYPosition: number, staff: Staff): void {
|
|
|
- if (musicSystem != null) {
|
|
|
- var staffLine: StaffLine = this.symbolFactory.createStaffLine(musicSystem, staff);
|
|
|
- musicSystem.StaffLines.Add(staffLine);
|
|
|
- var boundingBox: BoundingBox = staffLine.PositionAndShape;
|
|
|
- musicSystem.PositionAndShape.ChildElements.Add(boundingBox);
|
|
|
- var relativePosition: PointF_2D = new PointF_2D();
|
|
|
- if (musicSystem.Parent.MusicSystems[0] == musicSystem && musicSystem.Parent == musicSystem.Parent.Parent.MusicPages[0])
|
|
|
+ if (musicSystem !== undefined) {
|
|
|
+ let staffLine: StaffLine = this.symbolFactory.createStaffLine(musicSystem, staff);
|
|
|
+ musicSystem.StaffLines.push(staffLine);
|
|
|
+ let boundingBox: BoundingBox = staffLine.PositionAndShape;
|
|
|
+ musicSystem.PositionAndShape.ChildElements.push(boundingBox);
|
|
|
+ let relativePosition: PointF_2D = new PointF_2D();
|
|
|
+ if (musicSystem.Parent.MusicSystems[0] === musicSystem && musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0])
|
|
|
relativePosition.X = this.rules.FirstSystemMargin;
|
|
|
- else relativePosition.X = 0.0f;
|
|
|
+ else relativePosition.X = 0.0;
|
|
|
relativePosition.Y = relativeYPosition;
|
|
|
boundingBox.RelativePosition = relativePosition;
|
|
|
- if (musicSystem.Parent.MusicSystems[0] == musicSystem && musicSystem.Parent == musicSystem.Parent.Parent.MusicPages[0])
|
|
|
+ if (musicSystem.Parent.MusicSystems[0] === musicSystem && musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0])
|
|
|
boundingBox.BorderRight = musicSystem.PositionAndShape.Size.Width - this.rules.FirstSystemMargin;
|
|
|
else boundingBox.BorderRight = musicSystem.PositionAndShape.Size.Width;
|
|
|
- boundingBox.BorderLeft = 0.0f;
|
|
|
- boundingBox.BorderTop = 0.0f;
|
|
|
+ boundingBox.BorderLeft = 0.0;
|
|
|
+ boundingBox.BorderTop = 0.0;
|
|
|
boundingBox.BorderBottom = this.rules.StaffHeight;
|
|
|
- for (var i: number = 0; i < 5; i++) {
|
|
|
- var start: PointF_2D = new PointF_2D();
|
|
|
- start.X = 0.0f;
|
|
|
+ for (let i: number = 0; i < 5; i++) {
|
|
|
+ let start: PointF_2D = new PointF_2D();
|
|
|
+ start.X = 0.0;
|
|
|
start.Y = i * this.rules.StaffHeight / 4;
|
|
|
- var end: PointF_2D = new PointF_2D();
|
|
|
+ let end: PointF_2D = new PointF_2D();
|
|
|
end.X = staffLine.PositionAndShape.Size.Width;
|
|
|
end.Y = i * this.rules.StaffHeight / 4;
|
|
|
if (this.leadSheet)
|
|
@@ -259,15 +256,15 @@ export class MusicSystemBuilder {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- private initializeActiveInstructions(measureList: List<StaffMeasure>): void {
|
|
|
- var firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
|
|
|
- if (firstSourceMeasure != null) {
|
|
|
- this.visibleStaffIndices = this.graphicalMusicSheet.getVisibleStavesIndecesFromSourceMeasure(measureList).ToArray();
|
|
|
- for (var i: number = 0, len = this.visibleStaffIndices.length; i < len; i++) {
|
|
|
- var staffIndex: number = this.visibleStaffIndices[i];
|
|
|
- var graphicalMeasure: StaffMeasure = this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(firstSourceMeasure, staffIndex);
|
|
|
+ private initializeActiveInstructions(measureList: StaffMeasure[]): void {
|
|
|
+ let firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
|
|
|
+ if (firstSourceMeasure !== undefined) {
|
|
|
+ this.visibleStaffIndices = this.graphicalMusicSheet.getVisibleStavesIndecesFromSourceMeasure(measureList);
|
|
|
+ for (let i: number = 0, len: number = this.visibleStaffIndices.length; i < len; i++) {
|
|
|
+ let staffIndex: number = this.visibleStaffIndices[i];
|
|
|
+ let graphicalMeasure: StaffMeasure = this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(firstSourceMeasure, staffIndex);
|
|
|
this.activeClefs[i] = <ClefInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[0];
|
|
|
- var keyInstruction: KeyInstruction = new KeyInstruction(<KeyInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[1]);
|
|
|
+ let keyInstruction: KeyInstruction = new KeyInstruction(<KeyInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[1]);
|
|
|
keyInstruction = this.transposeKeyInstruction(keyInstruction, graphicalMeasure);
|
|
|
this.activeKeys[i] = keyInstruction;
|
|
|
this.activeRhythm[i] = <RhythmInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[2];
|
|
@@ -275,91 +272,88 @@ export class MusicSystemBuilder {
|
|
|
}
|
|
|
}
|
|
|
private transposeKeyInstruction(keyInstruction: KeyInstruction, graphicalMeasure: StaffMeasure): KeyInstruction {
|
|
|
- if (this.graphicalMusicSheet.ParentMusicSheet.Transpose != 0 && graphicalMeasure.ParentStaff.ParentInstrument.MidiInstrumentId != Common.Enums.MidiInstrument.Percussion && MusicSheetCalculator.TransposeCalculator != null)
|
|
|
+ if (this.graphicalMusicSheet.ParentMusicSheet.Transpose !== 0 && graphicalMeasure.ParentStaff.ParentInstrument.MidiInstrumentId !== Common.Enums.MidiInstrument.Percussion && MusicSheetCalculator.TransposeCalculator !== undefined)
|
|
|
MusicSheetCalculator.TransposeCalculator.TransposeKey(keyInstruction,
|
|
|
this.graphicalMusicSheet.ParentMusicSheet.Transpose);
|
|
|
return keyInstruction;
|
|
|
}
|
|
|
- private addBeginInstructions(measures: List<StaffMeasure>, isSystemFirstMeasure: boolean, isFirstSourceMeasure: boolean): number {
|
|
|
- var measureCount: number = measures.Count;
|
|
|
- if (measureCount == 0)
|
|
|
+ private addBeginInstructions(measures: StaffMeasure[], isSystemFirstMeasure: boolean, isFirstSourceMeasure: boolean): number {
|
|
|
+ let measureCount: number = measures.length;
|
|
|
+ if (measureCount === 0)
|
|
|
return 0;
|
|
|
- var totalBeginInstructionLengthX: number = 0.0f;
|
|
|
- var sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
|
|
|
- for (var idx: number = 0; idx < measureCount; ++idx) {
|
|
|
- var measure: StaffMeasure = measures[idx];
|
|
|
- var staffIndex: number = this.visibleStaffIndices[idx];
|
|
|
- var beginInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[staffIndex];
|
|
|
- var beginInstructionLengthX: number = this.AddInstructionsAtMeasureBegin(beginInstructionsStaffEntry, measure,
|
|
|
+ let totalBeginInstructionLengthX: number = 0.0;
|
|
|
+ let sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
|
|
|
+ for (let idx: number = 0; idx < measureCount; ++idx) {
|
|
|
+ let measure: StaffMeasure = measures[idx];
|
|
|
+ let staffIndex: number = this.visibleStaffIndices[idx];
|
|
|
+ let beginInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[staffIndex];
|
|
|
+ let beginInstructionLengthX: number = this.AddInstructionsAtMeasureBegin(beginInstructionsStaffEntry, measure,
|
|
|
idx, isFirstSourceMeasure,
|
|
|
isSystemFirstMeasure);
|
|
|
- totalBeginInstructionLengthX = Math.Max(totalBeginInstructionLengthX, beginInstructionLengthX);
|
|
|
+ totalBeginInstructionLengthX = Math.max(totalBeginInstructionLengthX, beginInstructionLengthX);
|
|
|
}
|
|
|
return totalBeginInstructionLengthX;
|
|
|
}
|
|
|
- private addEndInstructions(measures: List<StaffMeasure>): number {
|
|
|
- var measureCount: number = measures.Count;
|
|
|
- if (measureCount == 0)
|
|
|
+ private addEndInstructions(measures: StaffMeasure[]): number {
|
|
|
+ let measureCount: number = measures.length;
|
|
|
+ if (measureCount === 0)
|
|
|
return 0;
|
|
|
- var totalEndInstructionLengthX: number = 0.5f;
|
|
|
- var sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
|
|
|
- for (var idx: number = 0; idx < measureCount; idx++) {
|
|
|
- var measure: StaffMeasure = measures[idx];
|
|
|
- var staffIndex: number = this.visibleStaffIndices[idx];
|
|
|
- var endInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.LastInstructionsStaffEntries[staffIndex];
|
|
|
- var endInstructionLengthX: number = this.addInstructionsAtMeasureEnd(endInstructionsStaffEntry, measure);
|
|
|
- totalEndInstructionLengthX = Math.Max(totalEndInstructionLengthX, endInstructionLengthX);
|
|
|
+ let totalEndInstructionLengthX: number = 0.5;
|
|
|
+ let sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
|
|
|
+ for (let idx: number = 0; idx < measureCount; idx++) {
|
|
|
+ let measure: StaffMeasure = measures[idx];
|
|
|
+ let staffIndex: number = this.visibleStaffIndices[idx];
|
|
|
+ let endInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.LastInstructionsStaffEntries[staffIndex];
|
|
|
+ let endInstructionLengthX: number = this.addInstructionsAtMeasureEnd(endInstructionsStaffEntry, measure);
|
|
|
+ totalEndInstructionLengthX = Math.max(totalEndInstructionLengthX, endInstructionLengthX);
|
|
|
}
|
|
|
return totalEndInstructionLengthX;
|
|
|
}
|
|
|
private AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: StaffMeasure,
|
|
|
visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
|
|
|
- var instructionsLengthX: number = 0;
|
|
|
- var currentClef: ClefInstruction = null;
|
|
|
- var currentKey: KeyInstruction = null;
|
|
|
- var currentRhythm: RhythmInstruction = null;
|
|
|
- if (firstEntry != null) {
|
|
|
- for (var idx: number = 0, len = firstEntry.Instructions.Count; idx < len; ++idx) {
|
|
|
- var abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
|
|
|
+ let instructionsLengthX: number = 0;
|
|
|
+ let currentClef: ClefInstruction = undefined;
|
|
|
+ let currentKey: KeyInstruction = undefined;
|
|
|
+ let currentRhythm: RhythmInstruction = undefined;
|
|
|
+ if (firstEntry !== undefined) {
|
|
|
+ for (let idx: number = 0, len: number = firstEntry.Instructions.length; idx < len; ++idx) {
|
|
|
+ let abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
|
|
|
if (abstractNotationInstruction instanceof ClefInstruction) {
|
|
|
currentClef = <ClefInstruction>abstractNotationInstruction;
|
|
|
- }
|
|
|
- else if (abstractNotationInstruction instanceof KeyInstruction) {
|
|
|
+ } else if (abstractNotationInstruction instanceof KeyInstruction) {
|
|
|
currentKey = <KeyInstruction>abstractNotationInstruction;
|
|
|
- }
|
|
|
- else if (abstractNotationInstruction instanceof RhythmInstruction) {
|
|
|
+ } else if (abstractNotationInstruction instanceof RhythmInstruction) {
|
|
|
currentRhythm = <RhythmInstruction>abstractNotationInstruction;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (isSystemStartMeasure) {
|
|
|
- if (currentClef == null) {
|
|
|
+ if (currentClef === undefined) {
|
|
|
currentClef = this.activeClefs[visibleStaffIdx];
|
|
|
}
|
|
|
- if (currentKey == null) {
|
|
|
+ if (currentKey === undefined) {
|
|
|
currentKey = this.activeKeys[visibleStaffIdx];
|
|
|
}
|
|
|
- if (isFirstSourceMeasure && currentRhythm == null) {
|
|
|
+ if (isFirstSourceMeasure && currentRhythm === undefined) {
|
|
|
currentRhythm = this.activeRhythm[visibleStaffIdx];
|
|
|
}
|
|
|
}
|
|
|
- var clefAdded: boolean = false;
|
|
|
- var keyAdded: boolean = false;
|
|
|
- var rhythmAdded: boolean = false;
|
|
|
- if (currentClef != null) {
|
|
|
+ let clefAdded: boolean = false;
|
|
|
+ let keyAdded: boolean = false;
|
|
|
+ let rhythmAdded: boolean = false;
|
|
|
+ if (currentClef !== undefined) {
|
|
|
measure.AddClefAtBegin(currentClef);
|
|
|
clefAdded = true;
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
currentClef = this.activeClefs[visibleStaffIdx];
|
|
|
}
|
|
|
- if (currentKey != null) {
|
|
|
+ if (currentKey !== undefined) {
|
|
|
currentKey = this.transposeKeyInstruction(currentKey, measure);
|
|
|
- var previousKey: KeyInstruction = isSystemStartMeasure ? null : this.activeKeys[visibleStaffIdx];
|
|
|
+ let previousKey: KeyInstruction = isSystemStartMeasure ? undefined : this.activeKeys[visibleStaffIdx];
|
|
|
measure.AddKeyAtBegin(currentKey, previousKey, currentClef);
|
|
|
keyAdded = true;
|
|
|
}
|
|
|
- if (currentRhythm != null) {
|
|
|
+ if (currentRhythm !== undefined) {
|
|
|
measure.AddRhythmAtBegin(currentRhythm);
|
|
|
rhythmAdded = true;
|
|
|
}
|
|
@@ -371,52 +365,50 @@ export class MusicSystemBuilder {
|
|
|
return instructionsLengthX;
|
|
|
}
|
|
|
private addInstructionsAtMeasureEnd(lastEntry: SourceStaffEntry, measure: StaffMeasure): number {
|
|
|
- if (lastEntry == null || lastEntry.Instructions == null || lastEntry.Instructions.Count == 0)
|
|
|
+ if (lastEntry === undefined || lastEntry.Instructions === undefined || lastEntry.Instructions.length === 0)
|
|
|
return 0;
|
|
|
- for (var idx: number = 0, len = lastEntry.Instructions.Count; idx < len; ++idx) {
|
|
|
- var abstractNotationInstruction: AbstractNotationInstruction = lastEntry.Instructions[idx];
|
|
|
+ for (let idx: number = 0, len: number = lastEntry.Instructions.length; idx < len; ++idx) {
|
|
|
+ let abstractNotationInstruction: AbstractNotationInstruction = lastEntry.Instructions[idx];
|
|
|
if (abstractNotationInstruction instanceof ClefInstruction) {
|
|
|
- var activeClef: ClefInstruction = <ClefInstruction>abstractNotationInstruction;
|
|
|
+ let activeClef: ClefInstruction = <ClefInstruction>abstractNotationInstruction;
|
|
|
measure.AddClefAtEnd(activeClef);
|
|
|
}
|
|
|
}
|
|
|
return this.rules.MeasureRightMargin + measure.EndInstructionsWidth;
|
|
|
}
|
|
|
- private updateActiveClefs(measure: SourceMeasure, staffMeasures: List<StaffMeasure>): void {
|
|
|
- for (var visStaffIdx: number = 0, len = staffMeasures.Count; visStaffIdx < len; visStaffIdx++) {
|
|
|
- var staffIndex: number = this.visibleStaffIndices[visStaffIdx];
|
|
|
- var firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
|
|
|
- if (firstEntry != null) {
|
|
|
- for (var idx: number = 0, len2 = firstEntry.Instructions.Count; idx < len2; ++idx) {
|
|
|
- var abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
|
|
|
+ private updateActiveClefs(measure: SourceMeasure, staffMeasures: StaffMeasure[]): void {
|
|
|
+ for (let visStaffIdx: number = 0, len: number = staffMeasures.length; visStaffIdx < len; visStaffIdx++) {
|
|
|
+ let staffIndex: number = this.visibleStaffIndices[visStaffIdx];
|
|
|
+ let firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
|
|
|
+ if (firstEntry !== undefined) {
|
|
|
+ for (let idx: number = 0, len2: number = firstEntry.Instructions.length; idx < len2; ++idx) {
|
|
|
+ let abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
|
|
|
if (abstractNotationInstruction instanceof ClefInstruction) {
|
|
|
this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
|
|
|
- }
|
|
|
- else if (abstractNotationInstruction instanceof KeyInstruction) {
|
|
|
+ } else if (abstractNotationInstruction instanceof KeyInstruction) {
|
|
|
this.activeKeys[visStaffIdx] = <KeyInstruction>abstractNotationInstruction;
|
|
|
- }
|
|
|
- else if (abstractNotationInstruction instanceof RhythmInstruction) {
|
|
|
+ } else if (abstractNotationInstruction instanceof RhythmInstruction) {
|
|
|
this.activeRhythm[visStaffIdx] = <RhythmInstruction>abstractNotationInstruction;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- var entries: List<SourceStaffEntry> = measure.getEntriesPerStaff(staffIndex);
|
|
|
- for (var idx: number = 0, len2 = entries.Count; idx < len2; ++idx) {
|
|
|
- var staffEntry: SourceStaffEntry = entries[idx];
|
|
|
- if (staffEntry.Instructions != null) {
|
|
|
- for (var idx2: number = 0, len3 = staffEntry.Instructions.Count; idx2 < len3; ++idx2) {
|
|
|
- var abstractNotationInstruction: AbstractNotationInstruction = staffEntry.Instructions[idx2];
|
|
|
+ let entries: SourceStaffEntry[] = measure.getEntriesPerStaff(staffIndex);
|
|
|
+ for (let idx: number = 0, len2: number = entries.length; idx < len2; ++idx) {
|
|
|
+ let staffEntry: SourceStaffEntry = entries[idx];
|
|
|
+ if (staffEntry.Instructions !== undefined) {
|
|
|
+ for (let idx2: number = 0, len3: number = staffEntry.Instructions.length; idx2 < len3; ++idx2) {
|
|
|
+ let abstractNotationInstruction: AbstractNotationInstruction = staffEntry.Instructions[idx2];
|
|
|
if (abstractNotationInstruction instanceof ClefInstruction) {
|
|
|
this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- var lastEntry: SourceStaffEntry = measure.LastInstructionsStaffEntries[staffIndex];
|
|
|
- if (lastEntry != null) {
|
|
|
- var instructions: List<AbstractNotationInstruction> = lastEntry.Instructions;
|
|
|
- for (var idx: number = 0, len3 = instructions.Count; idx < len3; ++idx) {
|
|
|
- var abstractNotationInstruction: AbstractNotationInstruction = instructions[idx];
|
|
|
+ let lastEntry: SourceStaffEntry = measure.LastInstructionsStaffEntries[staffIndex];
|
|
|
+ if (lastEntry !== undefined) {
|
|
|
+ let instructions: AbstractNotationInstruction[] = lastEntry.Instructions;
|
|
|
+ for (let idx: number = 0, len3: number = instructions.length; idx < len3; ++idx) {
|
|
|
+ let abstractNotationInstruction: AbstractNotationInstruction = instructions[idx];
|
|
|
if (abstractNotationInstruction instanceof ClefInstruction) {
|
|
|
this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
|
|
|
}
|
|
@@ -424,80 +416,80 @@ export class MusicSystemBuilder {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- private checkAndCreateExtraInstructionMeasure(measures: List<StaffMeasure>): void {
|
|
|
- var firstStaffEntries: List<SourceStaffEntry> = measures[0].ParentSourceMeasure.FirstInstructionsStaffEntries;
|
|
|
- var visibleInstructionEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
|
|
|
- for (var idx: number = 0, len = measures.Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = measures[idx];
|
|
|
- visibleInstructionEntries.Add(firstStaffEntries[measure.ParentStaff.IdInMusicSheet]);
|
|
|
+ private checkAndCreateExtraInstructionMeasure(measures: StaffMeasure[]): void {
|
|
|
+ let firstStaffEntries: SourceStaffEntry[] = measures[0].ParentSourceMeasure.FirstInstructionsStaffEntries;
|
|
|
+ let visibleInstructionEntries: SourceStaffEntry[] = [];
|
|
|
+ for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = measures[idx];
|
|
|
+ visibleInstructionEntries.push(firstStaffEntries[measure.ParentStaff.IdInMusicSheet]);
|
|
|
}
|
|
|
- var maxMeasureWidth: number = 0;
|
|
|
- for (var visStaffIdx: number = 0, len = visibleInstructionEntries.Count; visStaffIdx < len; ++visStaffIdx) {
|
|
|
- var sse: SourceStaffEntry = visibleInstructionEntries[visStaffIdx];
|
|
|
- if (sse == null)
|
|
|
+ let maxMeasureWidth: number = 0;
|
|
|
+ for (let visStaffIdx: number = 0, len: number = visibleInstructionEntries.length; visStaffIdx < len; ++visStaffIdx) {
|
|
|
+ let sse: SourceStaffEntry = visibleInstructionEntries[visStaffIdx];
|
|
|
+ if (sse === undefined)
|
|
|
continue;
|
|
|
- var instructions: List<AbstractNotationInstruction> = sse.Instructions;
|
|
|
- var keyInstruction: KeyInstruction = null;
|
|
|
- var rhythmInstruction: RhythmInstruction = null;
|
|
|
- for (var idx2: number = 0, len2 = instructions.Count; idx2 < len2; ++idx2) {
|
|
|
- var instruction: AbstractNotationInstruction = instructions[idx2];
|
|
|
- if (instruction instanceof KeyInstruction && (<KeyInstruction>instruction).Key != this.activeKeys[visStaffIdx].Key)
|
|
|
+ let instructions: AbstractNotationInstruction[] = sse.Instructions;
|
|
|
+ let keyInstruction: KeyInstruction = undefined;
|
|
|
+ let rhythmInstruction: RhythmInstruction = undefined;
|
|
|
+ for (let idx2: number = 0, len2: number = instructions.length; idx2 < len2; ++idx2) {
|
|
|
+ let instruction: AbstractNotationInstruction = instructions[idx2];
|
|
|
+ if (instruction instanceof KeyInstruction && (<KeyInstruction>instruction).Key !== this.activeKeys[visStaffIdx].Key)
|
|
|
keyInstruction = <KeyInstruction>instruction;
|
|
|
- if (instruction instanceof RhythmInstruction && (<RhythmInstruction>instruction) != this.activeRhythm[visStaffIdx])
|
|
|
+ if (instruction instanceof RhythmInstruction && (<RhythmInstruction>instruction) !== this.activeRhythm[visStaffIdx])
|
|
|
rhythmInstruction = <RhythmInstruction>instruction;
|
|
|
}
|
|
|
- if (keyInstruction != null || rhythmInstruction != null) {
|
|
|
- var measureWidth: number = this.addExtraInstructionMeasure(visStaffIdx, keyInstruction, rhythmInstruction);
|
|
|
- maxMeasureWidth = Math.Max(maxMeasureWidth, measureWidth);
|
|
|
+ if (keyInstruction !== undefined || rhythmInstruction !== undefined) {
|
|
|
+ let measureWidth: number = this.addExtraInstructionMeasure(visStaffIdx, keyInstruction, rhythmInstruction);
|
|
|
+ maxMeasureWidth = Math.max(maxMeasureWidth, measureWidth);
|
|
|
}
|
|
|
}
|
|
|
if (maxMeasureWidth > 0) {
|
|
|
- this.currentSystemParams.systemMeasures.Add(__init(new MeasureBuildParameters(), { beginLine: SystemLinesEnum.None, endLine: SystemLinesEnum.None }));
|
|
|
+ this.currentSystemParams.systemMeasures.push(__init(new MeasureBuildParameters(), { beginLine: SystemLinesEnum.None, endLine: SystemLinesEnum.None }));
|
|
|
this.currentSystemParams.currentWidth += maxMeasureWidth;
|
|
|
this.currentSystemParams.currentSystemFixWidth += maxMeasureWidth;
|
|
|
}
|
|
|
}
|
|
|
private addExtraInstructionMeasure(visStaffIdx: number, keyInstruction: KeyInstruction, rhythmInstruction: RhythmInstruction): number {
|
|
|
- var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
- var measures: List<StaffMeasure> = new List<StaffMeasure>();
|
|
|
- var measure: StaffMeasure = this.symbolFactory.createExtraStaffMeasure(currentSystem.StaffLines[visStaffIdx]);
|
|
|
- measures.Add(measure);
|
|
|
- if (keyInstruction != null) {
|
|
|
+ let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
+ let measures: StaffMeasure[] = [];
|
|
|
+ let measure: StaffMeasure = this.symbolFactory.createExtraStaffMeasure(currentSystem.StaffLines[visStaffIdx]);
|
|
|
+ measures.push(measure);
|
|
|
+ if (keyInstruction !== undefined) {
|
|
|
measure.AddKeyAtBegin(keyInstruction, this.activeKeys[visStaffIdx], this.activeClefs[visStaffIdx]);
|
|
|
}
|
|
|
- if (rhythmInstruction != null) {
|
|
|
+ if (rhythmInstruction !== undefined) {
|
|
|
measure.AddRhythmAtBegin(rhythmInstruction);
|
|
|
}
|
|
|
- measure.PositionAndShape.BorderLeft = 0.0f;
|
|
|
- measure.PositionAndShape.BorderTop = 0.0f;
|
|
|
+ measure.PositionAndShape.BorderLeft = 0.0;
|
|
|
+ measure.PositionAndShape.BorderTop = 0.0;
|
|
|
measure.PositionAndShape.BorderBottom = this.rules.StaffHeight;
|
|
|
- var width: number = this.rules.MeasureLeftMargin + measure.BeginInstructionsWidth + this.rules.MeasureRightMargin;
|
|
|
+ let width: number = this.rules.MeasureLeftMargin + measure.BeginInstructionsWidth + this.rules.MeasureRightMargin;
|
|
|
measure.PositionAndShape.BorderRight = width;
|
|
|
- currentSystem.StaffLines[visStaffIdx].Measures.Add(measure);
|
|
|
+ currentSystem.StaffLines[visStaffIdx].Measures.push(measure);
|
|
|
measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
|
|
|
- currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.Add(measure.PositionAndShape);
|
|
|
+ currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.push(measure.PositionAndShape);
|
|
|
return width;
|
|
|
}
|
|
|
- private addStaveMeasuresToSystem(staffMeasures: List<StaffMeasure>): void {
|
|
|
- if (staffMeasures[0] != null) {
|
|
|
- var gmeasures: List<StaffMeasure> = new List<StaffMeasure>();
|
|
|
- for (var i: number = 0; i < staffMeasures.Count; i++)
|
|
|
- gmeasures.Add(staffMeasures[i]);
|
|
|
- var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
- for (var visStaffIdx: number = 0; visStaffIdx < this.numberOfVisibleStaffLines; visStaffIdx++) {
|
|
|
- var measure: StaffMeasure = gmeasures[visStaffIdx];
|
|
|
- currentSystem.StaffLines[visStaffIdx].Measures.Add(measure);
|
|
|
+ private addStaveMeasuresToSystem(staffMeasures: StaffMeasure[]): void {
|
|
|
+ if (staffMeasures[0] !== undefined) {
|
|
|
+ let gmeasures: StaffMeasure[] = [];
|
|
|
+ for (let i: number = 0; i < staffMeasures.length; i++)
|
|
|
+ gmeasures.push(staffMeasures[i]);
|
|
|
+ let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
+ for (let visStaffIdx: number = 0; visStaffIdx < this.numberOfVisibleStaffLines; visStaffIdx++) {
|
|
|
+ let measure: StaffMeasure = gmeasures[visStaffIdx];
|
|
|
+ currentSystem.StaffLines[visStaffIdx].Measures.push(measure);
|
|
|
measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
|
|
|
- currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.Add(measure.PositionAndShape);
|
|
|
+ currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.push(measure.PositionAndShape);
|
|
|
}
|
|
|
currentSystem.AddStaffMeasures(gmeasures);
|
|
|
}
|
|
|
}
|
|
|
private getMeasureStartLine(): SystemLinesEnum {
|
|
|
- var thisMeasureBeginsLineRep: boolean = this.thisMeasureBeginsLineRepetition();
|
|
|
+ let thisMeasureBeginsLineRep: boolean = this.thisMeasureBeginsLineRepetition();
|
|
|
if (thisMeasureBeginsLineRep) {
|
|
|
- var isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
|
|
|
- var isGlobalFirstMeasure: boolean = this.measureListIndex == 0;
|
|
|
+ let isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
|
|
|
+ let isGlobalFirstMeasure: boolean = this.measureListIndex === 0;
|
|
|
if (this.previousMeasureEndsLineRepetition() && !isSystemStartMeasure) {
|
|
|
return SystemLinesEnum.DotsBoldBoldDots;
|
|
|
}
|
|
@@ -513,7 +505,7 @@ export class MusicSystemBuilder {
|
|
|
if (this.thisMeasureEndsLineRepetition()) {
|
|
|
return SystemLinesEnum.DotsThinBold;
|
|
|
}
|
|
|
- if (this.measureListIndex == this.measureList.Count - 1 || this.measureList[this.measureListIndex][0].ParentSourceMeasure.EndsPiece) {
|
|
|
+ if (this.measureListIndex === this.measureList.length - 1 || this.measureList[this.measureListIndex][0].ParentSourceMeasure.EndsPiece) {
|
|
|
return SystemLinesEnum.ThinBold;
|
|
|
}
|
|
|
if (this.nextMeasureHasKeyInstructionChange() || this.thisMeasureEndsWordRepetition() || this.nextMeasureBeginsWordRepetition()) {
|
|
@@ -522,114 +514,114 @@ export class MusicSystemBuilder {
|
|
|
return SystemLinesEnum.SingleThin;
|
|
|
}
|
|
|
private getLineWidth(measure: StaffMeasure, systemLineEnum: SystemLinesEnum, isSystemStartMeasure: boolean): number {
|
|
|
- var width: number = measure.GetLineWidth(systemLineEnum);
|
|
|
- if (systemLineEnum == SystemLinesEnum.DotsBoldBoldDots) {
|
|
|
+ let width: number = measure.GetLineWidth(systemLineEnum);
|
|
|
+ if (systemLineEnum === SystemLinesEnum.DotsBoldBoldDots) {
|
|
|
width /= 2;
|
|
|
}
|
|
|
- if (isSystemStartMeasure && systemLineEnum == SystemLinesEnum.BoldThinDots) {
|
|
|
+ if (isSystemStartMeasure && systemLineEnum === SystemLinesEnum.BoldThinDots) {
|
|
|
width += this.rules.DistanceBetweenLastInstructionAndRepetitionBarline;
|
|
|
}
|
|
|
return width;
|
|
|
}
|
|
|
private previousMeasureEndsLineRepetition(): boolean {
|
|
|
- if (this.measureListIndex == 0)
|
|
|
+ if (this.measureListIndex === 0)
|
|
|
return false;
|
|
|
- for (var idx: number = 0, len = this.measureList[this.measureListIndex - 1].Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = this.measureList[this.measureListIndex - 1][idx];
|
|
|
+ for (let idx: number = 0, len: number = this.measureList[this.measureListIndex - 1].length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = this.measureList[this.measureListIndex - 1][idx];
|
|
|
if (measure.endsWithLineRepetition())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private thisMeasureBeginsLineRepetition(): boolean {
|
|
|
- for (var idx: number = 0, len = this.measureList[this.measureListIndex].Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
|
|
|
+ for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
|
|
|
if (measure.beginsWithLineRepetition())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private nextMeasureBeginsLineRepetition(): boolean {
|
|
|
- var nextMeasureIndex: number = this.measureListIndex + 1;
|
|
|
- if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.Count)
|
|
|
+ let nextMeasureIndex: number = this.measureListIndex + 1;
|
|
|
+ if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length)
|
|
|
return false;
|
|
|
- for (var idx: number = 0, len = this.measureList[nextMeasureIndex].Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
|
|
|
+ for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
|
|
|
if (measure.beginsWithLineRepetition())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private thisMeasureEndsLineRepetition(): boolean {
|
|
|
- for (var idx: number = 0, len = this.measureList[this.measureListIndex].Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
|
|
|
+ for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
|
|
|
if (measure.endsWithLineRepetition())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private nextMeasureBeginsWordRepetition(): boolean {
|
|
|
- var nextMeasureIndex: number = this.measureListIndex + 1;
|
|
|
- if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.Count)
|
|
|
+ let nextMeasureIndex: number = this.measureListIndex + 1;
|
|
|
+ if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length)
|
|
|
return false;
|
|
|
- for (var idx: number = 0, len = this.measureList[nextMeasureIndex].Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
|
|
|
+ for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
|
|
|
if (measure.beginsWithWordRepetition())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private thisMeasureEndsWordRepetition(): boolean {
|
|
|
- for (var idx: number = 0, len = this.measureList[this.measureListIndex].Count; idx < len; ++idx) {
|
|
|
- var measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
|
|
|
+ for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
|
|
|
+ let measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
|
|
|
if (measure.endsWithWordRepetition())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private nextMeasureHasKeyInstructionChange(): boolean {
|
|
|
- return this.getNextMeasureKeyInstruction() != null;
|
|
|
+ return this.getNextMeasureKeyInstruction() !== undefined;
|
|
|
}
|
|
|
private getNextMeasureKeyInstruction(): KeyInstruction {
|
|
|
- if (this.measureListIndex < this.measureList.Count - 1) {
|
|
|
- for (var visIndex: number = 0; visIndex < this.measureList[this.measureListIndex].Count; visIndex++) {
|
|
|
- var sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex + 1][visIndex].ParentSourceMeasure;
|
|
|
- if (sourceMeasure == null)
|
|
|
- return null;
|
|
|
+ if (this.measureListIndex < this.measureList.length - 1) {
|
|
|
+ for (let visIndex: number = 0; visIndex < this.measureList[this.measureListIndex].length; visIndex++) {
|
|
|
+ let sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex + 1][visIndex].ParentSourceMeasure;
|
|
|
+ if (sourceMeasure === undefined)
|
|
|
+ return undefined;
|
|
|
return sourceMeasure.getKeyInstruction(this.visibleStaffIndices[visIndex]);
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
+ return undefined;
|
|
|
}
|
|
|
private calculateXScalingFactor(systemFixWidth: number, systemVarWidth: number): number {
|
|
|
- if (Math.Abs(systemVarWidth - 0) < 0.00001f || Math.Abs(systemFixWidth - 0) < 0.00001f)
|
|
|
- return 1.0f;
|
|
|
- var systemEndX: number;
|
|
|
- var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
+ if (Math.abs(systemVarWidth - 0) < 0.00001 || Math.abs(systemFixWidth - 0) < 0.00001)
|
|
|
+ return 1.0;
|
|
|
+ let systemEndX: number;
|
|
|
+ let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
systemEndX = currentSystem.StaffLines[0].PositionAndShape.Size.Width;
|
|
|
- var scalingFactor: number = (systemEndX - systemFixWidth) / systemVarWidth;
|
|
|
+ let scalingFactor: number = (systemEndX - systemFixWidth) / systemVarWidth;
|
|
|
return scalingFactor;
|
|
|
}
|
|
|
private stretchMusicSystem(isPartEndingSystem: boolean): void {
|
|
|
- var scalingFactor: number = this.calculateXScalingFactor(this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth);
|
|
|
+ let scalingFactor: number = this.calculateXScalingFactor(this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth);
|
|
|
if (isPartEndingSystem)
|
|
|
- scalingFactor = Math.Min(scalingFactor, this.rules.LastSystemMaxScalingFactor);
|
|
|
- var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
- for (var visStaffIdx: number = 0, len = currentSystem.StaffLines.Count; visStaffIdx < len; ++visStaffIdx) {
|
|
|
- var staffLine: StaffLine = currentSystem.StaffLines[visStaffIdx];
|
|
|
- var currentXPosition: number = 0.0f;
|
|
|
- for (var i: number = 0; i < staffLine.Measures.Count; i++) {
|
|
|
- var measure: StaffMeasure = staffLine.Measures[i];
|
|
|
+ scalingFactor = Math.min(scalingFactor, this.rules.LastSystemMaxScalingFactor);
|
|
|
+ let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
+ for (let visStaffIdx: number = 0, len: number = currentSystem.StaffLines.length; visStaffIdx < len; ++visStaffIdx) {
|
|
|
+ let staffLine: StaffLine = currentSystem.StaffLines[visStaffIdx];
|
|
|
+ let currentXPosition: number = 0.0;
|
|
|
+ for (let i: number = 0; i < staffLine.Measures.length; i++) {
|
|
|
+ let measure: StaffMeasure = staffLine.Measures[i];
|
|
|
measure.SetPositionInStaffline(currentXPosition);
|
|
|
measure.SetWidth(measure.BeginInstructionsWidth + measure.MinimumStaffEntriesWidth * scalingFactor + measure.EndInstructionsWidth);
|
|
|
- if (i < this.currentSystemParams.systemMeasures.Count) {
|
|
|
- var startLine: SystemLinesEnum = this.currentSystemParams.systemMeasures[i].beginLine;
|
|
|
- var lineWidth: number = measure.GetLineWidth(SystemLinesEnum.BoldThinDots);
|
|
|
+ if (i < this.currentSystemParams.systemMeasures.length) {
|
|
|
+ let startLine: SystemLinesEnum = this.currentSystemParams.systemMeasures[i].beginLine;
|
|
|
+ let lineWidth: number = measure.GetLineWidth(SystemLinesEnum.BoldThinDots);
|
|
|
switch (startLine) {
|
|
|
case SystemLinesEnum.BoldThinDots:
|
|
|
{
|
|
|
- var xPosition: number = currentXPosition;
|
|
|
- if (i == 0) {
|
|
|
+ let xPosition: number = currentXPosition;
|
|
|
+ if (i === 0) {
|
|
|
xPosition = currentXPosition + measure.BeginInstructionsWidth - lineWidth;
|
|
|
}
|
|
|
currentSystem.createVerticalLineForMeasure(xPosition, SystemLinesEnum.BoldThinDots, lineWidth, visStaffIdx);
|
|
@@ -639,15 +631,15 @@ export class MusicSystemBuilder {
|
|
|
}
|
|
|
measure.StaffEntriesScaleFactor = scalingFactor;
|
|
|
measure.LayoutSymbols();
|
|
|
- var nextMeasureHasRepStartLine: boolean = i + 1 < this.currentSystemParams.systemMeasures.Count && this.currentSystemParams.systemMeasures[i + 1].beginLine == SystemLinesEnum.BoldThinDots;
|
|
|
+ let nextMeasureHasRepStartLine: boolean = i + 1 < this.currentSystemParams.systemMeasures.length && this.currentSystemParams.systemMeasures[i + 1].beginLine === SystemLinesEnum.BoldThinDots;
|
|
|
if (!nextMeasureHasRepStartLine) {
|
|
|
- var endLine: SystemLinesEnum = SystemLinesEnum.SingleThin;
|
|
|
- if (i < this.currentSystemParams.systemMeasures.Count) {
|
|
|
+ let endLine: SystemLinesEnum = SystemLinesEnum.SingleThin;
|
|
|
+ if (i < this.currentSystemParams.systemMeasures.length) {
|
|
|
endLine = this.currentSystemParams.systemMeasures[i].endLine;
|
|
|
}
|
|
|
- var lineWidth: number = measure.GetLineWidth(endLine);
|
|
|
- var xPos: number = measure.PositionAndShape.RelativePosition.X + measure.PositionAndShape.BorderRight - lineWidth;
|
|
|
- if (endLine == SystemLinesEnum.DotsBoldBoldDots)
|
|
|
+ let lineWidth: number = measure.GetLineWidth(endLine);
|
|
|
+ let xPos: number = measure.PositionAndShape.RelativePosition.X + measure.PositionAndShape.BorderRight - lineWidth;
|
|
|
+ if (endLine === SystemLinesEnum.DotsBoldBoldDots)
|
|
|
xPos -= lineWidth / 2;
|
|
|
currentSystem.createVerticalLineForMeasure(xPos, endLine, lineWidth, visStaffIdx);
|
|
|
}
|
|
@@ -658,13 +650,13 @@ export class MusicSystemBuilder {
|
|
|
this.decreaseMusicSystemBorders();
|
|
|
}
|
|
|
private decreaseMusicSystemBorders(): void {
|
|
|
- var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
- var width: number = currentSystem.StaffLines[0].Measures.Last().PositionAndShape.RelativePosition.X + currentSystem.StaffLines[0].Measures.Last().PositionAndShape.Size.Width;
|
|
|
- for (var idx: number = 0, len = currentSystem.StaffLines.Count; idx < len; ++idx) {
|
|
|
- var staffLine: StaffLine = currentSystem.StaffLines[idx];
|
|
|
+ let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
|
|
|
+ let width: number = currentSystem.StaffLines[0].Measures.Last().PositionAndShape.RelativePosition.X + currentSystem.StaffLines[0].Measures.Last().PositionAndShape.Size.Width;
|
|
|
+ for (let idx: number = 0, len: number = currentSystem.StaffLines.length; idx < len; ++idx) {
|
|
|
+ let staffLine: StaffLine = currentSystem.StaffLines[idx];
|
|
|
staffLine.PositionAndShape.BorderRight = width;
|
|
|
- for (var idx2: number = 0, len2 = staffLine.StaffLines.Length; idx2 < len2; ++idx2) {
|
|
|
- var graphicalLine: GraphicalLine = staffLine.StaffLines[idx2];
|
|
|
+ for (let idx2: number = 0, len2: number = staffLine.StaffLines.Length; idx2 < len2; ++idx2) {
|
|
|
+ let graphicalLine: GraphicalLine = staffLine.StaffLines[idx2];
|
|
|
graphicalLine.End = new PointF_2D(width, graphicalLine.End.Y);
|
|
|
}
|
|
|
}
|
|
@@ -673,14 +665,14 @@ export class MusicSystemBuilder {
|
|
|
}
|
|
|
export class SystemBuildParameters {
|
|
|
public currentSystem: MusicSystem;
|
|
|
- public systemMeasures: List<MeasureBuildParameters> = new List<MeasureBuildParameters>();
|
|
|
+ public systemMeasures: MeasureBuildParameters[] = [];
|
|
|
public systemMeasureIndex: number = 0;
|
|
|
public currentWidth: number = 0;
|
|
|
public currentSystemFixWidth: number = 0;
|
|
|
public currentSystemVarWidth: number = 0;
|
|
|
public MaxLabelLength: number = 0;
|
|
|
public IsSystemStartMeasure(): boolean {
|
|
|
- return this.systemMeasureIndex == 0;
|
|
|
+ return this.systemMeasureIndex === 0;
|
|
|
}
|
|
|
}
|
|
|
|