/**
  * Expands or collapses this <code>JCollapsiblePane</code>.
  *
  * <p>
  *
  * <p>If the component is collapsed and <code>val</code> is false, then this call expands the
  * JCollapsiblePane, such that the entire JCollapsiblePane will be visible. If {@link
  * #isAnimated()} returns true, the expansion will be accompanied by an animation.
  *
  * <p>
  *
  * <p>However, if the component is expanded and <code>val</code> is true, then this call collapses
  * the JCollapsiblePane, such that the entire JCollapsiblePane will be invisible. If {@link
  * #isAnimated()} returns true, the collapse will be accompanied by an animation.
  *
  * @javabean.property bound="true" preferred="true"
  * @see #isAnimated()
  * @see #setAnimated(boolean)
  */
 public void setCollapsed(boolean val) {
   if (collapsed != val) {
     collapsed = val;
     if (isAnimated()) {
       if (collapsed) {
         setAnimationParams(
             new AnimationParams(30, Math.max(8, wrapper.getHeight() / 10), 1.0f, 0.01f));
         animator.reinit(wrapper.getHeight(), 0);
         animateTimer.start();
       } else {
         setAnimationParams(
             new AnimationParams(
                 30, Math.max(8, getContentPane().getPreferredSize().height / 10), 0.01f, 1.0f));
         animator.reinit(wrapper.getHeight(), getContentPane().getPreferredSize().height);
         animateTimer.start();
       }
     } else {
       wrapper.c.setVisible(!collapsed);
       invalidate();
       doLayout();
     }
     repaint();
     firePropertyChange("collapsed", !collapsed, collapsed);
   }
 }
Example #2
0
  /**
   * Expands or collapses this <code>JXCollapsiblePane</code>.
   *
   * <p>If the component is collapsed and <code>val</code> is false, then this call expands the
   * JXCollapsiblePane, such that the entire JXCollapsiblePane will be visible. If {@link
   * #isAnimated()} returns true, the expansion will be accompanied by an animation.
   *
   * <p>However, if the component is expanded and <code>val</code> is true, then this call collapses
   * the JXCollapsiblePane, such that the entire JXCollapsiblePane will be invisible. If {@link
   * #isAnimated()} returns true, the collapse will be accompanied by an animation.
   *
   * @see #isAnimated()
   * @see #setAnimated(boolean)
   * @javabean.property bound="true" preferred="true"
   */
  public void setCollapsed(boolean val) {
    if (collapsed != val) {
      collapsed = val;
      if (isAnimated()) {
        if (collapsed) {
          int dimension = direction.isVertical() ? wrapper.getHeight() : wrapper.getWidth();
          setAnimationParams(new AnimationParams(30, Math.max(8, dimension / 10), 1.0f, 0.01f));
          animator.reinit(dimension, 0);
          animateTimer.start();
        } else {
          int dimension = direction.isVertical() ? wrapper.getHeight() : wrapper.getWidth();
          int preferredDimension =
              direction.isVertical()
                  ? getContentPane().getPreferredSize().height
                  : getContentPane().getPreferredSize().width;
          int delta = Math.max(8, preferredDimension / 10);

          setAnimationParams(new AnimationParams(30, delta, 0.01f, 1.0f));
          animator.reinit(dimension, preferredDimension);
          wrapper.getView().setVisible(true);
          animateTimer.start();
        }
      } else {
        wrapper.collapsedState = collapsed;
        wrapper.getView().setVisible(!collapsed);
        revalidate();
      }
      repaint();
      firePropertyChange("collapsed", !collapsed, collapsed);
    }
  }
  public void show() {
    mStatus = Status.STATUS_SMOOTH_UP;

    if (mAnimationListener != null) {
      mAnimationListener.onStart();
      this.postDelayed(
          new Runnable() {
            @Override
            public void run() {

              mAnimationListener.onContentShow();
            }
          },
          600);
    }

    ValueAnimator valueAnimator = ValueAnimator.ofInt(0, mMaxArcHeight);
    valueAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            int value = (int) animation.getAnimatedValue();
            mArcHeight = value;

            if (value == mMaxArcHeight) {
              duang();
            }
            invalidate();
          }
        });
    valueAnimator.setDuration(800);
    valueAnimator.setInterpolator(new AccelerateInterpolator());
    valueAnimator.start();
  }
Example #4
0
 public void stop() {
   mRunning = false;
   mBubbles.clear();
   mHandler.removeMessages(MSG_UPDATE);
   if (mAnimationListener != null) {
     mAnimationListener.onAnimationEnd(this);
   }
 }
Example #5
0
 public void start() {
   if (!mHandler.hasMessages(MSG_UPDATE)) {
     mRunning = true;
     mHandler.sendEmptyMessage(MSG_UPDATE);
     if (mAnimationListener != null) {
       mAnimationListener.onAnimationStart(this);
     }
   }
 }
Example #6
0
  private void updateBubbles() {
    Iterator<Bubble> iterator = mBubbles.iterator();
    boolean needToDraw = false;
    while (iterator.hasNext()) {
      Bubble bubble = iterator.next();
      if (bubble.curTime <= DURATION) {
        initBezierPointIfNeed(bubble);

        bubble.curTime = bubble.curTime + STEP_PERIOD;
        float factor = mInterpolator.getInterpolation(bubble.curTime / (float) (DURATION));
        bubble.scale = ScaleInit + ScaleRange * factor;
        calculateBezierPoint(
            bubble.position,
            factor,
            bubble.startPoint,
            bubble.ctrlPoint1,
            bubble.ctrlPoint2,
            bubble.endPoint);

        // The last Half of the period make transparency change
        if (bubble.curTime > DURATION / 2) {
          float alphaFactor =
              mAlphaInterpolator.getInterpolation(
                  (bubble.curTime - DURATION / 2) / (float) (DURATION / 2));
          bubble.alpha = AlphaInit + (int) (AlphaRange * alphaFactor);
        }
        needToDraw = true;
      } else {
        iterator.remove();
      }
    }

    if (needToDraw) {
      postInvalidate();
    } else {
      mRunning = false;
      if (mAnimationListener != null) {
        mAnimationListener.onAnimationEnd(this);
      }
    }
  }
 public void onAnimationFinish() {
   if (animationListener != null) {
     animationListener.onAnimationFinish();
   }
 }