Class MultiSlider

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class MultiSlider extends AbstractMultiSlider<Integer>
MultiSlider implements a slider with multiple thumbs. The MultiSlider is implemented by drawing a number of sliders on top of each other using an Swing OverlayManager, and passing the mouse events from a glass pane on top to the correct slider(s). The class is a ChangeListener to listen to the changes of individual sliders underneath.

Several models exist to indicate whether thumbs can pass each other or not, or be on top of each other or not.

Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck
See Also:
  • Constructor Details

    • MultiSlider

      public MultiSlider(int min, int max, int... initialValues)
      Creates a horizontal slider using the specified min, max and initial values.
      Parameters:
      min - the minimum value of the slider
      max - the maximum value of the slider
      initialValues - the initial values of the thumbs of the slider
      Throws:
      IllegalArgumentException - if initial values are outside the min-max range, or if the number of thumbs is 0, or when the values are not in increasing order (which is important for restricting passing and overlap)
    • MultiSlider

      public MultiSlider(int min, int max, boolean horizontal, int... initialValues)
      Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. The orientation can be either horizontal or vertical.
      Parameters:
      min - the minimum value of the slider
      max - the maximum value of the slider
      horizontal - the orientation of the slider; true for horizontal, false for vertical
      initialValues - the initial values of the thumbs of the slider
      Throws:
      IllegalArgumentException - if initial values are outside the min-max range, or if the number of thumbs is 0, or when the values are not in increasing order (which is important for restricting passing and overlap)
  • Method Details

    • mapIndexToValue

      protected Integer mapIndexToValue(int index)
      Translate an index to a value.
      Specified by:
      mapIndexToValue in class AbstractMultiSlider<Integer>
      Parameters:
      index - the index on the slider scale to convert
      Returns:
      the corresponding value
    • mapValueToIndex

      protected int mapValueToIndex(Integer value)
      Translate a value to an index.
      Specified by:
      mapValueToIndex in class AbstractMultiSlider<Integer>
      Parameters:
      value - the value to convert to an index
      Returns:
      the corresponding index