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; }
protected void createGraphics(final ExternalNetElementType element) throws CanoniserException { final GraphicsType graphics = ANF_FACTORY.createGraphicsType(); graphics.setCpfId(generateUUID(CONTROLFLOW_ID_PREFIX, element.getId())); graphics.setId(generateUUID()); // Convert Vertex to ANF convertVertexLayout(getContext().getLayoutVertexForElement(element.getId()), graphics); // Add YAWL specific extensions final Collection<LayoutDecoratorFactsType> layoutDecorators = getContext().getLayoutDecoratorForElement(element.getId()); if (layoutDecorators != null) { for (final LayoutDecoratorFactsType decorator : layoutDecorators) { graphics .getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.DECORATOR, decorator, LayoutDecoratorFactsType.class)); } } if (getContext().getLayoutLabelForElement(element.getId()) != null) { graphics .getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.LABEL, getContext().getLayoutLabelForElement(element.getId()), LayoutLabelFactsType.class)); } getContext().getAnnotationResult().getAnnotation().add(graphics); }
/** * 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); }