Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Zoom Bug in XYLayoutEditPolicy

We run into a bug in ths class XYLayoutEditPolicy with zoom != 1. In the method getConstraintFor(), the same rectangle changes the both x and y value (+1 or -1) after the  following two operations
        child.getFigure().translateToAbsolute(rect);
        child.getFigure().translateToRelative(rect);

This problem appears when we move the graphic element by keyborad with ctrl+arrow (you can test it with our last plugin: eclipseuml_1.1.9.20030320).

The solution is to define the precision Rectangle class as precisionPoint (attached in this email) and change a bit of this method as following:

protected Object getConstraintFor(

ChangeBoundsRequest request,

GraphicalEditPart child)

{

Rectangle bounds = child.getFigure().getBounds();

PrecisionRectangle rect = new PrecisionRectangle(bounds);

child.getFigure().translateToAbsolute(rect);

// original code:

// rect = request.getTransformedRectangle(rect);

{

rect.translate(request.getMoveDelta());

Dimension sizeDelta = request.getSizeDelta();

rect.width += sizeDelta.width;

rect.height+= sizeDelta.height;

}

child.getFigure().translateToRelative(rect);

rect.translate(getLayoutOrigin().getNegated());

if (RequestConstants.REQ_MOVE_CHILDREN.equals(request.getType()))

{

Rectangle cons = (Rectangle) getCurrentConstraintFor(child);

rect.setSize(cons.width, cons.height);

}

if (RequestConstants.REQ_RESIZE_CHILDREN.equals(request.getType()))

{

Dimension minSize = getMinimumSizeFor(child);

if (rect.width < minSize.width)

rect.width = minSize.width;

if (rect.height < minSize.height)

rect.height = minSize.height;

}

return getConstraintFor(rect.getCopy());

}

Please let me know if you need more precision

 

julien

omondo

 

Attachment: PrecisionRectangle.java
Description: Binary data


Back to the top