Search in sources :

Example 1 with SVGDimension

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

the class SourcesImpl method getDimensions.

/**
 * SVGDimensions (width and height) are set to zero as no icon is specified
 * @return dimensions of the SVG i.e. width and the height
 */
public SVGDimension getDimensions() {
    SVGDimension obj = new SVGDimension();
    obj.setHeight(0);
    obj.setWidth(0);
    return obj;
}
Also used : SVGDimension(org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)

Example 2 with SVGDimension

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

the class TargetsImpl method getDimensions.

/**
 * SVGDimensions (width and height) are set to zero as no icon is specified
 * @return dimensions of the SVG i.e. width and the height
 */
public SVGDimension getDimensions() {
    SVGDimension obj = new SVGDimension();
    obj.setHeight(0);
    obj.setWidth(0);
    return obj;
}
Also used : SVGDimension(org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)

Example 3 with SVGDimension

use of org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension 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 4 with SVGDimension

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

the class SequenceImpl 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;
        // 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 width of the subActivity is greater than zero
            if (subActivityDim.getWidth() > width) {
                width += subActivityDim.getWidth();
            }
            if (activity instanceof RepeatUntilImpl || activity instanceof ForEachImpl || activity instanceof WhileImpl || activity instanceof IfImpl) {
                height += subActivityDim.getHeight() + getYSpacing();
            } else {
                height += subActivityDim.getHeight();
            }
        }
        /*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() + getStartIconHeight();
        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 5 with SVGDimension

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

the class SourceImpl method getDimensions.

/**
 * SVGDimensions (width and height) are set to zero as no icon is specified
 *
 * @return dimensions of the SVG i.e. width and the height
 */
public SVGDimension getDimensions() {
    SVGDimension obj = new SVGDimension();
    obj.setHeight(0);
    obj.setWidth(0);
    return obj;
}
Also used : SVGDimension(org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)

Aggregations

SVGDimension (org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)16 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)10 NoSuchElementException (java.util.NoSuchElementException)1