Search in sources :

Example 41 with ActivityInterface

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

the class EventHandlerImpl 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;
        // Set the dimensions at the start to (0,0)
        dimensions = new SVGDimension(width, height);
        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 height of the subActivity is greater than zero
            if (subActivityDim.getHeight() > height) {
                height += subActivityDim.getHeight();
            }
            // width of the subActivities is added to the width of the composite activity
            width += subActivityDim.getWidth();
        }
        /*After iterating through all the subActivities and altering the dimensions of the composite activity
              to get more spacing , Xspacing and Yspacing is added to the height and the width of the composite activity
            */
        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 42 with ActivityInterface

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

the class EventHandlerImpl 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) {
    // Aligns the activities to the center of the layout
    int centreOfMyLayout = startYTop + (dimensions.getHeight() / 2);
    // Positioning the startIcon
    int xLeft = startXLeft + (getYSpacing() / 2);
    int yTop = centreOfMyLayout - (getStartIconHeight() / 2);
    // Positioning the endIcon
    int endXLeft = startXLeft + dimensions.getWidth() - getEndIconWidth() - (getYSpacing() / 2);
    int endYTop = centreOfMyLayout - (getEndIconHeight() / 2);
    ActivityInterface activity = null;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    int childXLeft = startXLeft + (getYSpacing() / 2);
    int childYTop = startYTop + (getXSpacing() / 2);
    // Iterates through all 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 start icon text
    setStartIconTextXLeft(startXLeft + BOX_MARGIN);
    setStartIconTextYTop(startYTop + BOX_MARGIN + BPEL2SVGFactory.TEXT_ADJUST);
    // Sets the xLeft and yTop positions of the SVG of the composite activity after setting the dimensions
    getDimensions().setXLeft(startXLeft);
    getDimensions().setYTop(startYTop);
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Example 43 with ActivityInterface

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

the class ProcessImpl 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;
        // Set the dimensions at the start to (0,0)
        dimensions = new SVGDimension(width, height);
        // Dimensons of the subActivities
        SVGDimension subActivityDim = null;
        ActivityInterface activity = null;
        Iterator<ActivityInterface> itr = getSubActivities().iterator();
        try {
            // Iterate through the subActivities
            while (itr.hasNext()) {
                activity = itr.next();
                // Gets the dimensions of each subActivity separately
                subActivityDim = activity.getDimensions();
                // Checks whether the width of the subActivity is greater than zero
                if (subActivityDim.getWidth() > width) {
                    width += subActivityDim.getWidth();
                }
                /*As the Process should increase in height when the number of subActivities increase, height of
                     each
                      subActivity is added to the height of the main/composite activity
                      */
                height += subActivityDim.getHeight();
            }
        } catch (NoSuchElementException e) {
            log.error("Invalid Element access", e);
        }
        /*After iterating through all the subActivities and altering the dimensions of the composite activity
              to get more spacing , Xspacing and Yspacing is added to the height and the width of the composite activity
            */
        height += ((getYSpacing() * 2) + getStartIconHeight() + getEndIconHeight());
        width += getXSpacing();
        // Set the calculated dimensions
        dimensions.setWidth(width);
        dimensions.setHeight(height);
        // Set the final SVG height and width
        layoutManager.setSvgHeight(height);
        layoutManager.setSvgWidth(width);
        // Check if the layout is vertical or not
        if (!layoutManager.isVerticalLayout()) {
            switchDimensionsToHorizontal();
        }
    }
    return dimensions;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) SVGDimension(org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension) NoSuchElementException(java.util.NoSuchElementException)

Example 44 with ActivityInterface

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

the class SequenceImpl method getExitArrowCoords.

/**
 * At the start: Xleft of Icon + (width of icon)/2 , yTop= Ytop of the Icon
 * Calculates the coordinates of the arrow which leaves an activity
 *
 * @return coordinates/exit point of the exit arrow for the activities
 */
@Override
public SVGCoordinates getExitArrowCoords() {
    int xLeft = getStartIconXLeft() + (getStartIconWidth() / 2);
    int yTop = getStartIconYTop();
    SVGCoordinates coords = null;
    if (layoutManager.isVerticalLayout()) {
        // Sets the coordinates of the arrow
        coords = new SVGCoordinates(xLeft, yTop);
    } else {
        coords = new SVGCoordinates(yTop, xLeft);
    }
    // Check Sub Activities
    if (subActivities != null && subActivities.size() > 0) {
        ActivityInterface activity = subActivities.get(subActivities.size() - 1);
        // Get the exit arrow coordinate for each subActivity
        coords = activity.getExitArrowCoords();
    }
    // Returns the calculated coordinate points of the exit arrow
    return coords;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 45 with ActivityInterface

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

the class SequenceImpl 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);
    ActivityInterface activity = null;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    int childYTop = yTop;
    int childXLeft;
    // Iterates through all the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Sets the xLeft position of the iterated activity : childXleft= center of the layout - (width of the
        // activity icon)/2
        childXLeft = centreOfMyLayout - activity.getDimensions().getWidth() / 2;
        /* If the activity inside Sequence 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.
                 */
        if (activity instanceof RepeatUntilImpl || activity instanceof ForEachImpl || activity instanceof WhileImpl || activity instanceof IfImpl) {
            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
            childYTop += activity.getDimensions().getHeight() + getYSpacing();
        } else {
            // Sets the xLeft and yTop position of the iterated activity
            activity.layout(childXLeft, childYTop);
            // Calculate the yTop position of the next activity
            childYTop += activity.getDimensions().getHeight();
        }
    /*   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 start icon text
    setStartIconTextXLeft(startXLeft + BOX_MARGIN);
    setStartIconTextYTop(startYTop + BOX_MARGIN + BPEL2SVGFactory.TEXT_ADJUST);
    // Sets the xLeft and yTop positions of the SVG  of the composite activity 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