setFishbonePosition method

  1. @override
void setFishbonePosition(
  1. Offset value
)
override

Implementation

@override
void setFishbonePosition(Offset value) {
  if (getNodeType() != NodeType.root) {
    if (getRightItems().isEmpty && getLeftItems().isEmpty) {
      if (getParentNode()?.getNodeType() == NodeType.root) {
        setFishboneWidth((getSize()?.width ?? 0) / 2);
      } else {
        IMindMapNode? topNode = getFishboneTopNode();
        if (topNode != null) {
          if (getMindMap()?.getFishboneMapType() ==
              FishboneMapType.leftToRight) {
            if (topNode.getFishboneNodeMode() == FishboneNodeMode.up) {
              double h =
                  (getSize()?.height ?? 0) +
                  value.dy -
                  topNode.getFishbonePosition().dy -
                  (topNode.getSize()?.height ?? 0) / 2;
              double r = value.dx + (getSize()?.width ?? 0) + h;
              double w =
                  r -
                  topNode.getFishbonePosition().dx -
                  (topNode.getSize()?.width ?? 0) / 2;
              setFishboneWidth(w);
            } else {
              double h = topNode.getFishbonePosition().dy - value.dy;
              double r = value.dx + (getSize()?.width ?? 0) + h;
              double w =
                  r -
                  topNode.getFishbonePosition().dx -
                  (topNode.getSize()?.width ?? 0) / 2;
              setFishboneWidth(w);
            }
          } else {
            if (topNode.getFishboneNodeMode() == FishboneNodeMode.up) {
              double h =
                  (getSize()?.height ?? 0) +
                  value.dy -
                  topNode.getFishbonePosition().dy -
                  (topNode.getSize()?.height ?? 0) / 2;
              double r = value.dx - h;
              double w =
                  topNode.getFishbonePosition().dx +
                  (topNode.getSize()?.width ?? 0) / 2 -
                  r;
              setFishboneWidth(w);
            } else {
              double h = topNode.getFishbonePosition().dy - value.dy;
              double r = value.dx - h;
              double w =
                  topNode.getFishbonePosition().dx +
                  (topNode.getSize()?.width ?? 0) / 2 -
                  r;
              setFishboneWidth(w);
            }
          }
        }
      }
    }
  }
  _fishbonePosition = value;
}