maspack.widgets
Class SliderRange

java.lang.Object
  extended by maspack.widgets.SliderRange

public class SliderRange
extends java.lang.Object


Constructor Summary
SliderRange()
           
 
Method Summary
static DoubleInterval estimateBoundsIfNecessary(NumericInterval range0, double x)
          Estimates the range for a slider, given an initial range range0 and an initial value x (assumed to be within that range).
static DoubleInterval roundBoundsTo125(NumericInterval range0)
          Rounds the upper and lower bounds of a supplied range to conform to
static double roundDown125(double x)
          Rounds a number x down to the nearest value defined by
static double roundUp125(double x)
          Rounds a number x up to the nearest value defined by
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SliderRange

public SliderRange()
Method Detail

roundUp125

public static double roundUp125(double x)
Rounds a number x up to the nearest value defined by
 sgn(x) k 10^n 
 
where n is an integer and k is 1, 2, or 5.

Parameters:
x - number to round up
Returns:
rounded number

roundDown125

public static double roundDown125(double x)
Rounds a number x down to the nearest value defined by
 sgn(x) k 10^n 
 
where n is an integer and k is 1, 2, or 5.

Parameters:
x - number to round down
Returns:
rounded number

estimateBoundsIfNecessary

public static DoubleInterval estimateBoundsIfNecessary(NumericInterval range0,
                                                       double x)
Estimates the range for a slider, given an initial range range0 and an initial value x (assumed to be within that range). Any finite bounds specified by range0 are preserved. In particular, if range0 is completely bounded, the method simply returns a copy the range. Otherwise, if either the upper or lower endpoints of the range are unbounded, the method attempts to determine reasonable values for these, based on x.

Parameters:
range0 - initial range value
x - initial value to help determine bounds if necessary
Returns:
bounded version of range0.

roundBoundsTo125

public static DoubleInterval roundBoundsTo125(NumericInterval range0)
Rounds the upper and lower bounds of a supplied range to conform to
 +/- k 10^n
 
where n is an integer and k is 1, 2 or 5.

Parameters:
range0 - range to be rounded
Returns:
rounded range