use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class ActivityImpl method switchDimensionsToHorizontal.
/**
* At start: width=0, height=0
* Switch the dimensions of the activity to horizontal
*/
public void switchDimensionsToHorizontal() {
int width = 0;
int height = 0;
ActivityInterface activity = null;
Iterator<ActivityInterface> itr = getSubActivities().iterator();
// Iterates through all the subActivities
while (itr.hasNext()) {
activity = itr.next();
// Switch the dimension of each subActivity to the horizontal
activity.switchDimensionsToHorizontal();
}
// Get the width and the height
width = getDimensions().getWidth();
height = getDimensions().getHeight();
// Set the dimensions by switching the width and the height
getDimensions().setHeight(width);
getDimensions().setWidth(height);
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class ActivityImpl 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) {
// Get the dimensions of the SVG i.e. width and the height
dimensions = getDimensions();
// 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 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 ActivityImpl 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 If activity and its subActivities
*/
protected Element getArrows(SVGDocument doc) {
Element subGroup = null;
subGroup = doc.createElementNS("http://www.w3.org/2000/svg", "g");
if (subActivities != null) {
ActivityInterface activity = null;
String id = null;
// Coordinates of the start icon exit arrow
SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
// Coordinates of the end icon entry arrow
SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
SVGCoordinates activityExitCoords = null;
SVGCoordinates activityEntryCoords = null;
Iterator<ActivityInterface> itr = subActivities.iterator();
// Iterate through the subActivities
while (itr.hasNext()) {
activity = itr.next();
// Gets the entry and exit coordinates of the iterated activity
activityExitCoords = activity.getExitArrowCoords();
activityEntryCoords = activity.getEntryArrowCoords();
id = activity.getId();
// Define the entry arrow flow coordinates for the activity
subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
// Define the exit arrow flow coordinates for the activity
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
}
return subGroup;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class ElseImpl 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 = null;
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 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 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;
}
Aggregations