GraphicalChordSymbolContainer.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import {Label} from "../Label";
  2. import {GraphicalLabel} from "./GraphicalLabel";
  3. import {ChordSymbolContainer} from "../VoiceData/ChordSymbolContainer";
  4. import {BoundingBox} from "./BoundingBox";
  5. import {GraphicalObject} from "./GraphicalObject";
  6. import {PointF2D} from "../../Common/DataObjects/PointF2D";
  7. import {EngravingRules} from "./EngravingRules";
  8. import { KeyInstruction } from "../VoiceData/Instructions/KeyInstruction";
  9. export class GraphicalChordSymbolContainer extends GraphicalObject {
  10. private chordSymbolContainer: ChordSymbolContainer;
  11. private graphicalLabel: GraphicalLabel;
  12. private rules: EngravingRules;
  13. constructor(chordSymbolContainer: ChordSymbolContainer, parent: BoundingBox, textHeight: number,
  14. keyInstruction: KeyInstruction, transposeHalftones: number, rules: EngravingRules) {
  15. super();
  16. this.chordSymbolContainer = chordSymbolContainer;
  17. this.boundingBox = new BoundingBox(this, parent);
  18. this.rules = rules;
  19. this.calculateLabel(textHeight, transposeHalftones, keyInstruction);
  20. }
  21. public get GetChordSymbolContainer(): ChordSymbolContainer {
  22. return this.chordSymbolContainer;
  23. }
  24. public get GraphicalLabel(): GraphicalLabel {
  25. return this.graphicalLabel;
  26. }
  27. private calculateLabel(textHeight: number, transposeHalftones: number, keyInstruction: KeyInstruction): void {
  28. const text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones, keyInstruction);
  29. this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, this.rules.ChordSymbolTextAlignment, this.rules, this.boundingBox);
  30. this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(this.rules.ChordSymbolRelativeXOffset, 0.0);
  31. this.graphicalLabel.Label.colorDefault = this.rules.DefaultColorChordSymbol;
  32. }
  33. }