1   package org.djutils.swing.multislider;
2   
3   /**
4    * MultiSlider implements a slider with multiple thumbs. The MultiSlider is implemented by drawing a number of sliders on top of
5    * each other using an Swing {@code OverlayManager}, and passing the mouse events from a glass pane on top to the correct
6    * slider(s). The class is a {@code ChangeListener} to listen to the changes of individual sliders underneath.
7    * <p>
8    * Several models exist to indicate whether thumbs can pass each other or not, or be on top of each other or not.
9    * </p>
10   * <p>
11   * Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
12   * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
13   * distributed under a three-clause BSD-style license, which can be found at
14   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>.
15   * </p>
16   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   */
18  public class MultiSlider extends AbstractMultiSlider<Integer>
19  {
20      /** */
21      private static final long serialVersionUID = 20241120L;
22  
23      /**
24       * Creates a horizontal slider using the specified min, max and initial values.
25       * @param min the minimum value of the slider
26       * @param max the maximum value of the slider
27       * @param initialValues the initial values of the thumbs of the slider
28       * @throws IllegalArgumentException if initial values are outside the min-max range, or if the number of thumbs is 0, or
29       *             when the values are not in increasing order (which is important for restricting passing and overlap)
30       */
31      public MultiSlider(final int min, final int max, final int... initialValues)
32      {
33          this(min, max, true, initialValues);
34      }
35  
36      /**
37       * Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. The orientation
38       * can be either horizontal or vertical.
39       * @param min the minimum value of the slider
40       * @param max the maximum value of the slider
41       * @param horizontal the orientation of the slider; true for horizontal, false for vertical
42       * @param initialValues the initial values of the thumbs of the slider
43       * @throws IllegalArgumentException if initial values are outside the min-max range, or if the number of thumbs is 0, or
44       *             when the values are not in increasing order (which is important for restricting passing and overlap)
45       */
46      public MultiSlider(final int min, final int max, final boolean horizontal, final int... initialValues)
47      {
48          super(min, max, horizontal, initialValues);
49      }
50  
51      /** {@inheritDoc} */
52      @Override
53      protected Integer mapIndexToValue(final int index)
54      {
55          return index;
56      }
57  
58      /** {@inheritDoc} */
59      @Override
60      protected int mapValueToIndex(final Integer value)
61      {
62          return value;
63      }
64  }