Is there any reason the sim.util.Interval class doesn’t have a method to test whether or not a value falls within the interval?
I went ahead and added this method to my local copy:
public boolean contains(Number val)
{
if (val.doubleValue() >= min.doubleValue() && val.doubleValue() <= max.doubleValue())
return true;
return false;
}
It makes using dom sliders and bounds testing a little nicer. For example:
public static double lambda = 1.0;
public double getLambda() { return lambda; }
public void setLambda(double val) { if (((Interval)domLambda()).contains(val)) lambda = val; }
public Object domLambda() { return new Interval(0.0, 1.0); }
Full Interval.java file also attached.
Thanks,
-Ben
Ben Axelrod
Research Scientist
iRobot Corporation
8 Crosby Drive, Mail Stop 8-1
Bedford, MA 01730
(781) 430-3315 (Tel)
(781) 960-2628 (Fax)