/**
   * 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);
  }
 private LineType convertFlowLineStyle(final LayoutFlowFactsType flowLayout) {
   final LineType lineType = ANF_FACTORY.createLineType();
   lineType.setWidth(new BigDecimal(DEFAULT_LINE_SIZE));
   for (final JAXBElement<?> obj :
       flowLayout.getAttributes().getAutosizeOrBackgroundColorOrBendable()) {
     if (obj.getName().getLocalPart().equalsIgnoreCase(LINE_STYLE)) {
       lineType.setWidth(new BigDecimal((BigInteger) obj.getValue()));
     }
   }
   return lineType;
 }
 private Collection<PositionType> convertFlowPositions(final LayoutFlowFactsType flowLayout)
     throws ParseException {
   final ArrayList<PositionType> positions = new ArrayList<PositionType>();
   for (final JAXBElement<?> obj :
       flowLayout.getAttributes().getAutosizeOrBackgroundColorOrBendable()) {
     if (obj.getValue() instanceof LayoutPointsType) {
       final LayoutPointsType points = (LayoutPointsType) obj.getValue();
       for (final LayoutPointType point : points.getValue()) {
         final PositionType position = ANF_FACTORY.createPositionType();
         position.setX(convertToBigDecimal(point.getX()));
         position.setY(convertToBigDecimal(point.getY()));
         positions.add(position);
       }
     }
   }
   return positions;
 }