use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class FlowImpl 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 height of the subActivity is greater than zero
if (subActivityDim.getHeight() > height) {
height += subActivityDim.getHeight();
}
// Width of each subActivity is added to the final width of the main/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() * 2) + getStartIconHeight() + getEndIconHeight();
width += getXSpacing();
// Set the Calculated dimensions for the SVG height and width
dimensions.setWidth(width);
dimensions.setHeight(height);
}
return dimensions;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class FlowImpl 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) {
if (dimensions != null) {
// 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);
// Positioning the endIcon
int endXLeft = centreOfMyLayout - (getEndIconWidth() / 2);
int endYTop = startYTop + dimensions.getHeight() - getEndIconHeight() - (getYSpacing() / 2);
ActivityInterface activity = null;
Iterator<ActivityInterface> itr = getSubActivities().iterator();
// Adjusting the childXLeft and childYTop positions
int childYTop = yTop + getStartIconHeight() + (getYSpacing() / 2);
int childXLeft = startXLeft + (getXSpacing() / 2);
// Iterates through all the subActivities
while (itr.hasNext()) {
activity = itr.next();
/* If the activity inside Flow activity is an instance of If activity, then setCheckIfinFlow becomes
true.
This If check is done to space the subActivities when an If activity is inside a Flow activity.
This is a special case.
*/
if (activity instanceof IfImpl) {
((IfImpl) activity).setCheckIfinFlow(true);
}
/* If the activity inside Flow 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
childXLeft += activity.getDimensions().getWidth();
} else {
// Sets the xLeft and yTop position of the iterated activity
activity.layout(childXLeft, childYTop);
// Calculate the yTop position of the next activity
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 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);
}
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class FlowImpl 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 = xLeft + getStartIconWidth() + (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);
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class IfImpl 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;
int yTop = startYTop - (getYSpacing() / 4);
// Positioning the endIcon
int endXLeft;
int endYTop = startYTop + dimensions.getHeight() + 15 - getEndIconHeight();
int centerNHLayout = startXLeft + (coreDimensions.getWidth() / 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()) {
xLeft = centreOfMyLayout - (getStartIconWidth() / 2);
endXLeft = centreOfMyLayout - (getEndIconWidth() / 2);
} else {
xLeft = centerNHLayout - (getStartIconWidth() / 2) + (getXSpacing() / 2);
endXLeft = centerNHLayout - (getEndIconWidth() / 2) + (getXSpacing() / 2);
}
ActivityInterface activity = null;
// Iterates through the subActivities
Iterator<ActivityInterface> itr = getSubActivities().iterator();
// Adjusting the childXLeft and childYTop positions
int childYTop = yTop + getStartIconHeight() + getYSpacing();
int childXLeft = startXLeft + (getXSpacing() / 2);
// Process None Handlers First
while (itr.hasNext()) {
activity = itr.next();
/*
* This if check is a special case. It is done only when there is a If activity inside a Flow activity.
* When Flow activity iterates its subActivities, if a IF acivity is present it makes the isCheckIfinFlow
* (true).
* This is done to increase the spacing of the subActivities inside IF when its parent is a FLOW activity
* */
if (this.isCheckIfinFlow() == true) {
// Checks whether the subActivity is a Sequence activity
if (activity instanceof SequenceImpl) {
childYTop = childYTop + getEndIconWidth() / 2;
// Sets the xLeft and yTop position of the iterated activity
activity.layout(childXLeft, childYTop);
childXLeft += activity.getDimensions().getWidth();
} else {
// For all other activities except for Sequence
childYTop = childYTop + getEndIconWidth() / 2 + 20;
// Sets the xLeft and yTop position of the iterated activity
activity.layout(childXLeft, childYTop);
childXLeft += activity.getDimensions().getWidth();
}
} else {
// 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);
childXLeft += activity.getDimensions().getWidth();
}
}
}
// Process Handlers
itr = getSubActivities().iterator();
// Adjusting the childXLeft and childYTop positions
childXLeft = startXLeft + coreDimensions.getWidth();
childYTop = yTop + 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);
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 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);
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class IfImpl 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 a ElseIf or Else activity
if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
// Checks whether the icon height is greater than the conditional height
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 the subActivites are not instances of ElseIf and Else
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();
/* The ElseIf spacing or adjustment is added to the conditional height as the conditional dimensions are
associated
with ElseIf and Else activities
*/
conHeight += getElseIfAdjustment();
// 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;
height += getYSpacing();
width += getXSpacing();
// Set the Calculated dimensions for the SVG height and width
dimensions.setWidth(width);
dimensions.setHeight(height);
}
return dimensions;
}
Aggregations