Search in sources :

Example 1 with ActivityInterface

use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.

the class ForEachImpl method getArrows.

/**
 * Get the arrow coordinates of the activities
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the activity
 * @return An element which contains the arrow coordinates of the ForEach activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    Element subGroup = null;
    // Creating an SVG Container "g"
    subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks for the subActivities
    if (subActivities != null) {
        ActivityInterface activity = null;
        String id = null;
        SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
        SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
        SVGCoordinates activityExitCoords = null;
        SVGCoordinates activityEntryCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            id = activity.getId();
            // Gets the entry and exit coordinates of the iterated activity
            activityExitCoords = activity.getExitArrowCoords();
            activityEntryCoords = activity.getEntryArrowCoords();
            // Gives the coordinates of the entry arrow to the first activity from the startIcon
            subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
            // Gives the coordinates of the entry arrow to the endIcon of ForEach
            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
        }
    }
    return subGroup;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 2 with ActivityInterface

use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.

the class ScopeImpl method getDimensions.

/**
 * At the start: width=0, height=0
 *
 * @return dimensions of the composite activity i.e. the final width and height after doing calculations by
 * iterating
 * through the dimensions of the subActivities
 */
@Override
public SVGDimension getDimensions() {
    if (dimensions == null) {
        int width = 0;
        int height = 0;
        int coreWidth = 0;
        int coreHeight = 0;
        int conWidth = 0;
        int conHeight = 0;
        // Set the dimensions at the start to (0,0)
        dimensions = new SVGDimension(coreWidth, coreHeight);
        coreDimensions = new SVGDimension(coreWidth, coreHeight);
        conditionalDimensions = new SVGDimension(conWidth, conHeight);
        // Dimensons of the subActivities
        SVGDimension subActivityDim = null;
        ActivityInterface activity = null;
        // Iterates through the subActivites inside the composite activity
        Iterator<ActivityInterface> itr = getSubActivities().iterator();
        while (itr.hasNext()) {
            activity = itr.next();
            // Gets the dimensions of each subActivity separately
            subActivityDim = activity.getDimensions();
            /*Checks whether the subActivity is any of the handlers i.e. FaultHandler, TerminationHandler,
                CompensateHandler
                  or EventHandler
                */
            if (activity instanceof FaultHandlerImpl || activity instanceof TerminationHandlerImpl || activity instanceof CompensationHandlerImpl || activity instanceof EventHandlerImpl) {
                if (subActivityDim.getHeight() > conHeight) {
                    // height of the icon is added to the conditional height
                    conHeight = subActivityDim.getHeight();
                }
                // width of the subActivities added to the conditional width
                conWidth += subActivityDim.getWidth();
            } else if (activity instanceof RepeatUntilImpl || activity instanceof ForEachImpl || activity instanceof WhileImpl || activity instanceof IfImpl) {
                /* If the activity is an instance of ForEach, Repeat Until, While or If activity,
                     ySpacing = 70 is also added to the core height of the composite activity as the start icons
                     of those activities are placed on the scope of the composite activity, so it requires more spacing.
                    */
                if (subActivityDim.getWidth() > coreWidth) {
                    // width of the subActivities added to the core width
                    coreWidth = subActivityDim.getWidth();
                }
                coreHeight += subActivityDim.getHeight() + getYSpacing();
            } else {
                // If the subActivites are not instances of any handlers
                if (subActivityDim.getWidth() > coreWidth) {
                    // width of the subActivities added to the core width
                    coreWidth = subActivityDim.getWidth();
                }
                // height of the subActivities added to the core height
                coreHeight += subActivityDim.getHeight();
            }
        }
        // Spacing the core height by adding ySpacing + startIcon height + endIcon height
        coreHeight += getYSpacing() + getStartIconHeight() + getEndIconHeight();
        // Check if its a simple layout
        if (!isSimpleLayout()) {
            coreWidth += getXSpacing();
        }
        conHeight += getHandlerAdjustment();
        // Setting the core dimensions after calculations
        coreDimensions.setHeight(coreHeight);
        coreDimensions.setWidth(coreWidth);
        // Setting the conditional dimensions after calculations
        conditionalDimensions.setHeight(conHeight);
        conditionalDimensions.setWidth(conWidth);
        // Checks if the core height is greater than the conditional height
        if (coreHeight > conHeight) {
            height = coreHeight;
        } else {
            height = conHeight;
        }
        // core width and conditional width is added to the final width of the composite activity
        width = coreWidth + conWidth;
        // Get the final height and width by adding Xspacing and Yspacing
        height += getYSpacing();
        width += getXSpacing();
        // Set the Calculated dimensions for the SVG height and width
        dimensions.setWidth(width);
        dimensions.setHeight(height);
    }
    return dimensions;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) SVGDimension(org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)

Example 3 with ActivityInterface

use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.

the class ScopeImpl method layoutVertical.

/**
 * Sets the x and y positions of the activities
 * At the start: startXLeft=0, startYTop=0
 * centreOfMyLayout- center of the the SVG
 *
 * @param startXLeft x-coordinate
 * @param startYTop  y-coordinate
 */
public void layoutVertical(int startXLeft, int startYTop) {
    // Aligns the activities to the center of the layout
    int centreOfMyLayout = startXLeft + (getDimensions().getWidth() / 2);
    int xLeft = 0;
    int yTop = 0;
    int endXLeft = 0;
    int endYTop = 0;
    int centerNHLayout = startXLeft + (getCoreDimensions().getWidth() / 2);
    // Set the dimensions
    getDimensions().setXLeft(startXLeft);
    getDimensions().setYTop(startYTop);
    // Set the xLeft and yTop of the core dimensions
    getCoreDimensions().setXLeft(startXLeft + (getXSpacing() / 2));
    getCoreDimensions().setYTop(startYTop + (getYSpacing() / 2));
    /* Checks whether its a simple layout i.e. whether the subActivities are any handlers
           if so --> true , else --> false
         */
    if (isSimpleLayout()) {
        // Positioning the startIcon
        xLeft = centreOfMyLayout - (getStartIconWidth() / 2);
        yTop = startYTop + (getYSpacing() / 2);
        // Positioning the endIcon
        endXLeft = centreOfMyLayout - (getEndIconWidth() / 2);
        endYTop = startYTop + getDimensions().getHeight() - getEndIconHeight() - (getYSpacing() / 2);
    } else {
        // Positioning the startIcon
        xLeft = centerNHLayout - (getStartIconWidth() / 2) + (getXSpacing() / 2);
        yTop = getCoreDimensions().getYTop() + (getYSpacing() / 2);
        // Positioning the endIcon
        endXLeft = centerNHLayout - (getEndIconWidth() / 2) + (getXSpacing() / 2);
        endYTop = getCoreDimensions().getYTop() + getCoreDimensions().getHeight() - getEndIconHeight() - (getYSpacing() / 2);
    }
    ActivityInterface activity = null;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    int childYTop = 0;
    int childXLeft = 0;
    /* Checks whether its a simple layout i.e. whether the subActivities are any handlers
           if so --> true , else --> false
         */
    if (isSimpleLayout()) {
        // Adjusting the childXLeft and childYTop positions
        childYTop = yTop + getStartIconHeight() + (getYSpacing() / 2);
        childXLeft = startXLeft + (getXSpacing() / 2);
    } else {
        // Adjusting the childXLeft and childYTop positions
        childYTop = getCoreDimensions().getYTop() + getStartIconHeight() + (getYSpacing() / 2);
        childXLeft = getCoreDimensions().getXLeft() + (getXSpacing() / 2);
    }
    // Iterates through the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Checks whether the activity is of any handler type
        if (activity instanceof FaultHandlerImpl || activity instanceof TerminationHandlerImpl || activity instanceof CompensationHandlerImpl || activity instanceof EventHandlerImpl) {
        } else if (activity instanceof RepeatUntilImpl || activity instanceof ForEachImpl || activity instanceof WhileImpl || activity instanceof IfImpl) {
            /* If the activity inside Scope activity is an instance of ForEach, Repeat Until, While or If activity,
                then increase the yTop position of start icon of those activities , as the start icon is placed
                on the scope/box which contains the subActivities.This requires more spacing, so the yTop of the
                activity following it i.e. the activity after it is also increased.
                */
            int x = childYTop + (getYSpacing() / 2);
            // Sets the xLeft and yTop position of the iterated activity
            activity.layout(childXLeft, x);
            // Calculate the yTop position of the next activity
            childXLeft += activity.getDimensions().getWidth();
        } else {
            // Sets the xLeft and yTop position of the iterated activity
            activity.layout(childXLeft, childYTop);
            // Calculate the yTop position of the next activity
            childXLeft += activity.getDimensions().getWidth();
        }
    }
    // Process Handlers
    itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    childXLeft = startXLeft + getCoreDimensions().getWidth();
    childYTop = yTop + getHandlerAdjustment();
    // Iterates through the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Checks whether the activity is of any handler type
        if (activity instanceof FaultHandlerImpl || activity instanceof TerminationHandlerImpl || activity instanceof CompensationHandlerImpl || activity instanceof EventHandlerImpl) {
            // Sets the xLeft and yTop position of the iterated activity
            activity.layout(childXLeft, childYTop);
            childXLeft += activity.getDimensions().getWidth();
        }
    }
    // Sets the xLeft and yTop positions of the start icon
    setStartIconXLeft(xLeft);
    setStartIconYTop(yTop);
    // Sets the xLeft and yTop positions of the end icon
    setEndIconXLeft(endXLeft);
    setEndIconYTop(endYTop);
    // Sets the xLeft and yTop positions of the start icon text
    setStartIconTextXLeft(startXLeft + BOX_MARGIN);
    setStartIconTextYTop(startYTop + BOX_MARGIN + BPEL2SVGFactory.TEXT_ADJUST);
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Example 4 with ActivityInterface

use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.

the class ProcessImpl method getLinkArrows.

/**
 * Gets the Link arrow coordinates when there is a FLOW activity in the process
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the process
 * @return An element which contains the link arrow coordinates of the Process
 */
private Element getLinkArrows(SVGDocument doc) {
    Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks whether the any links exist
    if (links != null && !links.isEmpty()) {
        // Returns a collection-view of the map with the link names, sources(starting activity) and the target
        // (ending activity)
        Set linksSet = links.entrySet();
        Iterator linksIterator = linksSet.iterator();
        // Iterates through the links
        while (linksIterator.hasNext()) {
            Map.Entry<String, Link> link = (Map.Entry<String, Link>) linksIterator.next();
            // Gets the source/start activity of the link
            ActivityInterface startActivity = link.getValue().getSource();
            // Gets the target/end activity of the link
            ActivityInterface endActivity = link.getValue().getTarget();
            // Get the link name
            String linkName = link.getKey();
            // Check if the source and the target of the link contains a value
            if (endActivity != null && startActivity != null) {
                // Define the link flow/path by giving the coordinates of the start and end activity
                group.appendChild(drawLink(doc, startActivity.getExitArrowCoords().getXLeft(), startActivity.getExitArrowCoords().getYTop(), endActivity.getEntryArrowCoords().getXLeft(), endActivity.getEntryArrowCoords().getYTop(), startActivity.getStartIconWidth(), link.getKey(), linkName));
            }
        }
    }
    return group;
}
Also used : Set(java.util.Set) ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) Map(java.util.Map) Link(org.wso2.carbon.bpel.ui.bpel2svg.Link)

Example 5 with ActivityInterface

use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.

the class ProcessImpl method layoutVertical.

/**
 * Sets the x and y positions of the activities
 * At the start: startXLeft=0, startYTop=0
 * centreOfMyLayout- center of the the SVG
 *
 * @param startXLeft x-coordinate
 * @param startYTop  y-coordinate
 */
public void layoutVertical(int startXLeft, int startYTop) {
    // Aligns the activities to the center of the layout
    int centreOfMyLayout = startXLeft + (dimensions.getWidth() / 2);
    // Positioning the startIcon
    int xLeft = centreOfMyLayout - (getStartIconWidth() / 2);
    int yTop = startYTop + (getYSpacing() / 2);
    // Positioning the endIcon
    int endXLeft = centreOfMyLayout - (getEndIconWidth() / 2);
    int endYTop = startYTop + dimensions.getHeight() - getEndIconHeight() - (getYSpacing() / 2);
    ActivityInterface activity = null;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    int childYTop = yTop + getStartIconHeight() + (getYSpacing() / 2);
    int childXLeft = startXLeft + (getXSpacing() / 2);
    // Iterate through the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Sets the xLeft and yTop position of the iterated activity
        activity.layout(childXLeft, childYTop);
        childYTop += activity.getDimensions().getHeight();
    }
    // Sets the xLeft and yTop positions of the start icon
    setStartIconXLeft(xLeft);
    setStartIconYTop(yTop);
    // Sets the xLeft and yTop positions of the end icon
    setEndIconXLeft(endXLeft);
    setEndIconYTop(endYTop);
    // Sets the xLeft and yTop positions of the SVG  of the process after setting the dimensions
    getDimensions().setXLeft(startXLeft);
    getDimensions().setYTop(startYTop);
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Aggregations

ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)52 SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)14 OMElement (org.apache.axiom.om.OMElement)12 Element (org.w3c.dom.Element)11 SVGDimension (org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)10 Iterator (java.util.Iterator)2 Link (org.wso2.carbon.bpel.ui.bpel2svg.Link)2 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1