GraphicalUnknownExpression.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { StaffLine } from "./StaffLine";
  2. import { GraphicalLabel } from "./GraphicalLabel";
  3. import { AbstractGraphicalExpression } from "./AbstractGraphicalExpression";
  4. import { PlacementEnum, AbstractExpression } from "../VoiceData/Expressions/AbstractExpression";
  5. import { MultiExpression } from "../VoiceData/Expressions/MultiExpression";
  6. import { SkyBottomLineCalculator } from "./SkyBottomLineCalculator";
  7. import log from "loglevel";
  8. import { SourceMeasure } from "../VoiceData/SourceMeasure";
  9. export class GraphicalUnknownExpression extends AbstractGraphicalExpression {
  10. public sourceMultiExpression: MultiExpression;
  11. constructor(staffLine: StaffLine, label: GraphicalLabel, placement: PlacementEnum, measure: SourceMeasure,
  12. sourceMultiExpression: MultiExpression = undefined) {
  13. super(staffLine, new AbstractExpression(placement), measure);
  14. this.label = label;
  15. this.sourceMultiExpression = sourceMultiExpression;
  16. }
  17. public updateSkyBottomLine(): void {
  18. // update Sky-BottomLine
  19. const skyBottomLineCalculator: SkyBottomLineCalculator = this.parentStaffLine.SkyBottomLineCalculator;
  20. const left: number = this.label.PositionAndShape.RelativePosition.x + this.label.PositionAndShape.BorderMarginLeft;
  21. const right: number = this.label.PositionAndShape.RelativePosition.x + this.label.PositionAndShape.BorderMarginRight;
  22. switch (this.Placement) {
  23. case PlacementEnum.Above:
  24. const yValueAbove: number = this.label.PositionAndShape.BorderMarginTop + this.label.PositionAndShape.RelativePosition.y;
  25. skyBottomLineCalculator.updateSkyLineInRange(left, right, yValueAbove);
  26. break;
  27. case PlacementEnum.Below:
  28. const yValueBelow: number = this.label.PositionAndShape.BorderMarginBottom + this.label.PositionAndShape.RelativePosition.y;
  29. skyBottomLineCalculator.updateBottomLineInRange(left, right, yValueBelow);
  30. break;
  31. default:
  32. log.error("Placement for GraphicalUnknownExpression is unknown");
  33. }
  34. }
  35. }