whole-line-point-helper.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import konva from "konva";
  2. import {
  3. WholeLinePointAttrib,
  4. WholeLinePointProps,
  5. } from "../view/whole-line-point";
  6. import { pointHelperZIndex } from "../style";
  7. import { Entity } from "../../entity";
  8. import { Label } from "konva/lib/shapes/Label";
  9. export class WholeLinePointHelper extends Entity<WholeLinePointAttrib, Label> {
  10. static namespace = "point-helper";
  11. constructor(props: WholeLinePointProps) {
  12. props.zIndex = props.zIndex || pointHelperZIndex;
  13. props.name = props.name || WholeLinePointHelper.namespace + props.attrib.id;
  14. super(props);
  15. }
  16. initShape() {
  17. const label = new konva.Label({ opacity: 0.75, name: "label" });
  18. label.add(
  19. new konva.Tag({
  20. name: "tag",
  21. fill: "rgba(0, 0, 0, 0.8)",
  22. pointerDirection: "down",
  23. pointerWidth: 5,
  24. pointerHeight: 5,
  25. lineJoin: "round",
  26. shadowColor: "black",
  27. shadowBlur: 10,
  28. shadowOffsetX: 10,
  29. shadowOffsetY: 10,
  30. shadowOpacity: 0.5,
  31. }),
  32. new konva.Text({
  33. name: "text",
  34. text: `P${this.attrib.id}`,
  35. fontFamily: "Calibri",
  36. fontSize: 10,
  37. padding: 3,
  38. fill: "white",
  39. })
  40. );
  41. return label;
  42. }
  43. diffRedraw(): void {
  44. this.shape.x(this.attrib.x).y(this.attrib.y);
  45. }
  46. }