Class CategorialMultiSlider<T>

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

public class CategorialMultiSlider<T> extends AbstractMultiSlider<T>
CategorialMultiSlider implements a slider with multiple thumbs and categorial values. 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

    • CategorialMultiSlider

      @SafeVarargs public CategorialMultiSlider(List<T> scale, T... initialValues)
      Creates a horizontal slider using the specified scale and initial values.
      Parameters:
      scale - the list of categorial values for the scale
      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), or when the scale has duplicate values
    • CategorialMultiSlider

      @SafeVarargs public CategorialMultiSlider(boolean horizontal, List<T> scale, 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
      scale - the list of categorial values for the scale
      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), or when the scale has duplicate values
  • Method Details

    • mapIndexToValue

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

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