Selaa lähdekoodia

Added MusicSheetDrawer and VexFlowImplementation of it.
Some renaming.
Some lint corrections.

Matthias 9 vuotta sitten
vanhempi
commit
582b6e9ac9

+ 3 - 3
src/MusicalScore/Graphical/GraphicalMusicSheet.ts

@@ -43,7 +43,7 @@ export class GraphicalMusicSheet {
     private subtitle: GraphicalLabel;
     private composer: GraphicalLabel;
     private lyricist: GraphicalLabel;
-    private scoreFollowingLines: GraphicalLine[] = [];
+    private cursors: GraphicalLine[] = [];
     private minAllowedSystemWidth: number;
     //private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
     private numberOfStaves: number;
@@ -117,8 +117,8 @@ export class GraphicalMusicSheet {
         this.lyricist = value;
     }
 
-    public get ScoreFollowingLines(): GraphicalLine[] {
-        return this.scoreFollowingLines;
+    public get Cursors(): GraphicalLine[] {
+        return this.cursors;
     }
 
     public get MinAllowedSystemWidth(): number {

+ 46 - 0
src/MusicalScore/Graphical/MusicSheetDrawer.ts

@@ -0,0 +1,46 @@
+import {GraphicalMusicSheet} from "./GraphicalMusicSheet";
+import {StaffMeasure} from "./StaffMeasure";
+import {StaffLine} from "./StaffLine";
+import {RectangleF2D} from "../../Common/DataObjects/RectangleF2D";
+import {MusicSystem} from "./MusicSystem";
+import {GraphicalMusicPage} from "./GraphicalMusicPage";
+export class MusicSheetDrawer {
+    private graphicalMusicSheet: GraphicalMusicSheet;
+
+    public drawSheet(graphicalMusicSheet: GraphicalMusicSheet): void {
+        this.graphicalMusicSheet = graphicalMusicSheet;
+        for (let idx: number = 0, len: number = this.graphicalMusicSheet.MusicPages.length; idx < len; ++idx) {
+            let page: GraphicalMusicPage = this.graphicalMusicSheet.MusicPages[idx];
+            this.drawPage(page);
+        }
+    }
+
+    protected drawMeasure(measure: StaffMeasure): void {
+        throw new Error("not implemented");
+    }
+
+    protected applyScreenTransformation(rectangle: RectangleF2D): RectangleF2D {
+        throw new Error("not implemented");
+    }
+
+    private drawPage(page: GraphicalMusicPage): void {
+        for (let idx: number = 0, len: number = page.MusicSystems.length; idx < len; ++idx) {
+            let system: MusicSystem = page.MusicSystems[idx];
+            this.drawMusicSystem(system);
+        }
+    }
+
+    private drawMusicSystem(musicSystem: MusicSystem): void {
+        for (let idx: number = 0, len: number = musicSystem.StaffLines.length; idx < len; ++idx) {
+            let staffLine: StaffLine = musicSystem.StaffLines[idx];
+            this.drawStaffLine(staffLine);
+        }
+    }
+
+    private drawStaffLine(staffLine: StaffLine): void {
+        for (let idx: number = 0, len: number = staffLine.Measures.length; idx < len; ++idx) {
+            let measure: StaffMeasure = staffLine.Measures[idx];
+            this.drawMeasure(measure);
+        }
+    }
+}

+ 21 - 0
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer.ts

@@ -0,0 +1,21 @@
+import {MusicSheetDrawer} from "../MusicSheetDrawer";
+import {RectangleF2D} from "../../../Common/DataObjects/RectangleF2D";
+import {StaffMeasure} from "../StaffMeasure";
+import {VexFlowMeasure} from "./VexFlowMeasure";
+/**
+ * Created by Matthias on 22.06.2016.
+ */
+export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
+    constructor() {
+        super();
+    }
+
+    protected drawMeasure(measure: StaffMeasure): void {
+        let vfMeasure: VexFlowMeasure = <VexFlowMeasure> measure;
+        throw new Error("not implemented");
+    }
+
+    protected applyScreenTransformation(rectangle: RectangleF2D): RectangleF2D {
+        throw new Error("not implemented");
+    }
+}

+ 2 - 5
src/MusicalScore/Graphical/VexFlow/VexFlowTextMeasurer.ts

@@ -6,10 +6,7 @@ import {FontStyles} from "../../../Common/Enums/FontStyles";
  */
 
 export class VexFlowTextMeasurer implements ITextMeasurer {
-    constructor() {
-    }
-    
-    computeTextWidthToHeightRatio(text: string, font: Fonts, style: FontStyles): number {
-        return text.length/2;
+    public computeTextWidthToHeightRatio(text: string, font: Fonts, style: FontStyles): number {
+        return text.length / 2;
     }
 }

+ 2 - 2
test/MusicalScore/ScoreCalculation/MusicSheetCalculator_Test.ts

@@ -23,7 +23,7 @@ describe("Music Sheet Calculator Tests", () => {
     }
 
     before((): void => {
-        
+        // ???
     });
 
     beforeEach((): void => {
@@ -42,7 +42,7 @@ describe("Music Sheet Calculator Tests", () => {
         score = new IXmlElement(doc.getElementsByTagName("score-partwise")[0]);
         // chai.expect(score).to.not.be.undefined;
         sheet = reader.createMusicSheet(score, path);
-        
+
         let graphicalSheet: GraphicalMusicSheet = new GraphicalMusicSheet(sheet, calculator);
         graphicalSheet.reCalculate();
         done();