Class SynthSliderUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.SliderUI
javax.swing.plaf.basic.BasicSliderUI
javax.swing.plaf.synth.SynthSliderUI
- All Implemented Interfaces:
PropertyChangeListener, EventListener, SynthConstants, SynthUI
Provides the Synth L&F UI delegate for
JSlider.- Since:
- 1.7
-
Nested Class Summary
Nested classes/interfaces inherited from class BasicSliderUI
BasicSliderUI.ActionScroller, BasicSliderUI.ChangeHandler, BasicSliderUI.ComponentHandler, BasicSliderUI.FocusHandler, BasicSliderUI.PropertyChangeHandler, BasicSliderUI.ScrollListener, BasicSliderUI.TrackListenerModifier and TypeClassDescriptionclassAs of Java 2 platform v1.3 this undocumented class is no longer used.classData model listener.classListener for resizing events.classFocus-change listener.classA property change handler.classScroll-event listener.classTrack mouse movements. -
Field Summary
Fields inherited from class BasicSliderUI
changeListener, componentListener, contentRect, focusInsets, focusListener, focusRect, insetCache, labelRect, leftToRightCache, MAX_SCROLL, MIN_SCROLL, NEGATIVE_SCROLL, POSITIVE_SCROLL, propertyChangeListener, scrollListener, scrollTimer, slider, thumbRect, tickRect, trackBuffer, trackListener, trackRectModifier and TypeFieldDescriptionprotected ChangeListenerChange listenerprotected ComponentListenerComponent listenerprotected RectangleContent rectangleprotected InsetsFocus insetsprotected FocusListenerFocus listenerprotected RectangleFocus rectangleprotected InsetsInset cacheprotected RectangleLabel rectangleprotected booleanLeft-to-right cachestatic final intMaximum scrollstatic final intMinimum scrollstatic final intNegative scrollstatic final intPositive scrollprotected PropertyChangeListenerProperty change listenerprotected BasicSliderUI.ScrollListenerScroll listenerprotected TimerScroll timerprotected JSliderSliderprotected RectangleThumb rectangleprotected RectangleTick rectangleprotected intThe distance that the track is from the side of the controlprotected BasicSliderUI.TrackListenerTrack listenerprotected RectangleTrack rectangleFields inherited from interface SynthConstants
DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTEDModifier and TypeFieldDescriptionstatic final intIndicates the region is the default.static final intPrimary state indicating the region is not enabled.static final intPrimary state indicating the component is enabled.static final intIndicates the region has focus.static final intPrimary state indicating the mouse is over the region.static final intPrimary state indicating the region is in a pressed state.static final intIndicates the region is selected. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalculates the geometry.protected voidCalculates the thumb location.protected BasicSliderUI.TrackListenerCreates a track listener.static ComponentUICreates a new UI object for the given component.intgetBaseline(JComponent c, int width, int height) Returns the baseline.Returns the Context for the specified component.Returns the minimum size.Returns the preferred size.protected DimensionReturns the thumb size.protected voidinstallDefaults(JSlider slider) Installs the defaults.protected voidinstallListeners(JSlider slider) Installs listeners.protected voidlayout()Lays out the slider.voidpaint(Graphics g, JComponent c) Paints the specified component according to the Look and Feel.protected voidpaint(SynthContext context, Graphics g) Paints the specified component.voidpaintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) Paints the border.protected voidpaintThumb(SynthContext context, Graphics g, Rectangle thumbBounds) Paints the slider thumb.protected voidpaintTrack(SynthContext context, Graphics g, Rectangle trackBounds) Paints the slider track.voidThis method gets called when a bound property is changed.protected voidRecalculates if the insets have changed.voidsetThumbLocation(int x, int y) Sets the thumb location.protected voiduninstallDefaults(JSlider slider) Uninstalls default setting.protected voiduninstallListeners(JSlider slider) Uninstalls listeners.voidupdate(Graphics g, JComponent c) Notifies this UI delegate to repaint the specified component.intvalueForXPosition(int xPos) Returns the value at the x position.intvalueForYPosition(int yPos) Returns the value at the y position.protected intxPositionForValue(int value) Returns the x position for a value.protected intyPositionForValue(int value, int trackY, int trackHeight) Returns the y location for the specified value.Methods inherited from class BasicSliderUI
calculateContentRect, calculateFocusRect, calculateLabelRect, calculateThumbSize, calculateTickRect, calculateTrackBuffer, calculateTrackRect, createChangeListener, createComponentListener, createFocusListener, createPropertyChangeListener, createScrollListener, drawInverted, getBaselineResizeBehavior, getFocusColor, getHeightOfHighValueLabel, getHeightOfLowValueLabel, getHeightOfTallestLabel, getHighestValue, getHighestValueLabel, getHighlightColor, getLowestValue, getLowestValueLabel, getMaximumSize, getMinimumHorizontalSize, getMinimumVerticalSize, getPreferredHorizontalSize, getPreferredVerticalSize, getShadowColor, getTickLength, getWidthOfHighValueLabel, getWidthOfLowValueLabel, getWidthOfWidestLabel, installKeyboardActions, installUI, isDragging, labelsHaveSameBaselines, paintFocus, paintHorizontalLabel, paintLabels, paintMajorTickForHorizSlider, paintMajorTickForVertSlider, paintMinorTickForHorizSlider, paintMinorTickForVertSlider, paintThumb, paintTicks, paintTrack, paintVerticalLabel, recalculateIfOrientationChanged, scrollByBlock, scrollByUnit, scrollDueToClickInTrack, uninstallKeyboardActions, uninstallUI, yPositionForValueModifier and TypeMethodDescriptionprotected voidCalculates the content rectangle.protected voidCalculates the focus rectangle.protected voidCalculates the label rectangle.protected voidCalculates the thumb size rectangle.protected voidCalculates the tick rectangle.protected voidCalculates the track buffer.protected voidCalculates the track rectangle.protected ChangeListenercreateChangeListener(JSlider slider) Creates a change listener.protected ComponentListenercreateComponentListener(JSlider slider) Creates a composite listener.protected FocusListenercreateFocusListener(JSlider slider) Creates a focus listener.protected PropertyChangeListenercreatePropertyChangeListener(JSlider slider) Creates a property change listener.protected BasicSliderUI.ScrollListenercreateScrollListener(JSlider slider) Creates a scroll listener.protected booleanDraws inverted.Returns an enum indicating how the baseline of the component changes as the size changes.protected ColorReturns the focus color.protected intReturns the height of the highest value label.protected intReturns the height of the lowest value label.protected intReturns the height of the tallest label.protected IntegerReturns the biggest value that has an entry in the label table.protected ComponentReturns the label that corresponds to the lowest slider value in the label table.protected ColorReturns the highlight color.protected IntegerReturns the smallest value that has an entry in the label table.protected ComponentReturns the label that corresponds to the highest slider value in the label table.Returns the maximum size.Returns the minimum horizontal size.Returns the minimum vertical size.Returns the preferred horizontal size.Returns the preferred vertical size.protected ColorReturns the shadow color.protected intGets the height of the tick area for horizontal sliders and the width of the tick area for vertical sliders.protected intReturns the width of the highest value label.protected intReturns the width of the lowest value label.protected intReturns the width of the widest label.protected voidinstallKeyboardActions(JSlider slider) Installs keyboard actions.voidInstalls a UI.protected booleanReturns true if the user is dragging the slider.protected booleanReturns true if all the labels from the label table have the same baseline.voidPaints focus.protected voidpaintHorizontalLabel(Graphics g, int value, Component label) Called for every label in the label table.voidPaints the labels.protected voidpaintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) Paints major tick for horizontal slider.protected voidpaintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) Paints major tick for vertical slider.protected voidpaintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) Paints minor tick for horizontal slider.protected voidpaintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) Paints minor tick for vertical slider.voidPaints the thumb.voidPaints ticks.voidPaints track.protected voidpaintVerticalLabel(Graphics g, int value, Component label) Called for every label in the label table.protected voidRecalculates if the orientation has changed.voidscrollByBlock(int direction) Scrolls by block.voidscrollByUnit(int direction) Scrolls by unit.protected voidscrollDueToClickInTrack(int dir) This function is called when a mousePressed was detected in the track, not in the thumb.protected voiduninstallKeyboardActions(JSlider slider) Uninstalls keyboard actions.voidUninstalls a UI.protected intyPositionForValue(int value) Returns the y position for a value.Methods inherited from class ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCountModifier and TypeMethodDescriptionbooleancontains(JComponent c, int x, int y) Returnstrueif the specified x,y location is contained within the look and feel's defined shape of the specified component.getAccessibleChild(JComponent c, int i) Returns theithAccessiblechild of the object.intReturns the number of accessible children in the object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
SynthSliderUI
-
-
Method Details
-
createUI
Creates a new UI object for the given component.- Parameters:
c- component to create UI object for- Returns:
- the UI object
-
installDefaults
Installs the defaults.- Overrides:
installDefaultsin classBasicSliderUI- Parameters:
slider- a slider
-
uninstallDefaults
Uninstalls default setting. This method is called when aLookAndFeelis uninstalled.- Overrides:
uninstallDefaultsin classBasicSliderUI- Parameters:
slider- a slider
-
installListeners
Installs listeners.- Overrides:
installListenersin classBasicSliderUI- Parameters:
slider- a slider
-
uninstallListeners
Uninstalls listeners.- Overrides:
uninstallListenersin classBasicSliderUI- Parameters:
slider- a slider
-
createTrackListener
Creates a track listener.- Overrides:
createTrackListenerin classBasicSliderUI- Parameters:
s- a slider- Returns:
- a track listener
-
getBaseline
Returns the baseline.- Overrides:
getBaselinein classBasicSliderUI- Parameters:
c-JComponentbaseline is being requested forwidth- the width to get the baseline forheight- the height to get the baseline for- Returns:
- baseline or a value < 0 indicating there is no reasonable baseline
- See Also:
-
getPreferredSize
Returns the preferred size.- Overrides:
getPreferredSizein classBasicSliderUI- Parameters:
c- a component- Returns:
- the preferred size
- See Also:
-
getMinimumSize
Returns the minimum size.- Overrides:
getMinimumSizein classBasicSliderUI- Parameters:
c- a component- Returns:
- the minimum size
- See Also:
-
calculateGeometry
protected void calculateGeometry()Calculates the geometry.- Overrides:
calculateGeometryin classBasicSliderUI
-
layout
protected void layout()Lays out the slider. -
calculateThumbLocation
protected void calculateThumbLocation()Calculates the thumb location.- Overrides:
calculateThumbLocationin classBasicSliderUI
-
setThumbLocation
public void setThumbLocation(int x, int y) Sets the thumb location.- Overrides:
setThumbLocationin classBasicSliderUI- Parameters:
x- the x coordinatey- the y coordinate
-
xPositionForValue
protected int xPositionForValue(int value) Returns the x position for a value.- Overrides:
xPositionForValuein classBasicSliderUI- Parameters:
value- the value- Returns:
- the x position for a value
-
yPositionForValue
protected int yPositionForValue(int value, int trackY, int trackHeight) Returns the y location for the specified value. No checking is done on the arguments. In particular iftrackHeightis negative undefined results may occur.- Overrides:
yPositionForValuein classBasicSliderUI- Parameters:
value- the slider value to get the location fortrackY- y-origin of the tracktrackHeight- the height of the track- Returns:
- the y location for the specified value of the slider
-
valueForYPosition
public int valueForYPosition(int yPos) Returns the value at the y position. IfyPosis beyond the track at the bottom or the top, this method sets the value to either the minimum or maximum value of the slider, depending on if the slider is inverted or not.- Overrides:
valueForYPositionin classBasicSliderUI- Parameters:
yPos- the location of the slider along the y axis- Returns:
- the value at the y position
-
valueForXPosition
public int valueForXPosition(int xPos) Returns the value at the x position. IfxPosis beyond the track at the left or the right, this method sets the value to either the minimum or maximum value of the slider, depending on if the slider is inverted or not.- Overrides:
valueForXPositionin classBasicSliderUI- Parameters:
xPos- the location of the slider along the x axis- Returns:
- the value of the x position
-
getThumbSize
Returns the thumb size.- Overrides:
getThumbSizein classBasicSliderUI- Returns:
- the thumb size
-
recalculateIfInsetsChanged
protected void recalculateIfInsetsChanged()Recalculates if the insets have changed.- Overrides:
recalculateIfInsetsChangedin classBasicSliderUI
-
getContext
Returns the Context for the specified component.- Specified by:
getContextin interfaceSynthUI- Parameters:
c- Component requesting SynthContext.- Returns:
- SynthContext describing component.
-
update
Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls thepaint(SynthContext,Graphics)method.In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the
paintmethod.- Overrides:
updatein classComponentUI- Parameters:
g- theGraphicsobject used for paintingc- the component being painted- See Also:
-
paint
Paints the specified component according to the Look and Feel.This method is not used by Synth Look and Feel. Painting is handled by the
paint(SynthContext,Graphics)method.- Overrides:
paintin classBasicSliderUI- Parameters:
g- theGraphicsobject used for paintingc- the component being painted- See Also:
-
paint
Paints the specified component.- Parameters:
context- context for the component being paintedg- theGraphicsobject used for painting- See Also:
-
paintBorder
Paints the border.- Specified by:
paintBorderin interfaceSynthUI- Parameters:
context- a component contextg-Graphicsto paint onx- the X coordinatey- the Y coordinatew- width of the borderh- height of the border
-
paintThumb
Paints the slider thumb.- Parameters:
context- context for the component being paintedg-Graphicsobject used for paintingthumbBounds- bounding box for the thumb
-
paintTrack
Paints the slider track.- Parameters:
context- context for the component being paintedg-Graphicsobject used for paintingtrackBounds- bounding box for the track
-
propertyChange
This method gets called when a bound property is changed.- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
e- A PropertyChangeEvent object describing the event source and the property that has changed.
-