use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocessInLanes.
public void updateShapeBoundsInSubprocessInLanes(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
for (FlowElement subEle : sub.getFlowElements()) {
Bounds subEleBounds = getBoundsForElement(subEle, plane);
if (subEleBounds != null) {
subEleBounds.setX(subEleBounds.getX() + parentX);
subEleBounds.setY(subEleBounds.getY() + parentY);
}
if (subEle instanceof SubProcess) {
updateShapeBoundsInSubprocessInLanes(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
}
}
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method createBpmnShapeForElement.
private void createBpmnShapeForElement(BpmnDiFactory factory, BPMNPlane plane, BaseElement element) {
Bounds bounds = _bounds.get(element.getId());
if (bounds != null) {
BPMNShape shape = factory.createBPMNShape();
shape.setBpmnElement(element);
shape.setBounds(bounds);
plane.getPlaneElement().add(shape);
}
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyBaseElementProperties.
protected void applyBaseElementProperties(BaseElement baseElement, Map<String, String> properties) {
if (properties.get("documentation") != null && !"".equals(properties.get("documentation"))) {
if (baseElement instanceof Definitions) {
this.processDocs = properties.get("documentation");
} else {
baseElement.getDocumentation().add(createDocumentation(wrapInCDATABlock(properties.get("documentation"))));
}
}
if (baseElement.getId() == null || baseElement.getId().length() < 1) {
baseElement.setId(properties.get("resourceId"));
}
if (properties.get("bgcolor") != null && properties.get("bgcolor").length() > 0) {
if (!(_elementColors.containsKey(baseElement.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("bgcolor:" + properties.get("bgcolor"));
_elementColors.put(baseElement.getId(), colorsList);
} else {
_elementColors.get(baseElement.getId()).add("bgcolor:" + properties.get("bgcolor"));
}
}
if (properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "selectable", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("isselectable"));
baseElement.getAnyAttribute().add(extensionEntry);
}
if (properties.get("bordercolor") != null && properties.get("bordercolor").length() > 0) {
if (!(_elementColors.containsKey(baseElement.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("bordercolor:" + properties.get("bordercolor"));
_elementColors.put(baseElement.getId(), colorsList);
} else {
_elementColors.get(baseElement.getId()).add("bordercolor:" + properties.get("bordercolor"));
}
}
if (properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "fontsize", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("fontsize"));
baseElement.getAnyAttribute().add(extensionEntry);
}
if (properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
if (!(_elementColors.containsKey(baseElement.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("fontcolor:" + properties.get("fontcolor"));
_elementColors.put(baseElement.getId(), colorsList);
} else {
_elementColors.get(baseElement.getId()).add("fontcolor:" + properties.get("fontcolor"));
}
}
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method updateShapeBounds.
public void updateShapeBounds(Definitions def, BPMNPlane plane, BaseElement ele) {
if (ele instanceof Lane) {
Lane nextLane = (Lane) ele;
Bounds laneBounds = getBoundsForElement(nextLane, plane);
updateShapeBoundsInLanes(plane, ele, nextLane, laneBounds.getX(), laneBounds.getY());
} else {
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
List<FlowElement> flowElements = process.getFlowElements();
boolean foundAsTopLevel = false;
for (FlowElement fe : flowElements) {
if (fe.getId().equals(ele.getId())) {
foundAsTopLevel = true;
break;
}
}
if (!foundAsTopLevel) {
for (FlowElement fe : flowElements) {
if (fe instanceof SubProcess) {
SubProcess sp = (SubProcess) fe;
// process if this subprocess is not in a lane already. otherwise we already updated it
if (sp.getLanes().size() < 1) {
// find the subprocess bounds
Bounds subprocessBounds = getBoundsForElement(fe, plane);
if (subprocessBounds != null) {
updateShapeBoundsInSubprocess(plane, ele, (SubProcess) fe, subprocessBounds.getX(), subprocessBounds.getY());
}
}
}
}
}
}
}
}
}
use of org.eclipse.bpmn2.BaseElement in project kie-wb-common by kiegroup.
the class DIZorderComparator method compareShape.
private int compareShape(BPMNShape a, BPMNShape b) {
BaseElement aElem = a.getBpmnElement();
BaseElement bElem = b.getBpmnElement();
boolean aIsSecondTier = aElem instanceof Lane || aElem instanceof SubProcess;
boolean bIsSecondTier = bElem instanceof Lane || bElem instanceof SubProcess;
if (aIsSecondTier && bIsSecondTier) {
if (isParent(aElem, bElem)) {
return -1;
} else if (isParent(bElem, aElem)) {
return 1;
}
return 0;
} else if (aIsSecondTier && !bIsSecondTier) {
return -1;
} else if (!aIsSecondTier && bIsSecondTier) {
return 1;
}
return 0;
}
Aggregations