views:

51

answers:

1

I have a slider with x number of bars that each represent a range of values. Each bar has an upper and lower handle that is used to manipulate the range. The bars can be interconnected, thus, some of the handles will affect two bars(i.e. the handle is in the middle of the two bars), of which, their movements can affect movements of other bars down the chain. Bars can have a max width, and they can still be pushed/pulled while maintaining their max width. My question is, is there a documented algorithm for validating a move where the user attempts to move a handle to value V, which will, in turn, either push or pull all of the connected bars down the chain?

This is a little hard to explain, so hopefully this made sense. I'm not looking for an actual solution, just some algorithms that might help me come to a solution(i.e. the magic google search terms for this type of problem). Thanks for your help.

A: 

Sounds like you're dealing with a special case of constraint programming. I think you could model your sliders as a series of constraints, i.e.:

slider1 range: (a,b) where a >= MIN, b <= MAX
slider2 range: (c,d) where c > a + x, d <= MAX
...

where x is changed when the user moves the bottom range of slider 2?

It would take time linear in the number of constraints to just evaluate all of the affected equations when the user moves a slider, which isn't too bad. I'm not sure you can do better than that.

Gabe Moothart
Thanks Gabe. I didn't think about approaching it that way(i.e. explicitly setting constraints on each handle, as opposed to validating the moves as they come). This may help me rethink my approach.
Do I get a vote? :-)
Gabe Moothart