AbstractGraphicalExpression.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { GraphicalObject } from "./GraphicalObject";
  2. import { GraphicalLabel } from "./GraphicalLabel";
  3. import { StaffLine } from "./StaffLine";
  4. import { BoundingBox } from "./BoundingBox";
  5. import { AbstractExpression, PlacementEnum } from "../VoiceData/Expressions/AbstractExpression";
  6. import { EngravingRules } from "./EngravingRules";
  7. import { SourceMeasure } from "../VoiceData";
  8. export abstract class AbstractGraphicalExpression extends GraphicalObject {
  9. protected label: GraphicalLabel;
  10. protected parentStaffLine: StaffLine;
  11. /** Internal cache of read expression */
  12. protected expression: AbstractExpression;
  13. /** EngravingRules for positioning */
  14. protected rules: EngravingRules;
  15. protected parentMeasure: SourceMeasure;
  16. constructor(parentStaffline: StaffLine, expression: AbstractExpression, measure: SourceMeasure) {
  17. super();
  18. this.expression = expression;
  19. this.parentMeasure = measure; // could be undefined!
  20. this.boundingBox = new BoundingBox(this, parentStaffline.PositionAndShape);
  21. this.parentStaffLine = parentStaffline;
  22. this.parentStaffLine.AbstractExpressions.push(this);
  23. this.rules = parentStaffline.ParentMusicSystem.rules;
  24. }
  25. /** Graphical label of the expression if available */
  26. get Label(): GraphicalLabel { return this.label; }
  27. /** Staffline where the expression is attached to */
  28. public get ParentStaffLine(): StaffLine { return this.parentStaffLine; }
  29. public get SourceExpression(): AbstractExpression { return this.expression; }
  30. public get Placement(): PlacementEnum { return this.expression.Placement; }
  31. //#region abstract methods
  32. public abstract updateSkyBottomLine(): void;
  33. //#endregion
  34. }