protected void changeShapeSize(
      GraphicsType annType,
      NodeType node,
      BigDecimal newHeight,
      BigDecimal newWidth,
      Map<String, AnnotationData> annotations) {
    super.changeShapeSize(annType, node, newHeight, newWidth, annotations);

    BigDecimal oldH = annType.getSize().getHeight();
    BigDecimal oldW = annType.getSize().getWidth();
    BigDecimal oldX = annType.getPosition().get(0).getX();
    BigDecimal oldY = annType.getPosition().get(0).getY();

    BigDecimal newX = oldW.subtract(newWidth).divide(divisor).add(oldX);
    BigDecimal newY = oldH.subtract(newHeight).divide(divisor).add(oldY);

    SizeType size = new SizeType();
    size.setHeight(newHeight);
    size.setWidth(newWidth);
    PositionType position = new PositionType();
    position.setX(newX);
    position.setY(newY);

    annType.setSize(size);
    annType.getPosition().remove(0);
    annType.getPosition().add(position);

    annotations.put(
        node.getId(), new AnnotationData(oldX, oldY, newX, newY, oldH, oldW, newHeight, newWidth));
  }
  private AnnotationsType buildANF() {
    AnnotationsType anf = new AnnotationsType();
    SizeType size = getSizeType();

    GraphicsType event = new GraphicsType();
    event.setId("4");
    event.setCpfId("1");
    event.setSize(size);
    event.getPosition().add(getPositionType(100, 100));

    GraphicsType task = new GraphicsType();
    task.setId("5");
    task.setCpfId("2");
    task.setSize(size);
    task.getPosition().add(getPositionType(200, 200));

    GraphicsType edge = new GraphicsType();
    edge.setId("6");
    edge.setCpfId("3");
    edge.setSize(size);
    edge.getPosition().add(getPositionType(100, 100));
    edge.getPosition().add(getPositionType(200, 200));

    anf.getAnnotation().add(event);
    anf.getAnnotation().add(task);
    anf.getAnnotation().add(edge);

    return anf;
  }
  /**
   * Create the graphical annotation for a YAWL edge.
   *
   * @param sourceId of the YAWL source
   * @param targetId of the YAWL target
   * @throws CanoniserException
   */
  protected void createGraphicsForFlow(final String sourceId, final String targetId)
      throws CanoniserException {
    final GraphicsType graphics = ANF_FACTORY.createGraphicsType();
    graphics.setCpfId(
        generateUUID(CONTROLFLOW_ID_PREFIX, getContext().buildEdgeId(sourceId, targetId)));
    graphics.setId(generateUUID());

    final LayoutFlowFactsType flowLayout =
        getContext().getLayoutFlow(getContext().buildEdgeId(sourceId, targetId));

    // Convert and add YAWL specific extension
    if (flowLayout != null) {
      graphics
          .getAny()
          .add(
              ExtensionUtils.marshalYAWLFragment(
                  ExtensionUtils.FLOW,
                  getContext().getLayoutFlow(getContext().buildEdgeId(sourceId, targetId)),
                  LayoutFlowFactsType.class));
      graphics.setLine(convertFlowLineStyle(flowLayout));
      try {
        graphics.getPosition().addAll(convertFlowPositions(flowLayout));
        if (graphics.getPosition().isEmpty()) {
          // Calculate start and end position
          LayoutVertexFactsType sourceVertex = getContext().getLayoutVertexForElement(sourceId);
          LayoutVertexFactsType targetVertex = getContext().getLayoutVertexForElement(targetId);
          if (sourceVertex != null && targetVertex != null) {
            try {
              graphics
                  .getPosition()
                  .add(calculateFlowPosition(sourceVertex, flowLayout.getPorts().getOut()));
              graphics
                  .getPosition()
                  .add(calculateFlowPosition(targetVertex, flowLayout.getPorts().getIn()));
            } catch (ParseException e) {
              throw new CanoniserException(
                  "Could not calculate default position for flow from "
                      + sourceId
                      + " to "
                      + targetId,
                  e);
            }
          }
        }

      } catch (final ParseException e) {
        throw new CanoniserException(
            "Could not convert layout of flow from " + sourceId + " to " + targetId, e);
      }
    }

    getContext().getAnnotationResult().getAnnotation().add(graphics);
  }
  /* Changes the size of the Gateway Node. */
  private void manipulateSplit(
      CanonicalProcessType cpf,
      AnnotationsType anf,
      GraphicsType splitGraphicsType,
      NodeType splitNode) {
    int index;
    BigDecimal newX, newY;
    PositionType position;
    GraphicsType targetAnn, targetEdgeAnn;
    SplitType split = (SplitType) splitNode;

    BigDecimal oldH = splitGraphicsType.getSize().getHeight();
    BigDecimal oldW = splitGraphicsType.getSize().getWidth();
    BigDecimal oldX = splitGraphicsType.getPosition().get(0).getX();
    BigDecimal oldY = splitGraphicsType.getPosition().get(0).getY();

    Map<EdgeType, NodeType> targets = findSplitNodeTargets(cpf, split.getId());
    for (Map.Entry<EdgeType, NodeType> target : targets.entrySet()) {
      targetAnn = findGraphicsType(anf, target.getValue().getId());
      targetEdgeAnn = findGraphicsType(anf, target.getKey().getId());

      if (targetAnn != null) {
        newX =
            targetAnn
                .getSize()
                .getWidth()
                .divide(divisor)
                .add(targetAnn.getPosition().get(0).getX());
        newY = targetAnn.getPosition().get(0).getY();

        index = 0;
        for (PositionType targetEdgePos : targetEdgeAnn.getPosition()) {
          if (!((targetEdgePos.getX().compareTo(oldX) > 0)
              && (targetEdgePos.getX().compareTo(oldX.add(oldW)) < 0)
              && (targetEdgePos.getY().compareTo(oldY) > 0)
              && (targetEdgePos.getY().compareTo(oldY.add(oldH)) < 0))) {
            position = new PositionType();
            position.setX(newX);
            position.setY(newY);

            targetEdgeAnn.getPosition().set(index, position);
          }
          index++;
        }
      }
    }
  }
  /* Changes the position of the edges X and Y. */
  private Map<PositionType, PositionType> changeLocation(
      GraphicsType graphicsType, AnnotationData annData) {
    int index = 0;
    PositionType newPos = new PositionType();
    Map<PositionType, PositionType> replace = new HashMap<>();

    for (PositionType pos : graphicsType.getPosition()) {
      if ((pos.getX().compareTo(annData.getOldX()) >= 0)
          && (pos.getX().compareTo(annData.getOldX().add(annData.getOldW())) <= 0)
          && (pos.getY().compareTo(annData.getOldY()) >= 0)
          && (pos.getY().compareTo(annData.getOldY().add(annData.getOldH())) <= 0)) {
        newPos.setX(annData.getNewX().add(annData.getNewW().divide(divisor)));
        newPos.setY(annData.getNewY().add(annData.getNewH().divide(divisor)));
        graphicsType.getPosition().set(index, newPos);
      }
      index++;
    }

    return replace;
  }
 private void convertLayoutRectangleAttribute(
     final LayoutRectangleType rect, final GraphicsType graphics) throws ParseException {
   final PositionType position = ANF_FACTORY.createPositionType();
   position.setX(convertToBigDecimal(rect.getX()));
   position.setY(convertToBigDecimal(rect.getY()));
   graphics.getPosition().add(position);
   final SizeType size = ANF_FACTORY.createSizeType();
   size.setHeight(convertToBigDecimal(rect.getH()));
   size.setWidth(convertToBigDecimal(rect.getW()));
   graphics.setSize(size);
 }