Search in sources :

Example 51 with ActivityInterface

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

the class ScopeImpl method isSimpleLayout.

/**
 * @return false-->  if the subActivities are instances of handlers i.e. FaultHandler, TerminationHandler,
 * CompensateHandler
 * or EventHandler
 * true -->  otherwise
 */
private boolean isSimpleLayout() {
    boolean simple = true;
    ActivityInterface activity = null;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Iterates through the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Checks whether the subActivities are instances of any handlers
        if (activity instanceof FaultHandlerImpl || activity instanceof TerminationHandlerImpl || activity instanceof CompensationHandlerImpl || activity instanceof EventHandlerImpl) {
            simple = false;
            break;
        }
    }
    return simple;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Example 52 with ActivityInterface

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

the class ScopeImpl method layoutHorizontal.

/**
 * Sets the x and y positions of the activities
 * At the start: startXLeft=0, startYTop=0
 *
 * @param startXLeft x-coordinate
 * @param startYTop  y-coordinate
 *                   centreOfMyLayout- center of the the SVG
 */
private void layoutHorizontal(int startXLeft, int startYTop) {
    int centreOfMyLayout = startYTop + (dimensions.getHeight() / 2);
    int xLeft = 0;
    int yTop = 0;
    int endXLeft = 0;
    int endYTop = 0;
    int centerNHLayout = startYTop + (coreDimensions.getHeight() / 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
        yTop = centreOfMyLayout - (getStartIconHeight() / 2);
        xLeft = startXLeft + (getYSpacing() / 2);
        // Positioning the endIcon
        endYTop = centreOfMyLayout - (getEndIconHeight() / 2);
        endXLeft = getCoreDimensions().getXLeft() + getCoreDimensions().getWidth() - getEndIconWidth() - (getXSpacing() / 2);
    } else {
        // Positioning the startIcon
        yTop = centerNHLayout - (getStartIconHeight() / 2) + (getYSpacing() / 2);
        xLeft = getCoreDimensions().getXLeft() + (getXSpacing() / 2);
        // Positioning the endIcon
        endYTop = centerNHLayout - (getEndIconHeight() / 2) + (getYSpacing() / 2);
        endXLeft = getCoreDimensions().getXLeft() + getCoreDimensions().getWidth() - getEndIconWidth() - (getXSpacing() / 2);
    }
    ActivityInterface activity = null;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    int childXLeft = 0;
    int childYTop = 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
        childXLeft = xLeft + getStartIconWidth() + (getYSpacing() / 2);
        childYTop = startYTop + (getXSpacing() / 2);
    } else {
        // Adjusting the childXLeft and childYTop positions
        childXLeft = getCoreDimensions().getXLeft() + getStartIconWidth() + (getYSpacing() / 2);
        childYTop = getCoreDimensions().getYTop() + (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 {
            // Sets the xLeft and yTop position of the iterated activity
            activity.layout(childXLeft, childYTop);
            childYTop += activity.getDimensions().getHeight();
        }
    }
    // Process Handlers
    itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    childYTop = startYTop + getCoreDimensions().getHeight() + (getYSpacing() / 2);
    childXLeft = xLeft + 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);
            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 start icon text
    setStartIconTextXLeft(startXLeft + BOX_MARGIN);
    setStartIconTextYTop(startYTop + BOX_MARGIN + BPEL2SVGFactory.TEXT_ADJUST);
}
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