Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » [Incubator][Draw2d] Wrong Path translation in SWTGraphics
[Incubator][Draw2d] Wrong Path translation in SWTGraphics [message #1700249] Wed, 01 July 2015 08:03
Jerome Sivadier is currently offline Jerome SivadierFriend
Messages: 15
Registered: May 2015
Junior Member
Hello RAP devs,

I'm currently using the incubation library draw2d + GEF (version 0.1.20141203) for RAP and I have found a strange behavior on SWT "Path" translation. After hours of debugging, I have found that in the class "SWTGraphics", the method "#initTransform" just WARNS the developer about a regression on RAP but does not fix anything... Indeed when the user uses the scrollbar on a GEF diagram, the shapes that use a SWT Path are not moved accordingly.

To solve this behavior, I have created a method that only works to translate Path(s) but it's already a beginning =). Here is the new implementation of "#fillPath" and "#drawPath" in "SWTGraphics":
@Override
public void drawPath(Path path) {
	checkPaint();
	path = translatePath(path);
	gc.drawPath(path);
}

@Override
public void fillPath(Path path) {
	checkFill();
	path = translatePath(path);
	gc.fillPath(path);
}

/**
 * RAP patch to avoid the unavailable SWT TRANSFORM. Only works for
 * translations
 * 
 * @param path
 *            the path to translate
 * @return a new path if a translation is to be done
 */
private Path translatePath(Path path) {
	if (translateX != 0 || translateY != 0) {
		PathData data = new PathData();
		PathData oldData = path.getPathData();
		data.types = oldData.types;
		data.points = new float[oldData.points.length];

		for (int count = 0; count < oldData.points.length; count++) {
			if (count % 2 == 0) {
				data.points[count] = oldData.points[count] + translateX;
			} else {
				data.points[count] = oldData.points[count] + translateY;
			}
		}
		return new Path(path.getDevice(), data);
	}
	return path;
}


You can find here the enhancement proposal on bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=471544

Best regards,
Jerome

[Updated on: Wed, 01 July 2015 08:06]

Report message to a moderator

Previous Topic:jetty authentication in Eclipse Luna
Next Topic:Downloading several files to the same client directory
Goto Forum:
  


Current Time: Thu Sep 19 16:34:43 GMT 2024

Powered by FUDForum. Page generated in 0.03718 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top