Class ScalingSlider

All Implemented Interfaces:
FocusListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, SwingConstants

public class ScalingSlider
extends ImmutableSlider
implements ChangeListener, FocusListener, Serializable
The front-end of the provided scalers. Because of the arithmetics and our goal (tackling issues on High DPI displays), the user could decrease UIdefaults with the factor of 2 at most. On the contrary, one could increase with a factor of 100. This could be overwritten though.
Author:
D. Garkov
See Also:
Serialized Form
  • Field Details

    • min

      public static int min
    • max

      public static int max
    • center

      public static int center
  • Constructor Details

    • ScalingSlider

      public ScalingSlider​(Container mainContainer)
      Slider to allow live modifications to the scaling of components. It just has to be initialized e.g. in Preferences window.
      Parameters:
      mainContainer - the applications main Container/Window/Frame
    • ScalingSlider

      public ScalingSlider​(int value, int extent, int min, int max, Container mainContainer)
      Specify your own Slider model. Factors, however, are dependent on values.
      Parameters:
      value - initial Slider's value
      extent - Slider's extent, see JSlider.getExtent()
      min - minimal Slider's value
      max - maximal Slider's value
      mainContainer - the applications main Container/Window/Frame
    • ScalingSlider

      public ScalingSlider​(int extent, int min, int max, Container mainContainer)
      Specify your own Slider model. Factors, however, are dependent on values.
      Parameters:
      extent - Slider's extent, see JSlider.getExtent()
      min - minimal Slider's value
      max - maximal Slider's value
      mainContainer - the applications main Container/Window/Frame
    • ScalingSlider

      public ScalingSlider​(int min, int max, Container mainContainer)
      Specify your own Slider model. Factors, however, are dependent on values.
      Parameters:
      min - minimal Slider's value
      max - maximal Slider's value
      mainContainer - the applications main Container/Window/Frame
  • Method Details

    • getStandard

      public static int getStandard()
      This determines what our standard DPI is.

      Basically, Macintosh uses 72 DPI - dots and pixels to inch are then literally the same (WYSIWYG). However, Windows is another story, to fix some of the 72-DPI-problems, it introduced a 33% bigger size - 96 DPI. As for Linux, we could only assume the Gnome default to be 96 DPI, because otherwise it's just a mess. And then for all the custom resolution displays, e.g. through HDMI, thus we take as a standard the default main-monitor DPI resolution.

    • getSliderValue

      public static int getSliderValue()
      Get the slider value.
      Returns:
      current slider value or most recent, if there is no active instance
    • setSliderValue

      public static boolean setSliderValue​(int value) throws IllegalStateException
      Set the slider value.
      Parameters:
      value - the value to set
      Returns:
      true if within range and successfully set
      Throws:
      IllegalStateException - if called without active instance
    • registerChangeListeners

      public static void registerChangeListeners​(ChangeListener[] changeListeners)
      This method could be used to add any number of ChangeListeners, so that you could synchronize any actions with the movement of the slider, i.e. the live scaling itself.
      Parameters:
      changeListeners -
    • getRegisteredChangeListeners

      public static List<ChangeListener> getRegisteredChangeListeners()
    • stateChanged

      public void stateChanged​(ChangeEvent e)
      Specified by:
      stateChanged in interface ChangeListener
    • focusGained

      public void focusGained​(FocusEvent e)
      Specified by:
      focusGained in interface FocusListener
    • focusLost

      public void focusLost​(FocusEvent e)
      Specified by:
      focusLost in interface FocusListener