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); }
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); }
protected void convertVertexLayout( final LayoutVertexFactsType vertex, final GraphicsType graphics) throws CanoniserException { if (vertex != null) { final FillType fill = ANF_FACTORY.createFillType(); // Convert all Attributes final LayoutAttributesFactsType attr = vertex.getAttributes(); for (final JAXBElement<?> element : attr.getAutosizeOrBackgroundColorOrBendable()) { final Object elementValue = element.getValue(); if (elementValue instanceof LayoutRectangleType) { try { convertLayoutRectangleAttribute((LayoutRectangleType) elementValue, graphics); } catch (final ParseException e) { throw new CanoniserException( "Could not convert layout of element " + vertex.getId(), e); } } if (element.getName().getLocalPart().equals(BACKGROUND_COLOR) && element.getValue() != null) { final BigInteger color = (BigInteger) element.getValue(); fill.setColor(ConversionUtils.convertColorToString(color.intValue())); } } fill.setImage(vertex.getIconpath()); graphics.setFill(fill); } }
private PositionType calculateFlowPosition( final LayoutVertexFactsType vertex, final BigInteger port) throws ParseException { PositionType position = ANF_FACTORY.createPositionType(); LayoutRectangleType rect = getRectangleFromVertex(vertex); // TODO decide based on port position.setX(convertToBigDecimal(rect.getX())); position.setY(convertToBigDecimal(rect.getY())); return position; }
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; }
protected void createDocumentation( final ExternalNetElementType element, final String documentation) throws CanoniserException { final DocumentationType d = ANF_FACTORY.createDocumentationType(); d.setCpfId(generateUUID(CONTROLFLOW_ID_PREFIX, element.getId())); d.setId(generateUUID()); d.getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.DOCUMENTATION, documentation, String.class)); getContext().getAnnotationResult().getAnnotation().add(d); }
/** * 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 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; }