public void resizeWidget(Collection<ConstraintWidget> widgets,ConstraintWidget widget,ResizeHandle handle,Rectangle originalBounds,int posX,int posY){
  if (widget == null) {
    return;
  }
  Animator.setAnimationEnabled(false);
  mSnapCandidates.clear();
  int x=widget.getDrawX();
  int y=widget.getDrawY();
  int w=widget.getDrawWidth();
  int h=widget.getDrawHeight();
  ResizeHandle.Type resize=handle.getType();
  ConstraintAnchor left=widget.getAnchor(ConstraintAnchor.Type.LEFT);
  ConstraintAnchor top=widget.getAnchor(ConstraintAnchor.Type.TOP);
  ConstraintAnchor right=widget.getAnchor(ConstraintAnchor.Type.RIGHT);
  ConstraintAnchor bottom=widget.getAnchor(ConstraintAnchor.Type.BOTTOM);
  ConstraintAnchor baseline=widget.getAnchor(ConstraintAnchor.Type.BASELINE);
  boolean leftIsConnected=left != null && left.isConnected();
  boolean rightIsConnected=right != null && right.isConnected();
  boolean topIsConnected=top != null && top.isConnected();
  boolean bottomIsConnected=bottom != null && bottom.isConnected();
  boolean baselineIsConnected=baseline != null && baseline.isConnected();
  if (leftIsConnected && !rightIsConnected) {
switch (resize) {
case LEFT_TOP:
{
        resize=ResizeHandle.Type.TOP_SIDE;
      }
    break;
case LEFT_BOTTOM:
{
    resize=ResizeHandle.Type.BOTTOM_SIDE;
  }
break;
}
}
if (rightIsConnected && !leftIsConnected) {
switch (resize) {
case RIGHT_TOP:
{
resize=ResizeHandle.Type.TOP_SIDE;
}
break;
case RIGHT_BOTTOM:
{
resize=ResizeHandle.Type.BOTTOM_SIDE;
}
break;
}
}
if ((topIsConnected || baselineIsConnected) && !bottomIsConnected) {
switch (resize) {
case LEFT_TOP:
{
resize=ResizeHandle.Type.LEFT_SIDE;
}
break;
case RIGHT_TOP:
{
resize=ResizeHandle.Type.RIGHT_SIDE;
}
break;
}
}
if (bottomIsConnected && !topIsConnected) {
switch (resize) {
case LEFT_BOTTOM:
{
resize=ResizeHandle.Type.LEFT_SIDE;
}
break;
case RIGHT_BOTTOM:
{
resize=ResizeHandle.Type.RIGHT_SIDE;
}
break;
}
}
ConstraintWidget base=widget.getParent();
switch (resize) {
case LEFT_TOP:
{
int newX=Math.min(originalBounds.x + originalBounds.width - widget.getMinWidth(),posX);
newX=clampX(newX,base);
newX=snapLeft(widgets,widget,newX,mSnapCandidates);
int newY=Math.min(originalBounds.y + originalBounds.height - widget.getMinHeight(),posY);
newY=clampY(newY,base);
newY=snapTop(widgets,widget,newY,mSnapCandidates);
int newWidth=originalBounds.x + originalBounds.width - newX;
int newHeight=originalBounds.y + originalBounds.height - newY;
setNewFrame(widget,newX,newY,newWidth,newHeight);
}
break;
case LEFT_BOTTOM:
{
int newX=Math.min(originalBounds.x + originalBounds.width - widget.getMinWidth(),posX);
newX=clampX(newX,base);
newX=snapLeft(widgets,widget,newX,mSnapCandidates);
int newWidth=originalBounds.x + originalBounds.width - newX;
int newHeight=posY - originalBounds.y;
newHeight=snapHeight(widgets,widget,newHeight,mSnapCandidates);
setNewFrame(widget,newX,y,newWidth,newHeight);
}
break;
case RIGHT_TOP:
{
int newY=Math.min(originalBounds.y + originalBounds.height - widget.getMinHeight(),posY);
newY=clampY(newY,base);
newY=snapTop(widgets,widget,newY,mSnapCandidates);
int newWidth=posX - originalBounds.x;
newWidth=snapWidth(widgets,widget,newWidth,mSnapCandidates);
int newHeight=originalBounds.y + originalBounds.height - newY;
setNewFrame(widget,x,newY,newWidth,newHeight);
}
break;
case RIGHT_BOTTOM:
{
int newWidth=posX - originalBounds.x;
int newHeight=posY - originalBounds.y;
newWidth=snapWidth(widgets,widget,newWidth,mSnapCandidates);
newHeight=snapHeight(widgets,widget,newHeight,mSnapCandidates);
setNewFrame(widget,x,y,newWidth,newHeight);
}
break;
case LEFT_SIDE:
{
int newX=Math.min(originalBounds.x + originalBounds.width - widget.getMinWidth(),posX);
if (widget instanceof Guideline) {
newX=posX;
}
newX=clampX(newX,base);
newX=snapLeft(widgets,widget,newX,mSnapCandidates);
int newWidth=originalBounds.x + originalBounds.width - newX;
setNewFrame(widget,newX,y,newWidth,h);
}
break;
case RIGHT_SIDE:
{
int newWidth=posX - originalBounds.x;
newWidth=snapWidth(widgets,widget,newWidth,mSnapCandidates);
setNewFrame(widget,x,y,newWidth,h);
}
break;
case TOP_SIDE:
{
int newY=Math.min(originalBounds.y + originalBounds.height - widget.getMinHeight(),posY);
if (widget instanceof Guideline) {
newY=posY;
}
newY=clampY(newY,base);
newY=snapTop(widgets,widget,newY,mSnapCandidates);
int newHeight=originalBounds.y + originalBounds.height - newY;
setNewFrame(widget,x,newY,w,newHeight);
}
break;
case BOTTOM_SIDE:
{
int newHeight=posY - originalBounds.y;
newHeight=snapHeight(widgets,widget,newHeight,mSnapCandidates);
setNewFrame(widget,x,y,w,newHeight);
}
break;
}
}

public void resizeWidget ( Collection < ConstraintWidget > widgets , ConstraintWidget widget , ResizeHandle handle , Rectangle originalBounds , int posX , int posY ) { if ( widget == null ) { return ; } Animator . setAnimationEnabled ( false ) ; mSnapCandidates . clear ( ) ; int x = widget . getDrawX ( ) ; int y = widget . getDrawY ( ) ; int w = widget . getDrawWidth ( ) ; int h = widget . getDrawHeight ( ) ; ResizeHandle . Type resize = handle . getType ( ) ; ConstraintAnchor left = widget . getAnchor ( ConstraintAnchor . Type . LEFT ) ; ConstraintAnchor top = widget . getAnchor ( ConstraintAnchor . Type . TOP ) ; ConstraintAnchor right = widget . getAnchor ( ConstraintAnchor . Type . RIGHT ) ; ConstraintAnchor bottom = widget . getAnchor ( ConstraintAnchor . Type . BOTTOM ) ; ConstraintAnchor baseline = widget . getAnchor ( ConstraintAnchor . Type . BASELINE ) ; boolean leftIsConnected = left != null && left . isConnected ( ) ; boolean rightIsConnected = right != null && right . isConnected ( ) ; boolean topIsConnected = top != null && top . isConnected ( ) ; boolean bottomIsConnected = bottom != null && bottom . isConnected ( ) ; boolean baselineIsConnected = baseline != null && baseline . isConnected ( ) ; if ( leftIsConnected && ! rightIsConnected ) { switch ( resize ) { case LEFT_TOP : { resize = ResizeHandle . Type . TOP_SIDE ; } break ; case LEFT_BOTTOM : { resize = ResizeHandle . Type . BOTTOM_SIDE ; } break ; } } if ( rightIsConnected && ! leftIsConnected ) { switch ( resize ) { case RIGHT_TOP : { resize = ResizeHandle . Type . TOP_SIDE ; } break ; case RIGHT_BOTTOM : { resize = ResizeHandle . Type . BOTTOM_SIDE ; } break ; } } if ( ( topIsConnected || baselineIsConnected ) && ! bottomIsConnected ) { switch ( resize ) { case LEFT_TOP : { resize = ResizeHandle . Type . LEFT_SIDE ; } break ; case RIGHT_TOP : { resize = ResizeHandle . Type . RIGHT_SIDE ; } break ; } } if ( bottomIsConnected && ! topIsConnected ) { switch ( resize ) { case LEFT_BOTTOM : { resize = ResizeHandle . Type . LEFT_SIDE ; } break ; case RIGHT_BOTTOM : { resize = ResizeHandle . Type . RIGHT_SIDE ; } break ; } } ConstraintWidget base = widget . getParent ( ) ; switch ( resize ) { case LEFT_TOP : { int newX = Math . min ( originalBounds . x + originalBounds . width - widget . getMinWidth ( ) , posX ) ; newX = clampX ( newX , base ) ; newX = snapLeft ( widgets , widget , newX , mSnapCandidates ) ; int newY = Math . min ( originalBounds . y + originalBounds . height - widget . getMinHeight ( ) , posY ) ; newY = clampY ( newY , base ) ; newY = snapTop ( widgets , widget , newY , mSnapCandidates ) ; int newWidth = originalBounds . x + originalBounds . width - newX ; int newHeight = originalBounds . y + originalBounds . height - newY ; setNewFrame ( widget , newX , newY , newWidth , newHeight ) ; } break ; case LEFT_BOTTOM : { int newX = Math . min ( originalBounds . x + originalBounds . width - widget . getMinWidth ( ) , posX ) ; newX = clampX ( newX , base ) ; newX = snapLeft ( widgets , widget , newX , mSnapCandidates ) ; int newWidth = originalBounds . x + originalBounds . width - newX ; int newHeight = posY - originalBounds . y ; newHeight = snapHeight ( widgets , widget , newHeight , mSnapCandidates ) ; setNewFrame ( widget , newX , y , newWidth , newHeight ) ; } break ; case RIGHT_TOP : { int newY = Math . min ( originalBounds . y + originalBounds . height - widget . getMinHeight ( ) , posY ) ; newY = clampY ( newY , base ) ; newY = snapTop ( widgets , widget , newY , mSnapCandidates ) ; int newWidth = posX - originalBounds . x ; newWidth = snapWidth ( widgets , widget , newWidth , mSnapCandidates ) ; int newHeight = originalBounds . y + originalBounds . height - newY ; setNewFrame ( widget , x , newY , newWidth , newHeight ) ; } break ; case RIGHT_BOTTOM : { int newWidth = posX - originalBounds . x ; int newHeight = posY - originalBounds . y ; newWidth = snapWidth ( widgets , widget , newWidth , mSnapCandidates ) ; newHeight = snapHeight ( widgets , widget , newHeight , mSnapCandidates ) ; setNewFrame ( widget , x , y , newWidth , newHeight ) ; } break ; case LEFT_SIDE : { int newX = Math . min ( originalBounds . x + originalBounds . width - widget . getMinWidth ( ) , posX ) ; if ( widget instanceof Guideline ) { newX = posX ; } newX = clampX ( newX , base ) ; newX = snapLeft ( widgets , widget , newX , mSnapCandidates ) ; int newWidth = originalBounds . x + originalBounds . width - newX ; setNewFrame ( widget , newX , y , newWidth , h ) ; } break ; case RIGHT_SIDE : { int newWidth = posX - originalBounds . x ; newWidth = snapWidth ( widgets , widget , newWidth , mSnapCandidates ) ; setNewFrame ( widget , x , y , newWidth , h ) ; } break ; case TOP_SIDE : { int newY = Math . min ( originalBounds . y + originalBounds . height - widget . getMinHeight ( ) , posY ) ; if ( widget instanceof Guideline ) { newY = posY ; } newY = clampY ( newY , base ) ; newY = snapTop ( widgets , widget , newY , mSnapCandidates ) ; int newHeight = originalBounds . y + originalBounds . height - newY ; setNewFrame ( widget , x , newY , w , newHeight ) ; } break ; case BOTTOM_SIDE : { int newHeight = posY - originalBounds . y ; newHeight = snapHeight ( widgets , widget , newHeight , mSnapCandidates ) ; setNewFrame ( widget , x , y , w , newHeight ) ; } break ; } }
resize the widget given the current mouse position
