NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: RangeSlider extension

Hi Paul,

> I have been using VisAD for visualization apps and
> I really like it.  For one situation I wanted
> a RangeSlider that would only allow endpoints
> from a range of tickmarked values, such as 1.
> to 100. in steps of 3.0.
>
> The most obvious way to do this involved a
> small change to a private method in the current
> source for RangeSlider.  In the main class I
> replaced:
>   private float gripToValue(int pos, int width) {
>     return (((maxLimit - minLimit) * ((float) (pos -
> GRIP_WIDTH))) /
>       (float) (width - (GRIP_WIDTH * 2))) + minLimit;
>   }
>
> With:
>   private float gripToValue(int pos, int width) {
>     return  adjustValue( (((maxLimit - minLimit) *
> ((float) (pos - GRIP_WIDTH))) /
>       (float) (width - (GRIP_WIDTH * 2))) + minLimit
> );
>   }
>   public float adjustValue(float val) { return val ; }
>
> And this allowed me to do what I need in a subclass.
> But this means that I need to include the original
> RangeSlider source, and to maintain it if it changes
> in future versions of VisAD.
>
> Is there a better way to create the RangeSlider I
> want that would not involve future code maintaince?
> Or would it be possible to have this sort of change
> incorporated into the standard distribution?

I'm happy to make these methods accessible so you can
extend the visad.browser.RangeSlider class. But I think
it would be cleaner to just change gripToValue() and
valueToGrip() from private to protected. Does that work
for you? Any other VisAD developers have a comment?

Cheers,
Bill


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: