Package org.vanted.scaling
Class ScalingSlider
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSlider
org.vanted.scaling.resources.ImmutableSlider
org.vanted.scaling.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
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
Constructors Constructor Description ScalingSlider(int value, int extent, int min, int max, Container mainContainer)
Specify your own Slider model.ScalingSlider(int extent, int min, int max, Container mainContainer)
Specify your own Slider model.ScalingSlider(int min, int max, Container mainContainer)
Specify your own Slider model.ScalingSlider(Container mainContainer)
Slider to allow live modifications to the scaling of components. -
Method Summary
Modifier and Type Method Description void
focusGained(FocusEvent e)
void
focusLost(FocusEvent e)
static List<ChangeListener>
getRegisteredChangeListeners()
static int
getSliderValue()
Get the slider value.static int
getStandard()
This determines what our standard DPI is.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.static boolean
setSliderValue(int value)
Set the slider value.void
stateChanged(ChangeEvent e)
Methods inherited from class org.vanted.scaling.resources.ImmutableSlider
getFont
Methods inherited from class javax.swing.JSlider
addChangeListener, createStandardLabels, createStandardLabels, getAccessibleContext, getChangeListeners, getExtent, getInverted, getLabelTable, getMajorTickSpacing, getMaximum, getMinimum, getMinorTickSpacing, getModel, getOrientation, getPaintLabels, getPaintTicks, getPaintTrack, getSnapToTicks, getUI, getUIClassID, getValue, getValueIsAdjusting, imageUpdate, removeChangeListener, setExtent, setFont, setInverted, setLabelTable, setMajorTickSpacing, setMaximum, setMinimum, setMinorTickSpacing, setModel, setOrientation, setPaintLabels, setPaintTicks, setPaintTrack, setSnapToTicks, setUI, setValue, setValueIsAdjusting, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
min
public static int min -
max
public static int max -
center
public static int center
-
-
Constructor Details
-
ScalingSlider
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
Specify your own Slider model. Factors, however, are dependent on values.- Parameters:
value
- initial Slider's valueextent
- Slider's extent, seeJSlider.getExtent()
min
- minimal Slider's valuemax
- maximal Slider's valuemainContainer
- the applications main Container/Window/Frame
-
ScalingSlider
Specify your own Slider model. Factors, however, are dependent on values.- Parameters:
extent
- Slider's extent, seeJSlider.getExtent()
min
- minimal Slider's valuemax
- maximal Slider's valuemainContainer
- the applications main Container/Window/Frame
-
ScalingSlider
Specify your own Slider model. Factors, however, are dependent on values.- Parameters:
min
- minimal Slider's valuemax
- maximal Slider's valuemainContainer
- 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
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
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
-
stateChanged
- Specified by:
stateChanged
in interfaceChangeListener
-
focusGained
- Specified by:
focusGained
in interfaceFocusListener
-
focusLost
- Specified by:
focusLost
in interfaceFocusListener
-