public void setBounds(int x, int y, int width, int height, boolean animate, final boolean reorderItems) {
if (animate) {
cancelAnimatingBounds();
final Bounds from = Bounds.fromRectangle(bounds);
final Bounds to = Bounds.fromXYWidthHeight(x, y, width, height);
if (from.equals(to)) {
return;
}
TimingTarget timingTarget = new TimingTargetAdapter() {
@Override
public void timingEvent(Animator source, double fraction) {
double doubleLeft = from.getLeft() + (to.getLeft() - from.getLeft()) * fraction;
double doubleRight = from.getRight() + (to.getRight() - from.getRight()) * fraction;
double doubleTop = from.getTop() + (to.getTop() - from.getTop()) * fraction;
double doubleBottom = from.getBottom() + (to.getBottom() - from.getBottom()) * fraction;
int intLeft = (int )Math.round(doubleLeft);
int intRight = (int )Math.round(doubleRight);
int intTop = (int )Math.round(doubleTop);
int intBottom = (int )Math.round(doubleBottom);
setBounds(Bounds.fromLeftTopRightBottom(intLeft, intTop, intRight, intBottom).toRectangle(), false, false);
checkFocusBasedOnCursor();
}
@Override
public void end(Animator source) {
setBounds(to.toRectangle(), false, false);
cancelAnimatingBounds();
if (reorderItems) {
item.getParent().reorderItems();