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 04:06] by Moderator