Package com.peterhi.ui.obsolete

Examples of com.peterhi.ui.obsolete.Bounds


        boundsAnimator.cancel();
        boundsAnimator = null;
      }

      Rectangle now = bounds.getNow();
      final Bounds from = Bounds.fromRectangle(now);
      final Bounds to = Bounds.fromXYWidthHeight(x, y, width, height);
     
      TimingTarget timingTarget = new TimingTargetAdapter() {

        @Override
        public void timingEvent(Animator source, double fraction) {
          int left = (int )Math.round(from.getLeft() + (to.getLeft() - from.getLeft()) * fraction);
          int right = (int )Math.round(from.getRight() + (to.getRight() - from.getRight()) * fraction);
          int top = (int )Math.round(from.getTop() + (to.getTop() - from.getTop()) * fraction);
          int bottom = (int )Math.round(from.getBottom() + (to.getBottom() - from.getBottom()) * fraction);
          updateBounds(Bounds.fromLeftTopRightBottom(left, top, right, bottom).toRectangle());
        }
       
        @Override
        public void end(Animator source) {
          updateBounds(to.toRectangle());
          boundsAnimator = null;
        }

      };
     
View Full Code Here


 
  void setBounds(int x, int y, int width, int height, boolean animate, final TimingTarget listener) {
    if (animate) {
      cancelBoundsAnimation();
     
      final Bounds from = Bounds.fromRectangle(getBounds());
      final Bounds to = Bounds.fromRectangle(new Rectangle(x, y, width, height));
     
      if (from.equals(to)) {
        return;
      }
     
      TimingTarget timingTarget = new TimingTargetAdapter() {

        @Override
        public void timingEvent(Animator source, double fraction) {
          double dLeft = from.getLeft() + ((to.getLeft() - from.getLeft()) * fraction);
          double dRight = from.getRight() + ((to.getRight() - from.getRight()) * fraction);
          double dTop = from.getTop() + ((to.getTop() - from.getTop()) * fraction);
          double dBottom = from.getBottom() + ((to.getBottom() - from.getBottom()) * fraction);
         
          int nLeft = (int )Math.round(dLeft);
          int nRight = (int )Math.round(dRight);
          int nTop = (int )Math.round(dTop);
          int nBottom = (int )Math.round(dBottom);

          Bounds bounds = Bounds.fromLeftTopRightBottom(nLeft, nTop, nRight, nBottom);
          setBounds(bounds.toRectangle(), false, null);
         
          if (listener != null) {
            listener.timingEvent(source, fraction);
          }
        }
View Full Code Here

  }
 
  private StripItem[] getAffectedItems(StripItem dragItem, int delta) {
    List<StripItem> affectedItems = new ArrayList<StripItem>();
   
    Bounds dragBounds = Bounds.fromRectangle(dragItem.getBounds());

    for (StripItem anItem : items) {
      if (anItem.equals(dragItem)) {
        continue;
      }
     
      Bounds aBounds = Bounds.fromRectangle(anItem.getBounds());

      if (delta > 0) {
        if (dragBounds.getLeft() <= aBounds.getCenterX() && dragBounds.getRight() + delta >= aBounds.getCenterX()) {
          affectedItems.add(anItem);
        }
      } else {
        if (dragBounds.getRight() >= aBounds.getCenterX() && dragBounds.getLeft() + delta <= aBounds.getCenterX()) {
          affectedItems.add(anItem);
        }
      }
    }
   
View Full Code Here

    }
  }
 
  private StripItemController[] getAffectedControllers(StripItemController dragItemController, int distance) {
    Set<StripItemController> affectedItemControllers = new HashSet<StripItemController>();
    Bounds dragItemBounds = Bounds.fromRectangle(dragItemController.getBounds());
   
    for (StripItemController itemController : itemControllers) {
      if (itemController.equals(dragItemController)) {
        continue;
      }
     
      Bounds itemBounds = Bounds.fromRectangle(itemController.getBounds());
     
      int threshold = itemBounds.getCenterX();
     
      if (distance > 0) {
        if (dragItemBounds.getLeft() < threshold) {
          if (dragItemBounds.getRight() + distance > threshold) {
            affectedItemControllers.add(itemController);
View Full Code Here

  }
 
  private StripItemController[] getControllersBefore(StripItemController controller, int moved) {
    Set<StripItemController> before = new HashSet<StripItemController>();
   
    Bounds offsetBounds = Bounds.fromRectangle(getItemOffsetBounds(controller.getItem()));
   
    for (StripItemController otherController : controllers) {
      if (otherController.equals(controller)) {
        continue;
      }
     
      Bounds otherOffsetBounds = Bounds.fromRectangle(getItemOffsetBounds(otherController.getItem()));

      if (offsetBounds.getRight() > otherOffsetBounds.getRight() && (offsetBounds.getLeft() - moved) < otherOffsetBounds.getCenterX()) {
        before.add(otherController);
      }
    }
   
    return before.toArray(new StripItemController[before.size()]);
View Full Code Here

  }
 
  private StripItemController[] getControllersAfter(StripItemController controller, int moved) {
    Set<StripItemController> after = new HashSet<StripItemController>();

    Bounds offsetBounds = Bounds.fromRectangle(getItemOffsetBounds(controller.getItem()));
   
    for (StripItemController otherController : controllers) {
      if (otherController.equals(controller)) {
        continue;
      }
     
      Bounds otherOffsetBounds = Bounds.fromRectangle(getItemOffsetBounds(otherController.getItem()));
     
      if (offsetBounds.getLeft() < otherOffsetBounds.getLeft() && (offsetBounds.getRight() + moved) > otherOffsetBounds.getCenterX()) {
        after.add(otherController);
      }
    }
   
    return after.toArray(new StripItemController[after.size()]);
View Full Code Here

      if (isBoundsAnimating()) {
        boundsAnimator.cancel();
        boundsAnimator = null;
      }
     
      final Bounds from = Bounds.fromRectangle(getRenderBounds());
      final Bounds to = Bounds.fromXYWidthHeight(x, y, width, height);
     
      TimingTarget timingTarget = new TimingTargetAdapter() {
        @Override
        public void timingEvent(Animator source, double fraction) {
          int left = (int )Math.round(from.getLeft() + (to.getLeft() - from.getLeft()) * fraction);
          int top = (int )Math.round(from.getTop() + (to.getTop() - from.getTop()) * fraction);
          int right = (int )Math.round(from.getRight() + (to.getRight() - from.getRight()) * fraction);
          int bottom = (int )Math.round(from.getBottom() + (to.getBottom() - from.getBottom()) * fraction);
          setRenderBounds(Bounds.fromLeftTopRightBottom(left, top, right, bottom).toRectangle());
         
          if (listener != null) {
            listener.timingEvent(source, fraction);
          }
        }
       
        @Override
        public void end(Animator source) {
          setRenderBounds(to.toRectangle());
          boundsAnimator = null;
         
          if (listener != null) {
            listener.end(source);
          }
View Full Code Here

 
  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();
View Full Code Here

     
      if (bounds.x == x && bounds.y == y && bounds.width == width && bounds.height == height) {
        return;
      }
     
      final Bounds from = Bounds.fromRectangle(getBounds());
      final Bounds to = Bounds.fromXYWidthHeight(x, y, width, height);
     
      TimingTarget timingTarget = new TimingTargetAdapter() {
        @Override
        public void timingEvent(Animator source, double fraction) {
          double leftDiff = (to.getLeft() - from.getLeft()) * fraction;
          double rightDiff = (to.getRight() - from.getRight()) * fraction;
          double topDiff = (to.getTop() - from.getTop()) * fraction;
          double bottomDiff = (to.getBottom() - from.getBottom()) * fraction;
          int newLeft = (int )Math.round(from.getLeft() + leftDiff);
          int newRight = (int )Math.round(from.getRight() + rightDiff);
          int newTop = (int )Math.round(from.getTop() + topDiff);
          int newBottom = (int )Math.round(from.getBottom() + bottomDiff);
          Bounds newBounds = Bounds.fromLeftTopRightBottom(newLeft, newTop, newRight, newBottom);
          setBounds(newBounds.getLeft(), newBounds.getTop(), newBounds.getWidth(), newBounds.getHeight(), false, null);
         
          if (listener != null) {
            listener.timingEvent(source, fraction);
          }
        }
View Full Code Here

  }
 
  private List<StripItem> getAffectedItems(StripItem mouseItem, int distance, boolean positive) {
    List<StripItem> affectedItems = new ArrayList<StripItem>();
   
    Bounds mouseBounds = Bounds.fromRectangle(mouseItem.getBounds());
   
    for (StripItem item : items) {
      if (item.equals(mouseItem)) {
        continue;
      }
     
      Bounds itemBounds = Bounds.fromRectangle(item.getBounds());
     
      if (positive) {
        if (mouseBounds.getLeft() < itemBounds.getCenterX()) {
          if (mouseBounds.getRight() + distance > itemBounds.getCenterX()) {
            affectedItems.add(item);
          }
        }
      } else {
        if (mouseBounds.getRight() > itemBounds.getCenterX()) {
          if (mouseBounds.getLeft() - distance < itemBounds.getCenterX()) {
            affectedItems.add(item);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.peterhi.ui.obsolete.Bounds

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.