Java 类com.facebook.rebound.SpringConfig 实例源码

项目:boohee_v5.6    文件:SpringConfiguratorView.java   
public void refreshSpringConfigurations() {
    Map<SpringConfig, String> springConfigMap = this.springConfigRegistry.getAllSpringConfig();
    this.spinnerAdapter.clear();
    this.mSpringConfigs.clear();
    for (Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
        if (entry.getKey() != SpringConfig.defaultConfig) {
            this.mSpringConfigs.add(entry.getKey());
            this.spinnerAdapter.add((String) entry.getValue());
        }
    }
    this.mSpringConfigs.add(SpringConfig.defaultConfig);
    this.spinnerAdapter.add((String) springConfigMap.get(SpringConfig.defaultConfig));
    this.spinnerAdapter.notifyDataSetChanged();
    if (this.mSpringConfigs.size() > 0) {
        this.mSpringSelectorSpinner.setSelection(0);
    }
}
项目:Incubators    文件:IOSToggleButton.java   
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle();
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.IOSToggleButton);
    offBorderColor = typedArray.getColor(R.styleable.IOSToggleButton_btnOffBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.IOSToggleButton_btnOnColor, onColor);
    spotColor = typedArray.getColor(R.styleable.IOSToggleButton_btnSpotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.IOSToggleButton_btnOffColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.IOSToggleButton_btnBorderWidth, borderWidth);
    typedArray.recycle();
}
项目:SpiderMenu    文件:SpiderMenu.java   
/**
 * Bounce the view. Will use the respective values for center and radial view
 * @param child
 *      The child that has to be bounced
 * @param springAnimator
 *      The spring animator with the listener to be invoked.
 *      Set null if you dont need to intercept the spring animation end
 *
 * @author Melvin Lobo
 */
private void bounceView(View child, SpringAnimator springAnimator) {
    LayoutParams params = (LayoutParams) child.getLayoutParams();

    if(params.getMenuType() == LayoutParams.CENTER) {
        Spring centerScaleSpring = mSpringSystem.createSpring();
        centerScaleSpring.setSpringConfig( new SpringConfig( CENTER_SCALE_TENSION, CENTER_SCALE_FRICTION ) );
        centerScaleSpring.setEndValue( 1 );
        centerScaleSpring.addListener( springAnimator );
    }
    else {
        Spring radialScaleSpring = mSpringSystem.createSpring();
        radialScaleSpring.setSpringConfig( new SpringConfig( RADIAL_SCALE_TENSION, RADIAL_SCALE_FRICTION ) );
        radialScaleSpring.setEndValue( 1 );
        radialScaleSpring.addListener( springAnimator );
    }
}
项目:RxComboDetector    文件:YOLOComboView.java   
public YOLOComboView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    BaseSpringSystem springSystem = SpringSystem.create();
    mComboSpring = springSystem.createSpring();
    mComboSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(600, 9));

    mYOLOLogo = new ImageView(context);
    FrameLayout.LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    mYOLOLogo.setLayoutParams(params);
    mYOLOLogo.setImageResource(R.drawable.ic_yolo);
    addView(mYOLOLogo);

    mComboText = new TextView(context);
    params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT);
    params.rightMargin = 30;
    mComboText.setLayoutParams(params);
    mComboText.setTextColor(context.getResources().getColor(android.R.color.holo_red_light));
    mComboText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    addView(mComboText);

    mSpringListener = new ComboSpringListener(mComboText);
    setAlpha(0);
}
项目:FloatWindow    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:MyScse-Client    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:EveryXDay    文件:ToggleButton.java   
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle();
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
    offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth, borderWidth);
    typedArray.recycle();
}
项目:KugouLayout    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:Green    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:AndroidPlayground    文件:BonusAnimationActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bonus_animation);
    ButterKnife.bind(this);
    mScaleSpring = mSpringSystem.createSpring();
    mScaleSpring.addListener(mBonusMsgSpringListener);
    mScaleSpring.setCurrentValue(0.07);
    mScaleSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(QC_TENSION,
            QC_FRICTION));

    new Thread(new Runnable() {
        @Override
        public void run() {
            mBonusAnimationView.initResources(BonusAnimationActivity.this);
        }
    }).start();
}
项目:Magnet    文件:Magnet.java   
protected void initializeMotionPhysics() {
  SpringConfig config = getSpringConfig();
  SpringSystem springSystem = getSpringSystem();
  xSpring = createXSpring(springSystem, config);
  ySpring = createYSpring(springSystem, config);
  motionImitatorX =
      new MagnetImitator(MotionProperty.X, Imitator.TRACK_ABSOLUTE, Imitator.FOLLOW_SPRING, 0, 0);
  motionImitatorY =
      new MagnetImitator(MotionProperty.Y, Imitator.TRACK_ABSOLUTE, Imitator.FOLLOW_SPRING, 0, 0);
  xWindowManagerPerformer = new WindowManagerPerformer(MotionProperty.X);
  yWindowManagerPerformer = new WindowManagerPerformer(MotionProperty.Y);
  actor = new Actor.Builder(springSystem, iconView).addMotion(xSpring, motionImitatorX,
      xWindowManagerPerformer)
      .addMotion(ySpring, motionImitatorY, yWindowManagerPerformer)
      .onTouchListener(this)
      .build();
  iconView.getViewTreeObserver().addOnGlobalLayoutListener(this);
}
项目:ToggleButton    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:light-novel-library_Wenku8_Android    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:light-novel-library_Wenku8_Android    文件:ToggleButton.java   
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle();
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
    offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth, borderWidth);
    typedArray.recycle();
}
项目:rebound    文件:SpringConfiguratorView.java   
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
项目:eazycore    文件:BaseAnimationDialog.java   
private void init(int startAnim, int endAnim) {
    this.time_start_animation = startAnim;
    this.time_end_animation = endAnim;
    springSystem = SpringSystem.create();
    mSpring = springSystem.createSpring();

    SpringConfig config = new SpringConfig(TENSION, DAMPER);
    mSpring.setSpringConfig(config);
}
项目:EazyBaseMVP    文件:BaseAnimationDialog.java   
private void init(int startAnim, int endAnim) {
    this.timeStartAnimation = startAnim;
    this.timeEndAnimation = endAnim;
    springSystem = SpringSystem.create();
    mSpring = springSystem.createSpring();

    SpringConfig config = new SpringConfig(TENSION, DAMPER);
    mSpring.setSpringConfig(config);
}
项目:boohee_v5.6    文件:SpringConfiguratorView.java   
private void updateSeekBarsForSpringConfig(SpringConfig springConfig) {
    int scaledTension = Math.round(((((float) OrigamiValueConverter.origamiValueFromTension
            (springConfig.tension)) - 0.0f) * 100000.0f) / MAX_TENSION);
    int scaledFriction = Math.round(((((float) OrigamiValueConverter.origamiValueFromFriction
            (springConfig.friction)) - 0.0f) * 100000.0f) / 50.0f);
    this.mTensionSeekBar.setProgress(scaledTension);
    this.mFrictionSeekBar.setProgress(scaledFriction);
}
项目:JPSpringMenu    文件:MainActivity.java   
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (seekBar == mTensionbar) {
        mTvTension.setText("Tension:" + progress);
    } else {
        mTvFriction.setText("Fricsion:" + progress);
    }
    mSpringMenu.setMenuSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(mTensionbar.getProgress(), mFrictionBar.getProgress()));
}
项目:FloatingView    文件:SpringHelper.java   
public void start(){
    SpringSystem springSystem = SpringSystem.create();
    Spring spring  = springSystem.createSpring();
    if (mConfig == 0){
        spring.setSpringConfig(SpringConfig.fromBouncinessAndSpeed(mConfigValueOne, mConfigValueTwo));
    }else if (mConfig == 1){
        spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(mConfigValueOne, mConfigValueTwo));
    }
    start(spring);
}
项目:MyTravelingDiary    文件:SwitchButton.java   
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle(defaultAnimate);
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SwitchButton);
    offBorderColor = typedArray.getColor(R.styleable.SwitchButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.SwitchButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.SwitchButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.SwitchButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.SwitchButton_insetBorderWidth, borderWidth);
    defaultAnimate = typedArray.getBoolean(R.styleable.SwitchButton_animate, defaultAnimate);
    typedArray.recycle();

    borderColor = offBorderColor;
}
项目:FloatWindow    文件:ToggleButton.java   
public void setup(AttributeSet attrs) {
    mDensity = getResources().getDisplayMetrics().density;

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle(defaultAnimate);
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
    offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth, (int)(borderWidth * mDensity));
    defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_animate, defaultAnimate);
    typedArray.recycle();

    borderColor = offBorderColor;
}
项目:FloatWindow    文件:SpringConfiguratorView.java   
/**
 * update the position of the seekbars based on the spring value;
 * @param springConfig current editing spring
 */
private void updateSeekBarsForSpringConfig(SpringConfig springConfig) {
  float tension = (float) OrigamiValueConverter.origamiValueFromTension(springConfig.tension);
  float tensionRange = MAX_TENSION - MIN_TENSION;
  int scaledTension = Math.round(((tension - MIN_TENSION) * MAX_SEEKBAR_VAL) / tensionRange);

  float friction = (float) OrigamiValueConverter.origamiValueFromFriction(springConfig.friction);
  float frictionRange = MAX_FRICTION - MIN_FRICTION;
  int scaledFriction = Math.round(((friction - MIN_FRICTION) * MAX_SEEKBAR_VAL) / frictionRange);

  mTensionSeekBar.setProgress(scaledTension);
  mFrictionSeekBar.setProgress(scaledFriction);
}
项目:MyScse-Client    文件:SpringConfiguratorView.java   
/**
 * update the position of the seekbars based on the spring value;
 * @param springConfig current editing spring
 */
private void updateSeekBarsForSpringConfig(SpringConfig springConfig) {
  float tension = (float) OrigamiValueConverter.origamiValueFromTension(springConfig.tension);
  float tensionRange = MAX_TENSION - MIN_TENSION;
  int scaledTension = Math.round(((tension - MIN_TENSION) * MAX_SEEKBAR_VAL) / tensionRange);

  float friction = (float) OrigamiValueConverter.origamiValueFromFriction(springConfig.friction);
  float frictionRange = MAX_FRICTION - MIN_FRICTION;
  int scaledFriction = Math.round(((friction - MIN_FRICTION) * MAX_SEEKBAR_VAL) / frictionRange);

  mTensionSeekBar.setProgress(scaledTension);
  mFrictionSeekBar.setProgress(scaledFriction);
}
项目:MyScse-Client    文件:ToggleButton.java   
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle(defaultAnimate);
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
    offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidthToggleButton, borderWidth);
    defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_animate, defaultAnimate);
    isDefaultOn = typedArray.getBoolean(R.styleable.ToggleButton_isDefaultOn, isDefaultOn);
    typedArray.recycle();

    borderColor = offBorderColor;

    if (isDefaultOn) {
        toggleOn();
    }
}
项目:betwixt    文件:SpringInterpolators.java   
/**
 * A spring interpolator backed by a {@link com.facebook.rebound.Spring}. This creates a
 * {@link SpringInterpolator} with the provided tension and friction. The caller can still
 * {@link SpringInterpolator#configure()} the spring before rasterizing it.
 * See {@link SpringInterpolator#rasterize()}
 */
@NonNull
public static SpringInterpolator spring(double tension, double friction) {
    SpringInterpolator interpolator = new SpringInterpolator();
    interpolator.configure().setSpringConfig(new SpringConfig(tension, friction));
    return interpolator;
}
项目:ExhibitionCenter    文件:ToggleButton.java   
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    springSystem = SpringSystem.create();
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));

    this.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            toggle(defaultAnimate);
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
    offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_button_border_width, borderWidth);
    defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_animate, defaultAnimate);
    isDefaultOn = typedArray.getBoolean(R.styleable.ToggleButton_isDefaultOn, isDefaultOn);
    typedArray.recycle();

    borderColor = offBorderColor;

    if (isDefaultOn) {
        toggleOn();
    }
}
项目:springmenu    文件:ReboundAnimation.java   
private static Spring initializeSpring(final View view, final int startTranslationX, final int startTranslationY, boolean overshoot)
{
    view.setTranslationX(startTranslationX);
    view.setTranslationY(startTranslationY);
    view.setVisibility(View.VISIBLE);

    // Create a system to run the physics loop for a set of springs.
    SpringSystem springSystem = SpringSystem.create();

    // Add a spring to the system.
    Spring spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(80, 7));
    spring.setOvershootClampingEnabled(!overshoot);
    return spring;
}
项目:test4XXX    文件:BallExample.java   
public BallExample(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  COASTING = SpringConfig.fromOrigamiTensionAndFriction(0, 0.5);
  COASTING.tension = 0;
  setBackgroundColor(Color.WHITE);

  springSystem = SpringSystem.create();
  springSystem.addListener(this);
  xSpring = springSystem.createSpring();
  ySpring = springSystem.createSpring();
  xSpring.addListener(this);
  ySpring.addListener(this);
  paint = new Paint(Paint.ANTI_ALIAS_FLAG);

  getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
      centerX = getWidth() / 2f;
      centerY = getHeight() / 2f;

      xSpring.setCurrentValue(centerX).setAtRest();
      ySpring.setCurrentValue(centerY).setAtRest();
      getViewTreeObserver().removeOnGlobalLayoutListener(this);

      int offsetH = (int) ((getHeight() - (2 * radius)) % 800) / 2;
      int offsetW = (int) ((getWidth() - (2 * radius))  % 800) / 2;
      for (float i = offsetH + radius; i < getHeight() - offsetH; i += 400) {
        for (float j = offsetW + radius; j < getWidth() - offsetW; j += 400) {
          points.add(new PointF(j, i));
        }
      }
    }
  });
}
项目:Backboard    文件:ExplosionFragment.java   
private static void createCircle(Context context, ViewGroup rootView,
                                 SpringSystem springSystem,
                                 SpringConfig coasting,
                                 SpringConfig gravity,
                                 int diameter,
                                 Drawable backgroundDrawable) {

    final Spring xSpring = springSystem.createSpring().setSpringConfig(coasting);
    final Spring ySpring = springSystem.createSpring().setSpringConfig(gravity);

    // create view
    View view = new View(context);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(diameter, diameter);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    view.setLayoutParams(params);
    view.setBackgroundDrawable(backgroundDrawable);

    rootView.addView(view);

    // generate random direction and magnitude
    double magnitude = Math.random() * 1000 + 3000;
    double angle = Math.random() * Math.PI / 2 + Math.PI / 4;

    xSpring.setVelocity(magnitude * Math.cos(angle));
    ySpring.setVelocity(-magnitude * Math.sin(angle));

    int maxX = rootView.getMeasuredWidth() / 2 + diameter;
    xSpring.addListener(new Destroyer(rootView, view, -maxX, maxX));

    int maxY = rootView.getMeasuredHeight() / 2 + diameter;
    ySpring.addListener(new Destroyer(rootView, view, -maxY, maxY));

    xSpring.addListener(new Performer(view, View.TRANSLATION_X));
    ySpring.addListener(new Performer(view, View.TRANSLATION_Y));

    // set a different end value to cause the animation to play
    xSpring.setEndValue(2);
    ySpring.setEndValue(9001);
}
项目:Backboard    文件:ExplosionFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();
    mSpringSystem = SpringSystem.create();

    mCoasting = SpringConfig.fromOrigamiTensionAndFriction(0, 0);
    mCoasting.tension = 0;

    // this is very much a hack, since the end value is set to 9001 to simulate constant
    // acceleration.
    mGravity = SpringConfig.fromOrigamiTensionAndFriction(0, 0);
    mGravity.tension = 1;
}
项目:compass-project    文件:DragLayout.java   
private void init(Context context, AttributeSet attrs) {
    if(attrs != null) {
        TypedArray attrArray = context
                .obtainStyledAttributes(attrs, R.styleable.DragLayout);

        for (int i = 0; i < attrArray.getIndexCount(); ++i) {
            int attr = attrArray.getIndex(i);
            if (attr == R.styleable.DragLayout_scale) {
                scale = attrArray.getFloat(attr, DEFAULT_SCALE);

            } else if (attr == R.styleable.DragLayout_springFriction) {
                friction = attrArray.getFloat(attr, DEFAULT_FRICTION);

            } else if (attr == R.styleable.DragLayout_springTension) {
                tension = attrArray.getFloat(attr, DEFAULT_TENSION);

            } else if (attr == R.styleable.DragLayout_intercepting) {
                intercepting = attrArray.getBoolean(attr, DEFAULT_INTERCEPT_TOUCH_EVENT);

            }
        }
        attrArray.recycle();
    }

    setClickable(true);
    setOnTouchListener(this);
    setOnLongClickListener(this);

    SpringSystem springSystem = SpringSystem.create();
    pushSpring = springSystem.createSpring();
    pushSpring.addListener(this);
    pushSpring.setSpringConfig(new SpringConfig(tension, friction));
}
项目:KugouLayout    文件:SpringConfiguratorView.java   
/**
 * update the position of the seekbars based on the spring value;
 * @param springConfig current editing spring
 */
private void updateSeekBarsForSpringConfig(SpringConfig springConfig) {
  float tension = (float) OrigamiValueConverter.origamiValueFromTension(springConfig.tension);
  float tensionRange = MAX_TENSION - MIN_TENSION;
  int scaledTension = Math.round(((tension - MIN_TENSION) * MAX_SEEKBAR_VAL) / tensionRange);

  float friction = (float) OrigamiValueConverter.origamiValueFromFriction(springConfig.friction);
  float frictionRange = MAX_FRICTION - MIN_FRICTION;
  int scaledFriction = Math.round(((friction - MIN_FRICTION) * MAX_SEEKBAR_VAL) / frictionRange);

  mTensionSeekBar.setProgress(scaledTension);
  mFrictionSeekBar.setProgress(scaledFriction);
}
项目:Bound    文件:SpringController.java   
public Spring slideButtonSpring() {
  if(slideButtonSpring == null) {
    synchronized (Spring.class) {
      if(slideButtonSpring == null) {
        slideButtonSpring = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(slideButtonTension, slideButtonFriction));
      }
    }
  }
  return slideButtonSpring;
}
项目:Bound    文件:SpringController.java   
public Spring fabButtonSpring() {
  if(fabButtonSpring == null) {
    synchronized (Spring.class) {
      if(fabButtonSpring == null) {
        fabButtonSpring = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(fabButtonTension, fabButtonFriction));
      }
    }
  }
  return fabButtonSpring;
}
项目:Bound    文件:SpringController.java   
public Spring scaleButtonSpring() {
  if(scaleButtonSpring == null) {
    synchronized (Spring.class) {
      if(scaleButtonSpring == null) {
        scaleButtonSpring = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(fabButtonTension, fabButtonFriction));
      }
    }
  }
  return scaleButtonSpring;
}
项目:pagarme-android    文件:CardHashView.java   
private Spring scaleSpringZoomIn() {
  if(scaleSpringZoomIn == null) {
    synchronized (Spring.class) {
      if(scaleSpringZoomIn == null) {
        scaleSpringZoomIn = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(
                SpringConfig.fromBouncinessAndSpeed(0, 30));
      }
    }
  }
  return scaleSpringZoomIn;
}
项目:pagarme-android    文件:CardHashView.java   
private Spring scaleSpringZoomOut() {
  if(scaleSpringZoomOut == null) {
    synchronized (Spring.class) {
      if(scaleSpringZoomOut == null) {
        scaleSpringZoomOut = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(
                SpringConfig.fromBouncinessAndSpeed(0, 30));
      }
    }
  }
  return scaleSpringZoomOut;
}
项目:pagarme-android    文件:CardHashView.java   
private Spring rotateHorizontalSpring() {
  if(rotateHorizontalSpring == null) {
    synchronized (Spring.class) {
      if(rotateHorizontalSpring == null) {
        rotateHorizontalSpring = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(
                SpringConfig.fromOrigamiTensionAndFriction(60, 5));
      }
    }
  }
  return rotateHorizontalSpring;
}
项目:pagarme-android    文件:CardHashView.java   
private Spring rotateVerticalSpring() {
  if(rotateVerticalSpring == null) {
    synchronized (Spring.class) {
      if(rotateVerticalSpring == null) {
        rotateVerticalSpring = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(
                SpringConfig.fromOrigamiTensionAndFriction(60, 5));
      }
    }
  }
  return rotateVerticalSpring;
}