public void setup(final RangeFilter rangeFilter) {
this.filter = rangeFilter;
new Thread(new Runnable() {
public void run() {
final JRangeSliderPanel rangeSlider = (JRangeSliderPanel) rangeSliderPanel;
values = rangeFilter.getValues();
final Range range = (Range) rangeFilter.getRangeProperty().getValue();
rangeSlider.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
try {
if (evt.getPropertyName().equals(JRangeSliderPanel.LOWER_BOUND)) {
Range oldRange = (Range) filter.getRangeProperty().getValue();
final Range newRange = new Range((Number) rangeSlider.getRange().getLowerBound(), (Number) rangeSlider.getRange().getUpperBound(), oldRange.getMinimum(), oldRange.getMaximum());
if (!oldRange.equals(newRange)) {
filter.getRangeProperty().setValue(newRange);
new Thread(new Runnable() {
public void run() {
setupHistogram(filter, newRange);
}
}).start();
}
} else if (evt.getPropertyName().equals(JRangeSliderPanel.UPPER_BOUND)) {
final Range oldRange = (Range) filter.getRangeProperty().getValue();
final Range newRange = new Range((Number) rangeSlider.getRange().getLowerBound(), (Number) rangeSlider.getRange().getUpperBound(), oldRange.getMinimum(), oldRange.getMaximum());
if (!oldRange.equals(newRange)) {
filter.getRangeProperty().setValue(newRange);
new Thread(new Runnable() {
public void run() {
setupHistogram(filter, newRange);
}
}).start();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
SwingUtilities.invokeLater(new Runnable() {
public void run() {
rangeSlider.setRange(new JRangeSliderPanel.Range(
rangeSlider, range.getMinimum(), range.getMaximum(), range.getLowerBound(), range.getUpperBound()));
}
});
setupHistogram(rangeFilter, range);
}