当前位置: 首页>>代码示例>>Java>>正文


Java SpringUtil.mapValueFromRangeToRange方法代码示例

本文整理汇总了Java中com.facebook.rebound.SpringUtil.mapValueFromRangeToRange方法的典型用法代码示例。如果您正苦于以下问题:Java SpringUtil.mapValueFromRangeToRange方法的具体用法?Java SpringUtil.mapValueFromRangeToRange怎么用?Java SpringUtil.mapValueFromRangeToRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.rebound.SpringUtil的用法示例。


在下文中一共展示了SpringUtil.mapValueFromRangeToRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    // On each update of the spring value, we adjust the scale of the image view to match
    // the
    // springs new value. We use the SpringUtil linear interpolation function
    // mapValueFromRangeToRange
    // to translate the spring's 0 to 1 scale to a 100% to 50% scale range and apply that to
    // the View
    // with setScaleX/Y. Note that rendering is an implementation detail of the application
    // and not
    // Rebound itself. If you need Gingerbread compatibility consider using NineOldAndroids
    // to update
    // your view properties in a backwards compatible manner.
    float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.5);
    mImageView.setScaleX(mappedValue);
    mImageView.setScaleY(mappedValue);
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:18,代码来源:MainActivity.java

示例2: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    setVisibility(View.VISIBLE);
    double value = spring.getCurrentValue();

    float selectedImage = (float) SpringUtil.mapValueFromRangeToRange(
            value, 0, 1, 0, 1);
    float titleTranslateX = (float) SpringUtil.mapValueFromRangeToRange(
            value, 0, 1, mStartX, 0);
    float titleTranslateY = (float) SpringUtil.mapValueFromRangeToRange(
            value, 0, 1, mStartY, 0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setScaleX(selectedImage);
        setScaleY(selectedImage);
        setTranslationX(titleTranslateX);
        setTranslationY(titleTranslateY);
    }
}
 
开发者ID:runningcode,项目名称:Hipster-Visualization,代码行数:19,代码来源:SpringyImageView.java

示例3: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    setVisibility(View.VISIBLE);
    double value = spring.getCurrentValue();

    float selectedTitleScale = (float) SpringUtil.mapValueFromRangeToRange(
            value, 0, 1, 0, 1);
    float titleTranslateX = (float) SpringUtil.mapValueFromRangeToRange(
            value, 0, 1, mStartX, 0);
    float titleTranslateY = (float) SpringUtil.mapValueFromRangeToRange(
            value, 0, 1, mStartY, 0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setScaleX(selectedTitleScale);
        setScaleY(selectedTitleScale);
        setTranslationX(titleTranslateX);
        setTranslationY(titleTranslateY);
    }
}
 
开发者ID:runningcode,项目名称:Hipster-Visualization,代码行数:19,代码来源:SpringyButton.java

示例4: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    Resources resources = getResources();
    double value = spring.getCurrentValue();

    float selectedTitleScale = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 0,
            1);
    float titleTranslateY = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1,
            Util.dpToPx(-150f, resources), 0);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setScaleX(selectedTitleScale);
        setScaleY(selectedTitleScale);
        setTranslationY(titleTranslateY);
    }
}
 
开发者ID:runningcode,项目名称:Hipster-Visualization,代码行数:17,代码来源:SpringyFontFitTextView.java

示例5: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    // On each update of the spring value, we adjust the scale of the image view to match the
    // springs new value. We use the SpringUtil linear interpolation function mapValueFromRangeToRange
    // to translate the spring's 0 to 1 scale to a 100% to 50% scale range and apply that to the View
    // with setScaleX/Y. Note that rendering is an implementation detail of the application and not
    // Rebound itself. If you need Gingerbread compatibility consider using NineOldAndroids to update
    // your view properties in a backwards compatible manner.
    float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.5);
    suggestionView.setScaleX(mappedValue);
    suggestionView.setScaleY(mappedValue);
}
 
开发者ID:hanuor,项目名称:sapphire,代码行数:13,代码来源:MainActivity.java

示例6: calculateEffect

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
 * @param value
 */
private void calculateEffect(final double value) {
    final float mapToggleX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, spotMinX, spotMaxX);
    spotX = mapToggleX;

    float mapOffLineWidth = (float) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, 10, spotSize);

    offLineWidth = mapOffLineWidth;

    final int fb = Color.blue(onColor);
    final int fr = Color.red(onColor);
    final int fg = Color.green(onColor);

    final int tb = Color.blue(offBorderColor);
    final int tr = Color.red(offBorderColor);
    final int tg = Color.green(offBorderColor);

    int sb = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fb, tb);
    int sr = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fr, tr);
    int sg = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fg, tg);

    sb = clamp(sb, 0, 255);
    sr = clamp(sr, 0, 255);
    sg = clamp(sg, 0, 255);

    borderColor = Color.rgb(sr, sg, sb);

    postInvalidate();
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:32,代码来源:SwitchButton.java

示例7: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    float mappedvalue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.8);
    view.setScaleX(mappedvalue);
    view.setScaleY(mappedvalue);

    float rotation = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 0, 30);
    view.setRotation(rotation);
}
 
开发者ID:J1aDong,项目名称:Gank-Meizi,代码行数:10,代码来源:ReboundImageView.java

示例8: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
	final double value = spring.getCurrentValue();
	
	final float mapToggleX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, spotMinX, spotMaxX);
	spotX = mapToggleX;
	
	float mapOffLineWidth = (float) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, 10, spotSize);
	
	offLineWidth = mapOffLineWidth;
	
	final int fb = Color.blue(onColor);
	final int fr = Color.red(onColor);
	final int fg = Color.green(onColor);
	
	final int tb = Color.blue(offBorderColor);
	final int tr = Color.red(offBorderColor);
	final int tg = Color.green(offBorderColor);
	
	int sb = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fb, tb);
	int sr = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fr, tr);
	int sg = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fg, tg);
	
	sb = clamp(sb, 0, 255);
	sr = clamp(sr, 0, 255);
	sg = clamp(sg, 0, 255);
	
	borderColor = Color.rgb(sr, sg, sb);
	
	postInvalidate();
}
 
开发者ID:CarlisleChan,项目名称:Incubators,代码行数:32,代码来源:IOSToggleButton.java

示例9: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
 * Called whenever the spring is updated
 *
 * @param spring the Spring sending the update
 */
@Override
public void onSpringUpdate( Spring spring ) {
	/*
	Map our current value to scale values. Rebound has a nifty SpringUtil class to do that
	We map our values between scale 0.3 to 1 (Range of 30% to 100%)
	 */
	double nMappedValue = SpringUtil.mapValueFromRangeToRange( spring.getCurrentValue(), 0.0d, 1.0d, 0.8d, 1.0d);
	mView.get().setScaleX( (float)nMappedValue );
	mView.get().setScaleY( (float)nMappedValue );
}
 
开发者ID:melvinjlobo,项目名称:SpiderMenu,代码行数:16,代码来源:SpiderMenu.java

示例10: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
    if (mView != null) {
        float mappedValue =
                (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1,
                        1, TO_HIGH);
        mView.setScaleX(mappedValue);
        mView.setScaleY(mappedValue);
    }
}
 
开发者ID:Piasy,项目名称:RxComboDetector,代码行数:11,代码来源:YOLOComboView.java

示例11: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override public void onSpringUpdate(Spring spring) {
  // On each update of the spring value, we adjust the scale of the image view to match the
  // springs new value. We use the SpringUtil linear interpolation function mapValueFromRangeToRange
  // to translate the spring's 0 to 1 scale to a 100% to 50% scale range and apply that to the View
  // with setScaleX/Y. Note that rendering is an implementation detail of the application and not
  // Rebound itself. If you need Gingerbread compatibility consider using NineOldAndroids to update
  // your view properties in a backwards compatible manner.
  float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.5);
  imageView.setScaleX(mappedValue);
  imageView.setScaleY(mappedValue);
}
 
开发者ID:jaredrummler,项目名称:AndroidAnimations,代码行数:12,代码来源:ReboundDemoActivity.java

示例12: calculateEffect

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
 * @param value
 */
private void calculateEffect(final double value) {
	final float mapToggleX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, spotMinX, spotMaxX);
	spotX = mapToggleX;
	
	float mapOffLineWidth = (float) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, 10, spotSize);
	
	offLineWidth = mapOffLineWidth;
	
	final int fb = Color.blue(onColor);
	final int fr = Color.red(onColor);
	final int fg = Color.green(onColor);
	
	final int tb = Color.blue(offBorderColor);
	final int tr = Color.red(offBorderColor);
	final int tg = Color.green(offBorderColor);
	
	int sb = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fb, tb);
	int sr = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fr, tr);
	int sg = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fg, tg);
	
	sb = clamp(sb, 0, 255);
	sr = clamp(sr, 0, 255);
	sg = clamp(sg, 0, 255);
	
	borderColor = Color.rgb(sr, sg, sb);
	
	postInvalidate();
}
 
开发者ID:xujunbin,项目名称:FloatWindow,代码行数:32,代码来源:ToggleButton.java

示例13: render

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
 * This method takes the current state of the spring and maps it to all the values for each UI
 * element that is animated on this spring. This allows the Spring to act as a common timing
 * function for the animation ensuring that all element transitions are synchronized.
 *
 * You can think of these mappings as similiar to Origami transitions.
 * SpringUtil#mapValueFromRangeToRange converts the spring's 0 to 1 transition and maps it to the
 * range of animation for a property on a view such as translation, scale, rotation, and alpha.
 */
private void render() {
  Resources resources = getResources();
  // Get the current spring value.
  double value = mSpring.getCurrentValue();

  // Map the spring to the feedback bar position so that its hidden off screen and bounces in on tap.
  float barPosition =
      (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, mFeedbackBar.getHeight(), 0);
  mFeedbackBar.setTranslationY(barPosition);

  // Map the spring to the selected photo scale as it moves into and out of the grid.
  float selectedPhotoScale =
      (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 0.33, 1);
  selectedPhotoScale = Math.max(selectedPhotoScale, 0); // Clamp the value so we don't go below 0.
  mSelectedPhoto.setScaleX(selectedPhotoScale);
  mSelectedPhoto.setScaleY(selectedPhotoScale);

  // Map the spring to the selected photo translation from its position in the grid
  float selectedPhotoTranslateX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, Util.dpToPx(-106.667f, resources), 0);
  float selectedPhotoTranslateY = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, Util.dpToPx(46.667f, resources), 0);
  mSelectedPhoto.setTranslationX(selectedPhotoTranslateX);
  mSelectedPhoto.setTranslationY(selectedPhotoTranslateY);

  // Map the spring to the photo grid alpha as it fades to black when the photo is selected.
  float gridAlpha =
      (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 1, 0);
  mPhotoGrid.setAlpha(gridAlpha);


  // Map the spring to the photo grid scale so that it scales down slightly as the selected photo // zooms in.
  float gridScale =
      (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 1, 0.95);
  gridScale = Math.max(gridScale, 0); // Clamp the value so we don't go below 0.
  mPhotoGrid.setScaleX(gridScale);
  mPhotoGrid.setScaleY(gridScale);
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:46,代码来源:OrigamiExample.java

示例14: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(Spring spring) {
  double val = spring.getCurrentValue();
  float xlat = (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, getWidth());
  setTranslationX(xlat);
  if (mCallback != null) {
    mCallback.onProgress(spring.getCurrentValue());
  }
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:10,代码来源:ExampleContainerView.java

示例15: onSpringUpdate

import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@Override public void onSpringUpdate(Spring spring) {
  super.onSpringUpdate(spring);
  float scaleSpring = (float) SpringUtil.mapValueFromRangeToRange(
      spring.getCurrentValue(), 0, 1, 0, scale);
  ViewCompat.setScaleX(viewCallback.getBoundMenu(), scaleSpring);
  ViewCompat.setScaleY(viewCallback.getBoundMenu(), scaleSpring);
}
 
开发者ID:ppamorim,项目名称:Bound,代码行数:8,代码来源:SpringController.java


注:本文中的com.facebook.rebound.SpringUtil.mapValueFromRangeToRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。