Class LinearMultiSlider<T extends Number & Comparable<T>>

Type Parameters:
T - The type of the labels for the multislider
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public abstract class LinearMultiSlider<T extends Number & Comparable<T>> extends AbstractMultiSlider<T>
LinearMultiSlider implements a slider with multiple thumbs and liner values based on the class Number. The slider returns instances of a given type. 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

    • LinearMultiSlider

      @SafeVarargs public LinearMultiSlider(T min, T max, int unitTicks, T... initialValues)
      Creates a horizontal slider using the specified interval, number of steps, and initial values.
      Parameters:
      min - the lowest value of the linear scale
      max - the highest value of the linear scale
      unitTicks - the number of ticks on the linear scale; note that when you need 100 intervals (0-100), ticks should be 101. When you need 99 intervals (1-100), ticks should be 100.
      initialValues - the initial values of the slider
      Throws:
      IllegalArgumentException - if the initial values are not part of the scale, or if the number of thumbs is 0, or when the values are not in increasing scale order (which is important for restricting passing and overlap)
    • LinearMultiSlider

      @SafeVarargs public LinearMultiSlider(T min, T max, int unitTicks, boolean horizontal, T... initialValues)
      Creates a horizontal or vertical slider using the specified min, max and initial values.
      Parameters:
      horizontal - the orientation of the slider; true for horizontal, false for vertical
      min - the lowest value of the linear scale
      max - the highest value of the linear scale
      unitTicks - the number of ticks on the linear scale; note that when you need 100 intervals (0-100), ticks should be 101. When you need 99 intervals (1-100), ticks should be 100.
      initialValues - the initial values of the slider.
      Throws:
      IllegalArgumentException - if the initial values are not part of the scale, or if the number of thumbs is 0, or when the values are not in increasing scale order (which is important for restricting passing and overlap)
  • Method Details

    • mapValueToIndex

      protected int mapValueToIndex(T value)
      Description copied from class: AbstractMultiSlider
      Translate a value to an index.
      Specified by:
      mapValueToIndex in class AbstractMultiSlider<T extends Number & Comparable<T>>
      Parameters:
      value - the value to convert to an index
      Returns:
      the corresponding index
    • getUnitTicks

      public int getUnitTicks()
      Return the number of unit ticks on the scale.
      Returns:
      the number of ticks on the linear scale; note that when you need 100 intervals (0-100), ticks is 101.