Bug 438604 - Offset in x,y coordinates between *.bpmn and exported Image
Summary: Offset in x,y coordinates between *.bpmn and exported Image
Status: ASSIGNED
Alias: None
Product: BPMN2Modeler
Classification: SOA
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement with 1 vote (vote)
Target Milestone: future   Edit
Assignee: benjamin wirtz CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-01 03:42 EDT by benjamin wirtz CLA
Modified: 2014-07-17 15:02 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description benjamin wirtz CLA 2014-07-01 03:42:01 EDT
When I drag a Task with x=10,y=10 to the upper corner the designer makes a new gap between the edge of the pain and the task (50pix) but in the BPMN File the value of y is now 0.!
So when I now export a Diagram. The x,y Values in BPMN file are not equal to the x,y Coordinates in the Diagram. 

This is related to bug 423326.

According to the BPMN2 spec, coordinates must be non-negative. This is why, if you move a shape into negative coordinate territory, the editor normalizes everything back to zero. This is done during file saving in Bpmn2ModelerResourceImpl$Bpmn2ModelerXMLSave#saveElement(o,f).

Solution: do a negative coordinate check just before the image is saved and offset the image exporter by the min X/Y values if negative (a pretty good idea, but I'm not sure of the amount of work involved)
Comment 1 Robert Brodt CLA 2014-07-17 15:01:48 EDT
I'm afraid the best I can do right now is to add a comment at the beginning of the file when it is saved, something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at x=-50 y=0 -->
<bpmn2:definitions .../>

You can then grab this comment string in Java code after the document is loaded, like this:

import org.eclipse.bpmn2.DocumentRoot;
import org.eclipse.bpmn2.Bpmn2Resource;
import org.eclipse.emf.ecore.util.FeatureMap;
...
	Bpmn2Resource resource = getResource(); /* get the EMF Resource from somewhere */
	DocumentRoot documentRoot = resource.getContents().get(0);
	FeatureMap featureMap = documentRoot.getMixed();
	if (featureMap.size()>0) {
		FeatureMap.Entry e = featureMap.get(0);
		if (e.getEStructuralFeature() == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT) {
			String comment = e.getValue();
			// parse the comment string here...
		}
	}


Will that work for you?