Search in sources :

Example 46 with SVGCoordinates

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

the class ElseImpl 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 Else activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    // Checks for the subActivities
    if (subActivities != null) {
        ActivityInterface prevActivity = null;
        ActivityInterface activity = null;
        String id = null;
        ActivityInterface seqActivity = null;
        SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
        // SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
        SVGCoordinates exitCoords = null;
        SVGCoordinates activityEntryCoords = null;
        // SVGCoordinates activityExitCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        // Creating an SVG Container "g"
        Element subGroup = doc.createElementNS(SVG_NAMESPACE, "g");
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            // Gets the entry and exit coordinates of the iterated activity
            activityEntryCoords = activity.getEntryArrowCoords();
            /*If the activity is a Sequence, then all the subActivities inside the Sequence is iterated and
                 checked for
                any Throw activities inside it.
                If a Throw activity is present : throwOrNot =true ,
                Else : throwOrNot =false
                 */
            if (activity instanceof SequenceImpl) {
                List<ActivityInterface> sub = activity.getSubActivities();
                Iterator<ActivityInterface> as = sub.iterator();
                while (as.hasNext()) {
                    seqActivity = as.next();
                    if (seqActivity instanceof ThrowImpl) {
                        throwOrNot = true;
                        break;
                    } else {
                        throwOrNot = false;
                    }
                }
            }
            // Checks whether the activity is a Throw activity
            if (activity instanceof ThrowImpl) {
                throwOrNot = true;
            }
            // Checks whether the previous activity is null
            if (prevActivity != null) {
                // Get the exit arrow coordinates of the previous activity
                exitCoords = prevActivity.getExitArrowCoords();
                // 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(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
            } else {
                /*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(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
            }
            // current activity is assigned to the previous activity
            prevActivity = activity;
        }
        return subGroup;
    }
    return null;
}
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 47 with SVGCoordinates

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

the class EventHandlerImpl method getExitArrowCoords.

/**
 * At the start: xLeft=0, yTop=0
 * 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 = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = getEndIconXLeft() + (getEndIconWidth() / 2);
        yTop = getEndIconYTop() + getEndIconHeight();
    } else {
        xLeft = getEndIconXLeft() + getEndIconWidth();
        yTop = getEndIconYTop() + (getEndIconHeight() / 2);
    }
    // Returns the calculated coordinate points of the exit arrow
    SVGCoordinates coords = new SVGCoordinates(xLeft, yTop);
    return coords;
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 48 with SVGCoordinates

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

the class EventHandlerImpl method getEntryArrowCoords.

/**
 * At the start: xLeft=0, yTop=0
 * Calculates the coordinates of the arrow which enters an activity
 *
 * @return coordinates/entry point of the entry arrow for the activities
 * After Calculations(Vertical Layout): xLeft=Xleft of Icon + (width of icon)/2 , yTop= Ytop of the Icon
 */
@Override
public SVGCoordinates getEntryArrowCoords() {
    int xLeft = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = getDimensions().getXLeft() + (getDimensions().getWidth() / 2);
        yTop = getDimensions().getYTop() + BOX_MARGIN;
    } else {
        xLeft = getDimensions().getXLeft() + BOX_MARGIN;
        yTop = getDimensions().getYTop() + (getDimensions().getHeight() / 2);
    }
    // Returns the calculated coordinate points of the entry arrow
    SVGCoordinates coords = new SVGCoordinates(xLeft, yTop);
    return coords;
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 49 with SVGCoordinates

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

the class ProcessImpl method getEndEntryArrowCoords.

/**
 * At the start: xLeft= xLeft of endIcon + (width of endIcon)/2, yTop= yTop of endIcon
 * Calculates the coordinates of the entry arrow of the end activity
 *
 * @return coordinates/exit point of the entry arrow for the end activity
 */
public SVGCoordinates getEndEntryArrowCoords() {
    int xLeft = getEndIconXLeft() + (getEndIconWidth() / 2);
    int yTop = getEndIconYTop();
    if (!layoutManager.isVerticalLayout()) {
        xLeft = getEndIconXLeft();
        yTop = getEndIconYTop() + (getEndIconHeight() / 2);
    }
    // Returns the calculated coordinate points of the entry arrow for end activity
    SVGCoordinates coords = new SVGCoordinates(xLeft, yTop);
    return coords;
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 50 with SVGCoordinates

use of org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates 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)

Aggregations

SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)59 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)14 OMElement (org.apache.axiom.om.OMElement)10 Element (org.w3c.dom.Element)10