use of org.eclipse.gef.handles.HandleBounds in project tdi-studio-se by Talend.
the class TalendConnectionHandleLocator method relocate.
/*
* (non-Javadoc)
*
* @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
*/
@Override
public void relocate(IFigure target) {
Rectangle bounds = reference instanceof HandleBounds ? ((HandleBounds) reference).getHandleBounds().getCopy() : reference.getBounds().getCopy();
Point center = bounds.getCenter();
Point cursorPosition = new Point(center.x + bounds.width / 2, center.y);
borderPoint.setLocation(bounds.x + bounds.width, cursorPosition.y);
side = PositionConstants.EAST;
Point borderPointTranslated = borderPoint.getCopy();
reference.translateToAbsolute(bounds);
target.translateToRelative(bounds);
reference.translateToAbsolute(borderPointTranslated);
target.translateToRelative(borderPointTranslated);
int height = target.getBounds().height;
int halfHeight = height / 2;
if (side == PositionConstants.EAST) {
target.setLocation(borderPointTranslated.getTranslated(new Dimension(1, -halfHeight)));
}
}
use of org.eclipse.gef.handles.HandleBounds in project yamcs-studio by yamcs.
the class PolyPointDragTracker method getSourceBounds.
/**
* Gets the source bounds of the owners figure.
*
* @return the source bounds
*/
protected PrecisionRectangle getSourceBounds() {
PrecisionRectangle sourceRect;
IFigure figure = _owner.getFigure();
if (figure instanceof HandleBounds) {
sourceRect = new PrecisionRectangle(((HandleBounds) figure).getHandleBounds());
} else {
sourceRect = new PrecisionRectangle(figure.getBounds());
}
figure.translateToAbsolute(sourceRect);
return sourceRect;
}
use of org.eclipse.gef.handles.HandleBounds in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method getConstraintForResize.
// super.super.getConstraintFor() has been overriden to fix a bug when handle bounds does not equal with bounds. For example, polyline figue.
/**
* Generates a draw2d constraint object derived from the specified child
* EditPart using the provided Request. The returned constraint will be
* translated to the application's model later using
* {@link #translateToModelConstraint(Object)}.
*
* @param request
* the ChangeBoundsRequest
* @param child
* the child EditPart for which the constraint should be
* generated
* @return the draw2d constraint
*/
protected Object getConstraintForResize(ChangeBoundsRequest request, GraphicalEditPart child) {
Rectangle bounds = child.getFigure().getBounds();
if (child.getFigure() instanceof HandleBounds) {
bounds = ((HandleBounds) child.getFigure()).getHandleBounds();
}
Rectangle rect = new PrecisionRectangle(bounds);
child.getFigure().translateToAbsolute(rect);
rect = request.getTransformedRectangle(rect);
child.getFigure().translateToRelative(rect);
rect.translate(getLayoutOrigin().getNegated());
return getConstraintFor(rect);
}
Aggregations