use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class SequenceImpl 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 Sequence activity and its subActivities
*/
protected Element getArrows(SVGDocument doc) {
Element subGroup = null;
// Creating an SVG Container "g" to place the activities
subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
// Checks for the subActivities
if (subActivities != null) {
ActivityInterface prevActivity = null;
ActivityInterface activity = null;
String id = null;
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();
/*Check whether the activity is a Throw activity, if so setCheck()= true
This check is done to remove the exit arrow coming from the Throw activity,as when the process
reaches
a Throw activity, the process terminates.
*/
if (activity instanceof ThrowImpl) {
setCheck(true);
}
if (prevActivity instanceof SourcesImpl || prevActivity instanceof SourceImpl || prevActivity instanceof TargetImpl || prevActivity instanceof TargetsImpl || activity instanceof SourcesImpl || activity instanceof SourceImpl || activity instanceof TargetImpl || activity instanceof TargetsImpl || prevActivity instanceof ThrowImpl) {
// No exit arrow for Source or Target as it doesn't have an icon specified.
// Checks whether the previous activity is a Throw activity, if so no exit arrow
} else {
subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), entryCoords.getXLeft(), entryCoords.getYTop(), id));
}
}
prevActivity = activity;
}
}
return subGroup;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class ForEachImpl 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);
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 ForEachImpl 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();
}
/*As ForEach should increase in height when the number of subActivities increase, height of each
subActivity
is added to the height of the main/composite activity
*/
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() * 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 ForEachImpl 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 = centreOfMyLayout - (getStartIconWidth() / 2);
int yTop = startYTop - (getYSpacing() / 4);
// Positioning the endIcon
int endXLeft = centreOfMyLayout - (getEndIconWidth() / 2);
int endYTop = startYTop + dimensions.getHeight() + 15 - getEndIconHeight();
ActivityInterface activity = null;
Iterator<ActivityInterface> itr = getSubActivities().iterator();
// Adjusting the childXLeft and childYTop positions
int childYTop = yTop + getStartIconHeight() + getYSpacing();
int childXLeft = startXLeft + (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 ScopeImpl 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 Scope activity and its subActivities
*/
protected Element getArrows(SVGDocument doc) {
if (subActivities != null) {
Element subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
ActivityInterface prevActivity = 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();
// Coordinates of the start arrow of the EventHandler
SVGCoordinates myStartEventCoords = getStartEventCoords();
// Coordinates of the start arrow of the TerminationHandler
SVGCoordinates myStartTerminationCoords = getStartTerminationCoords();
// Coordinates of the start arrow of the CompensationHandler
SVGCoordinates myStartCompensationCoords = getStartCompensationCoords();
// Coordinates of the start arrow of the FaultHandler
SVGCoordinates myStartFaultCoords = getStartFaultCoords();
SVGCoordinates activityEntryCoords = null;
SVGCoordinates activityExitCoords = null;
Iterator<ActivityInterface> itr = subActivities.iterator();
// Iterates through the subActivities
while (itr.hasNext()) {
activity = itr.next();
// Gets the entry and exit coordinates of the iterated activity
activityEntryCoords = activity.getEntryArrowCoords();
activityExitCoords = activity.getExitArrowCoords();
// id is assigned with the id of the previous activity + id of the current activity
id = getId() + "-" + activity.getId();
// defined.
if (activity instanceof FaultHandlerImpl) {
subGroup.appendChild(getArrowDefinition(doc, myStartFaultCoords.getXLeft(), myStartFaultCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else if (activity instanceof TerminationHandlerImpl) {
subGroup.appendChild(getArrowDefinition(doc, myStartTerminationCoords.getXLeft(), myStartTerminationCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else if (activity instanceof CompensationHandlerImpl) {
subGroup.appendChild(getArrowDefinition(doc, myStartCompensationCoords.getXLeft(), myStartCompensationCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else if (activity instanceof EventHandlerImpl) {
subGroup.appendChild(getArrowDefinition(doc, myStartEventCoords.getXLeft(), myStartEventCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else {
// If the activity is not a handler type, then the entry and the exit coordinates of the activity
// are defined
subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
}
return subGroup;
}
return null;
}
Aggregations