Prechádzať zdrojové kódy

All Ties are finally visible - "that was not easy!!"
Fixed Binary Search usage - was originally with length but expects now end index.
Fixed Dictionary Usages where key is a class. Created a class that creates a unique string id.

Matthias 8 rokov pred
rodič
commit
d7008cfd59

+ 0 - 1
src/MusicalScore/Graphical/GraphicalLabel.ts

@@ -10,7 +10,6 @@ import {MusicSheetCalculator} from "./MusicSheetCalculator";
  */
 export class GraphicalLabel extends Clickable {
     private label: Label;
-
     constructor(label: Label, textHeight: number, alignment: TextAlignment, parent: BoundingBox = undefined) {
         super();
         this.label = label;

+ 1 - 2
src/MusicalScore/Graphical/GraphicalMusicSheet.ts

@@ -327,8 +327,7 @@ export class GraphicalMusicSheet {
         let index: number = CollectionUtil.binarySearch(this.verticalGraphicalStaffEntryContainers,
                                                         new VerticalGraphicalStaffEntryContainer(0, timestamp),
                                                         VerticalGraphicalStaffEntryContainer.compareByTimestamp,
-                                                        startIndex,
-                                                        this.verticalGraphicalStaffEntryContainers.length - startIndex);
+                                                        startIndex);
         if (index >= 0) {
             return this.verticalGraphicalStaffEntryContainers[index];
         }

+ 3 - 1
src/MusicalScore/VoiceData/SourceMeasure.ts

@@ -11,9 +11,11 @@ import {MultiTempoExpression} from "./Expressions/MultiTempoExpression";
 import {KeyInstruction} from "./Instructions/KeyInstruction";
 import {AbstractNotationInstruction} from "./Instructions/AbstractNotationInstruction";
 import {Repetition} from "../MusicSource/Repetition";
+import {BaseIdClass} from "../../Util/BaseIdClass";
 
-export class SourceMeasure {
+export class SourceMeasure extends BaseIdClass {
     constructor(completeNumberOfStaves: number) {
+        super();
         this.completeNumberOfStaves = completeNumberOfStaves;
         this.implicitMeasure = false;
         this.breakSystemAfter = false;

+ 1 - 1
src/MusicalScore/VoiceData/Tie.ts

@@ -2,7 +2,7 @@ import {Note} from "./Note";
 import {Beam} from "./Beam";
 import {Fraction} from "../../Common/DataObjects/Fraction";
 import {Tuplet} from "./Tuplet";
-import {BaseIdClass} from "./BaseIdClass";
+import {BaseIdClass} from "../../Util/BaseIdClass";
 
 export class Tie extends BaseIdClass {
 

+ 14 - 0
src/Util/BaseIdClass.ts

@@ -0,0 +1,14 @@
+import * as shortid from "shortid";
+
+export abstract class BaseIdClass {
+
+    protected instanceId: string;
+
+    constructor() {
+        this.instanceId = shortid.generate();
+    }
+
+    public toString(): string {
+        return this.instanceId;
+    }
+}

+ 1 - 1
src/Util/CollectionUtil.ts

@@ -46,7 +46,7 @@ export class CollectionUtil {
                                   element: T,
                                   cmp: (elem1: T, elem2: T) => number,
                                   startIndex: number = 0,
-                                  endIndex: number = array.length): number {
+                                  endIndex: number = array.length - 1): number {
         let mid: number = 1;
         while (startIndex < endIndex) {
             mid = Math.floor((startIndex + endIndex) / 2);