use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class ProcessImpl 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 SVG of the process 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 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;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class SequenceImpl 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 + (getXSpacing() / 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;
// 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 SequenceImpl method getEntryArrowCoords.
/**
* At the start: xLeft=Xleft of Icon + (width of icon)/2 , yTop= Ytop of the Icon
* 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 = 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 for Sub Activities
if (subActivities != null && subActivities.size() > 0) {
ActivityInterface activity = subActivities.get(0);
// Get the entry arrow coordinate for each subActivity
coords = activity.getEntryArrowCoords();
}
// Returns the calculated coordinate points of the entry arrow
return coords;
}
use of org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface in project carbon-business-process by wso2.
the class ActivityImpl method processSubActivities.
/**
* Get the subactivites in the bpel process
* Processes the subActivities each one separately, if the activity name matches any of the element tags
* then the constructor of that activity implementation is invoked
*
* @param omElement process definition of the bpel process
* @return activity
*/
public ActivityInterface processSubActivities(OMElement omElement) {
ActivityInterface endActivity = null;
// Checks whether omElement contains a value
if (omElement != null) {
ActivityInterface activity = null;
Iterator iterator = omElement.getChildElements();
// Iterates through the subActivities
while (iterator.hasNext()) {
OMElement tmpElement = (OMElement) iterator.next();
if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ASSIGN_START_TAG) && isIncludeAssigns()) {
activity = new AssignImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EMPTY_START_TAG)) {
activity = new EmptyImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.CATCHALL_START_TAG)) {
activity = new CatchAllImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.CATCH_START_TAG)) {
activity = new CatchImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATESCOPE_START_TAG)) {
activity = new CompensateScopeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATE_START_TAG)) {
activity = new CompensateImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATIONHANDLER_START_TAG)) {
activity = new CompensationHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ELSEIF_START_TAG)) {
activity = new ElseIfImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ELSE_START_TAG)) {
activity = new ElseImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EVENTHANDLER_START_TAG)) {
activity = new EventHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EXIT_START_TAG)) {
activity = new ExitImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FAULTHANDLER_START_TAG)) {
activity = new FaultHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FLOW_START_TAG)) {
activity = new FlowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FOREACH_START_TAG)) {
activity = new ForEachImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.IF_START_TAG)) {
activity = new IfImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.INVOKE_START_TAG)) {
activity = new InvokeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONALARM_START_TAG)) {
activity = new OnAlarmImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONEVENT_START_TAG)) {
activity = new OnEventImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONMESSAGE_START_TAG)) {
activity = new OnMessageImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PICK_START_TAG)) {
activity = new PickImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PROCESS_START_TAG)) {
activity = new ProcessImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.RECEIVE_START_TAG)) {
activity = new ReceiveImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.REPEATUNTIL_START_TAG)) {
activity = new RepeatUntilImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.REPLY_START_TAG)) {
activity = new ReplyImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.RETHROW_START_TAG)) {
activity = new ReThrowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SCOPE_START_TAG)) {
activity = new ScopeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SEQUENCE_START_TAG)) {
activity = new SequenceImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SOURCE_START_TAG)) {
// source
activity = new SourceImpl(tmpElement, this);
if (activity.getAttributes().get(0).getAttribute().equals("linkName")) {
if (links.containsKey(activity.getAttributes().get(0).getValue())) {
// if a entry for the particular link name already exists
links.get(activity.getAttributes().get(0).getValue()).setSource(this.parent);
} else {
// if the link name doesnot exist i.e. if the link is a new link
// Create a new Link object
Link link = new Link();
// Set the source(Start activity) as the parent activity
link.setSource(this.parent);
links.put(activity.getAttributes().get(0).getValue(), link);
}
// Add the parent activity of the activity to the source-list
sources.add(this.parent);
}
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SOURCES_START_TAG)) {
activity = new SourcesImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TARGET_START_TAG)) {
// target;
activity = new TargetImpl(tmpElement, this);
if (activity.getAttributes().get(0).getAttribute().equals("linkName")) {
if (links.containsKey(activity.getAttributes().get(0).getValue())) {
// if a entry for the particular link name already exists
links.get(activity.getAttributes().get(0).getValue()).setTarget(this.parent);
} else {
// if the link name doesnot exist i.e. if the link is a new link
// Create a new Link object
Link link = new Link();
// Set the target(End activity) as the parent activity
link.setTarget(this.parent);
links.put(activity.getAttributes().get(0).getValue(), link);
}
// Add the parent activity of the activity to the target-list
targets.add(this.parent);
}
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TARGETS_START_TAG)) {
activity = new TargetsImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TERMINATIONHANDLER_START_TAG)) {
activity = new TerminationHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.THROW_START_TAG)) {
activity = new ThrowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.WAIT_START_TAG)) {
activity = new WaitImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.WHILE_START_TAG)) {
activity = new WhileImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(getEndTag())) {
break;
} else {
continue;
}
// Set the link properties i.e. the link name, source of the link and the target of the link
activity.setLinkProperties(links, sources, targets);
// Add the activity to the subActivities list
subActivities.add(activity);
// Checks if the activity has any child activities
if (tmpElement.getChildElements().hasNext()) {
// The child activities are processed again by invoking the same method recursively
ActivityInterface replyActivity = activity.processSubActivities(tmpElement);
if (replyActivity != null) {
subActivities.add(replyActivity);
}
}
if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PROCESS_START_TAG)) {
break;
}
}
}
return endActivity;
}
Aggregations