MASON-INTEREST-L Archives

January 2012

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Axelrod, Benjamin" <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Tue, 3 Jan 2012 18:01:05 +0000
Content-Type:
multipart/mixed
Parts/Attachments:
text/plain (907 bytes) , text/html (8 kB) , Interval.java (8 kB)
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)
[log in to unmask]



ATOM RSS1 RSS2