Search in sources :

Example 1 with TreeLayoutConstraint

use of org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint in project statecharts by Yakindu.

the class TreeLayoutEditPolicy method getConstraintFor.

@Override
protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
    if (request instanceof AlignmentRequest) {
        return super.getConstraintFor(request, child);
    }
    final Rectangle rect = (Rectangle) super.getConstraintFor(request, child);
    final Rectangle cons = getCurrentConstraintFor(child);
    final int newTreePosition = TreeLayoutUtil.getNewTreeNodePosition(request.getLocation(), TreeLayoutUtil.getSiblings((IGraphicalEditPart) child));
    if (cons instanceof TreeLayoutConstraint) {
        final TreeLayoutConstraint treeLayoutConstraint = (TreeLayoutConstraint) cons;
        return new TreeLayoutConstraint(rect, treeLayoutConstraint.isRoot(), newTreePosition);
    }
    return new TreeLayoutConstraint(rect, false, newTreePosition);
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) AlignmentRequest(org.eclipse.gef.requests.AlignmentRequest) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 AlignmentRequest (org.eclipse.gef.requests.AlignmentRequest)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 TreeLayoutConstraint (org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint)1