GraphicalChordSymbolContainer.ts 1.5 KB

12345678910111213141516171819202122232425262728
  1. import {TextAlignment} from "../../Common/Enums/TextAlignment";
  2. import {Label} from "../Label";
  3. import {GraphicalLabel} from "./GraphicalLabel";
  4. import {ChordSymbolContainer} from "../VoiceData/ChordSymbolContainer";
  5. import {BoundingBox} from "./BoundingBox";
  6. import {GraphicalObject} from "./GraphicalObject";
  7. import {PointF_2D} from "../../Common/DataObjects/PointF_2D";
  8. export class GraphicalChordSymbolContainer extends GraphicalObject {
  9. private chordSymbolContainer: ChordSymbolContainer;
  10. private graphicalLabel: GraphicalLabel;
  11. constructor(chordSymbolContainer: ChordSymbolContainer, parent: BoundingBox, textHeight: number, transposeHalftones: number) {
  12. this.chordSymbolContainer = chordSymbolContainer;
  13. this.boundingBox = new BoundingBox(parent, this);
  14. this.calculateLabel(textHeight, transposeHalftones);
  15. }
  16. public get GetChordSymbolContainer(): ChordSymbolContainer {
  17. return this.chordSymbolContainer;
  18. }
  19. public get GetGraphicalLabel(): GraphicalLabel {
  20. return this.graphicalLabel;
  21. }
  22. private calculateLabel(textHeight: number, transposeHalftones: number): void {
  23. var text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones);
  24. this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, TextAlignment.CenterBottom, this.boundingBox);
  25. this.graphicalLabel.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
  26. this.boundingBox.ChildElements.Add(this.graphicalLabel.PositionAndShape);
  27. }
  28. }