Search in sources :

Example 1 with HandleBounds

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)));
    }
}
Also used : HandleBounds(org.eclipse.gef.handles.HandleBounds) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with HandleBounds

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;
}
Also used : HandleBounds(org.eclipse.gef.handles.HandleBounds) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with HandleBounds

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);
}
Also used : HandleBounds(org.eclipse.gef.handles.HandleBounds) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Aggregations

HandleBounds (org.eclipse.gef.handles.HandleBounds)3 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 IFigure (org.eclipse.draw2d.IFigure)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1