Search in sources :

Example 31 with ActivityInterface

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

the class IfImpl 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;
    // Positioning the endIcon
    int endXLeft = startXLeft + dimensions.getWidth() - getEndIconWidth() - (getYSpacing() / 2);
    int endYTop;
    int centerNHLayout = startYTop + (coreDimensions.getHeight() / 2);
    /* Checks whether its a simple layout i.e. whether the subActivities are instances of ElseIf or Else
           if so --> true , else --> false
         */
    if (isSimpleLayout()) {
        yTop = centreOfMyLayout - (getStartIconHeight() / 2);
        endYTop = centreOfMyLayout - (getEndIconHeight() / 2);
    } else {
        yTop = centerNHLayout - (getStartIconHeight() / 2);
        endYTop = centerNHLayout - (getEndIconHeight() / 2);
    }
    ActivityInterface activity = null;
    // Iterates through the subActivities
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    int childXLeft = xLeft + getStartIconWidth() + (getYSpacing() / 2);
    int childYTop = startYTop + (getXSpacing() / 2);
    // Process None Handlers First
    while (itr.hasNext()) {
        activity = itr.next();
        // Checks whether the iterated activity is an ElseIf or an Else
        if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
        } 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 + coreDimensions.getHeight();
    childXLeft = xLeft + getElseIfAdjustment();
    // Iterates through the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Checks whether the iterated activity is an ElseIf or an Else
        if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
            // 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 32 with ActivityInterface

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

the class OnMessageImpl method getDimensions.

/**
 * At the start: width=0, height=0
 *
 * @return dimensions of the 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;
        // Iterates through the subActivites inside the 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 width of the subActivity is greater than zero
            if (subActivityDim.getWidth() > width) {
                width += subActivityDim.getWidth();
            }
            /*As OnMessage should increase in height when the number of subActivities increase, height of each
                subActivity
                  is added to the height of the main activity
                */
            height += subActivityDim.getHeight();
        }
        /*After iterating through all the subActivities and altering the dimensions of the  activity
              to get more spacing , Xspacing and Yspacing is added to the height and the width of the  activity
            */
        height += getYSpacing() + getStartIconHeight() + (getYSpacing() / 2);
        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 33 with ActivityInterface

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

the class OnMessageImpl 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
 */
public 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);
    ActivityInterface activity;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    int childYTop;
    int childXLeft = xLeft + getStartIconWidth() + (getYSpacing() / 2);
    // Iterates through all the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Sets the yTop position of the iterated activity : childYTop= center of layout -(height of the activity)/2
        childYTop = centreOfMyLayout - (activity.getDimensions().getHeight() / 2);
        // 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 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 activity after setting the dimensions
    getDimensions().setXLeft(startXLeft);
    getDimensions().setYTop(startYTop);
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Example 34 with ActivityInterface

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

the class OnMessageImpl 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 OnMessage activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    Element subGroup = null;
    subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks for the subActivities
    if (subActivities != null) {
        ActivityInterface prevActivity = null;
        ActivityInterface activity = null;
        String id = null;
        // Gets the exit coordinates of the start icon
        SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
        SVGCoordinates exitCoords = null;
        SVGCoordinates entryCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            // Checks whether the previous activity is null
            if (prevActivity != null) {
                // Get the exit arrow coordinates of the previous activity
                exitCoords = prevActivity.getExitArrowCoords();
                // Get the entry arrow coordinates of the current activity
                entryCoords = activity.getEntryArrowCoords();
                // id is assigned with the id of the previous activity + id of the current activity
                id = prevActivity.getId() + "-" + activity.getId();
                /*If the previous activity is not null, then arrow flow is from the previous activity to the
                    current activity
                      This gives the coordinates of the start point and the end point
                    */
                subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), entryCoords.getXLeft(), entryCoords.getYTop(), id));
            } else {
                // Get the entry arrow coordinates of the current activity
                entryCoords = activity.getEntryArrowCoords();
                /*If the previous activity is null, then arrow flow is directly from the startIcon to the activity
                      This gives the coordinates of the start point and the end point
                    */
                subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), entryCoords.getXLeft(), entryCoords.getYTop(), id));
            }
            prevActivity = activity;
        }
    }
    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 35 with ActivityInterface

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

the class ProcessImpl 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 Process and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    if (subActivities != null) {
        // Gets the start activity of the process
        ActivityInterface startActivity = subActivities.get(0);
        // Gets the end activity of the process
        ActivityInterface endActivity = subActivities.get(subActivities.size() - 1);
        // Get the coordinates of the entry arrow of the start activity
        SVGCoordinates exitCoords = getExitArrowCoords();
        // Define the arrow flow according to the coordinates
        group.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), startActivity.getEntryArrowCoords().getXLeft(), startActivity.getEntryArrowCoords().getYTop(), name));
        // Get the coordinates of the entry arrows of the end activity
        SVGCoordinates entryCoords = getEndEntryArrowCoords();
        // Define the arrow flow according to the coordinates
        group.appendChild(getArrowDefinition(doc, endActivity.getExitArrowCoords().getXLeft(), endActivity.getExitArrowCoords().getYTop(), entryCoords.getXLeft(), entryCoords.getYTop(), name));
    }
    return group;
}
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)

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