public void onProgressChanged(SeekBar seekBar, int val, boolean b) { if (seekBar == SpringConfiguratorView.this.mTensionSeekBar) { float scaledTension = ((((float) val) * SpringConfiguratorView.MAX_TENSION) / 100000.0f) + 0.0f; SpringConfiguratorView.this.mSelectedSpringConfig.tension = OrigamiValueConverter .tensionFromOrigamiValue((double) scaledTension); SpringConfiguratorView.this.mTensionLabel.setText("T:" + SpringConfiguratorView .DECIMAL_FORMAT.format((double) scaledTension)); } if (seekBar == SpringConfiguratorView.this.mFrictionSeekBar) { float scaledFriction = ((((float) val) * 50.0f) / 100000.0f) + 0.0f; SpringConfiguratorView.this.mSelectedSpringConfig.friction = OrigamiValueConverter.frictionFromOrigamiValue((double) scaledFriction); SpringConfiguratorView.this.mFrictionLabel.setText("F:" + SpringConfiguratorView .DECIMAL_FORMAT.format((double) scaledFriction)); } }
@Override public void onProgressChanged(SeekBar seekBar, int val, boolean b) { float tensionRange = MAX_TENSION - MIN_TENSION; float frictionRange = MAX_FRICTION - MIN_FRICTION; if (seekBar == mTensionSeekBar) { float scaledTension = ((val) * tensionRange) / MAX_SEEKBAR_VAL + MIN_TENSION; mSelectedSpringConfig.tension = OrigamiValueConverter.tensionFromOrigamiValue(scaledTension); String roundedTensionLabel = DECIMAL_FORMAT.format(scaledTension); mTensionLabel.setText("T:" + roundedTensionLabel); } if (seekBar == mFrictionSeekBar) { float scaledFriction = ((val) * frictionRange) / MAX_SEEKBAR_VAL + MIN_FRICTION; mSelectedSpringConfig.friction = OrigamiValueConverter.frictionFromOrigamiValue(scaledFriction); String roundedFrictionLabel = DECIMAL_FORMAT.format(scaledFriction); mFrictionLabel.setText("F:" + roundedFrictionLabel); } }
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); }
/** * 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); }