@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
Slider slider = (Slider)TerraSliderSkin.this.getComponent();
int sliderWidth = slider.getWidth();
int thumbWidth = thumb.getWidth();
Point sliderCoordinates = thumb.mapPointToAncestor(slider, x, y);
int minX = dragOffset.x;
if (sliderCoordinates.x < minX) {
sliderCoordinates.x = minX;
}
int maxX = (sliderWidth - thumbWidth) + dragOffset.x;
if (sliderCoordinates.x > maxX) {
sliderCoordinates.x = maxX;
}
float ratio = (float)(sliderCoordinates.x - dragOffset.x) / (sliderWidth - thumbWidth);
int minimum = slider.getMinimum();
int maximum = slider.getMaximum();
int value = (int)(minimum + (float)(maximum - minimum) * ratio);
slider.setValue(value);
}
return consumed;
}