Package org.apache.pivot.wtk.skin.terra
Class TerraScrollBarSkin
- java.lang.Object
-
- org.apache.pivot.wtk.skin.ComponentSkin
-
- org.apache.pivot.wtk.skin.ContainerSkin
-
- org.apache.pivot.wtk.skin.terra.TerraScrollBarSkin
-
- All Implemented Interfaces:
ComponentKeyListener
,ComponentListener
,ComponentMouseButtonListener
,ComponentMouseListener
,ComponentMouseWheelListener
,ComponentStateListener
,ComponentTooltipListener
,ConstrainedVisual
,ContainerListener
,ContainerMouseListener
,ScrollBarListener
,ScrollBarValueListener
,Skin
,Visual
public class TerraScrollBarSkin extends ContainerSkin implements ScrollBarListener, ScrollBarValueListener
Scroll bar skin.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
TerraScrollBarSkin.AutomaticScroller
Encapsulates the code needed to perform timer-controlled scrolling.protected class
TerraScrollBarSkin.Handle
Scroll bar handle component.protected class
TerraScrollBarSkin.HandleSkin
Scroll bar scroll handle component skin.protected class
TerraScrollBarSkin.ScrollButton
Scroll bar scroll button component.protected class
TerraScrollBarSkin.ScrollButtonImage
protected class
TerraScrollBarSkin.ScrollButtonSkin
Scroll bar scroll button component skin.protected class
TerraScrollBarSkin.ScrollDownImage
protected class
TerraScrollBarSkin.ScrollUpImage
-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.skin.ContainerSkin
ContainerSkin.IndexFocusTraversalPolicy
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentKeyListener
ComponentKeyListener.Adapter, ComponentKeyListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentListener
ComponentListener.Adapter, ComponentListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseButtonListener
ComponentMouseButtonListener.Adapter, ComponentMouseButtonListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseListener
ComponentMouseListener.Adapter, ComponentMouseListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseWheelListener
ComponentMouseWheelListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentStateListener
ComponentStateListener.Adapter, ComponentStateListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentTooltipListener
ComponentTooltipListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerListener
ContainerListener.Adapter, ContainerListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ContainerMouseListener
ContainerMouseListener.Adapter, ContainerMouseListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ScrollBarListener
ScrollBarListener.Adapter, ScrollBarListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ScrollBarValueListener
ScrollBarValueListener.Listeners
-
-
Constructor Summary
Constructors Constructor Description TerraScrollBarSkin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
blockIncrementChanged(ScrollBar scrollBar, int previousBlockIncrement)
Called when a scroll bar's block increment has changed.void
enabledChanged(Component component)
Propagates the scroll bar's enabled state to the scroll buttons.java.awt.Color
getBorderColor()
int
getMinimumHandleLength()
int
getPreferredHeight(int width)
Returns the visual's preferred height given the provided width constraint.Dimensions
getPreferredSize()
Returns the visual's unconstrained preferred size.int
getPreferredWidth(int height)
Returns the visual's preferred width given the provided height constraint.java.awt.Color
getScrollButtonBackgroundColor()
java.awt.Color
getScrollButtonDisabledBackgroundColor()
java.awt.Color
getScrollButtonHighlightedBackgroundColor()
java.awt.Color
getScrollButtonImageColor()
java.awt.Color
getScrollButtonPressedBackgroundColor()
void
install(Component component)
Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.void
layout()
If the component on which the skin is installed is a container, lays out the container's children.boolean
mouseDown(Component component, Mouse.Button button, int x, int y)
Initiates automatic block scrolling.void
mouseOut(Component component)
Called when the mouse exits a component.boolean
mouseUp(Component component, Mouse.Button button, int x, int y)
Cancels automatic block scrolling.boolean
mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
Updates the scroll bar's value.void
orientationChanged(ScrollBar scrollBar, Orientation previousOrientation)
Called when a scroll bar's orientation has changed.void
paint(java.awt.Graphics2D graphics)
Paints the visual.void
scopeChanged(ScrollBar scrollBar, int previousStart, int previousEnd, int previousExtent)
Called when a scroll bar's scope has changed.void
setBorderColor(int borderColor)
void
setBorderColor(java.awt.Color borderColor)
void
setBorderColor(java.lang.String borderColor)
void
setMinimumHandleLength(int minimumHandleLength)
void
setScrollButtonBackgroundColor(int scrollButtonBackgroundColor)
void
setScrollButtonBackgroundColor(java.awt.Color scrollButtonBackgroundColor)
void
setScrollButtonBackgroundColor(java.lang.String scrollButtonBackgroundColor)
void
setScrollButtonDisabledBackgroundColor(int scrollButtonDisabledBackgroundColor)
void
setScrollButtonDisabledBackgroundColor(java.awt.Color scrollButtonDisabledBackgroundColor)
void
setScrollButtonDisabledBackgroundColor(java.lang.String scrollButtonDisabledBackgroundColor)
void
setScrollButtonHighlightedBackgroundColor(int scrollButtonHighlightedBackgroundColor)
void
setScrollButtonHighlightedBackgroundColor(java.awt.Color scrollButtonHighlightedBackgroundColor)
void
setScrollButtonHighlightedBackgroundColor(java.lang.String scrollButtonHighlightedBackgroundColor)
void
setScrollButtonImageColor(int scrollButtonImageColor)
void
setScrollButtonImageColor(java.awt.Color scrollButtonImageColor)
void
setScrollButtonImageColor(java.lang.String scrollButtonImageColor)
void
setScrollButtonPressedBackgroundColor(int scrollButtonPressedBackgroundColor)
void
setScrollButtonPressedBackgroundColor(java.awt.Color scrollButtonPressedBackgroundColor)
void
setScrollButtonPressedBackgroundColor(java.lang.String scrollButtonPressedBackgroundColor)
void
unitIncrementChanged(ScrollBar scrollBar, int previousUnitIncrement)
Called when a scroll bar's unit increment has changed.void
valueChanged(ScrollBar scrollBar, int previousValue)
Called when a scroll bar's value has changed.-
Methods inherited from class org.apache.pivot.wtk.skin.ContainerSkin
componentInserted, componentMoved, componentsRemoved, focusTraversalPolicyChanged, getBackgroundColor, getBackgroundPaint, isFocusable, isOpaque, mouseDown, mouseMove, mouseUp, mouseWheel, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundPaint, setBackgroundPaint, setBackgroundPaint
-
Methods inherited from class org.apache.pivot.wtk.skin.ComponentSkin
colorFromObject, colorFromObject, colorFromObject, colorFromObject, currentTheme, cursorChanged, decodeFont, defaultBackgroundColor, defaultForegroundColor, dragSourceChanged, dropTargetChanged, focusedChanged, fontFromObject, getBaseline, getBaseline, getColor, getComponent, getFocusRectangleStroke, getHeight, getSize, getTextInputMethodListener, getThemeFont, getWidth, heightLimitsChanged, invalidateComponent, keyPressed, keyReleased, keyTyped, locationChanged, menuHandlerChanged, mouseClick, mouseMove, mouseOver, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, setDefaultStyles, setSize, sizeChanged, themeHasThickFocusRectangle, themeHasTransitionEnabled, themeIsDark, themeIsFlat, tooltipDelayChanged, tooltipTextChanged, tooltipTriggered, visibleChanged, widthLimitsChanged
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pivot.wtk.ConstrainedVisual
setSize
-
-
-
-
Method Detail
-
install
public void install(Component component)
Description copied from class:ComponentSkin
Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.- Specified by:
install
in interfaceSkin
- Overrides:
install
in classContainerSkin
- Parameters:
component
- The component to which the skin is being attached.
-
getPreferredWidth
public int getPreferredWidth(int height)
Description copied from interface:ConstrainedVisual
Returns the visual's preferred width given the provided height constraint.- Specified by:
getPreferredWidth
in interfaceConstrainedVisual
- Overrides:
getPreferredWidth
in classContainerSkin
- Parameters:
height
- The height by which to constrain the preferred width, or-1
for no constraint.- Returns:
- The preferred width given the height constraint.
-
getPreferredHeight
public int getPreferredHeight(int width)
Description copied from interface:ConstrainedVisual
Returns the visual's preferred height given the provided width constraint.- Specified by:
getPreferredHeight
in interfaceConstrainedVisual
- Overrides:
getPreferredHeight
in classContainerSkin
- Parameters:
width
- The width by which to constrain the preferred height, or-1
for no constraint.- Returns:
- The preferred height given the width constraint.
-
getPreferredSize
public Dimensions getPreferredSize()
Description copied from interface:ConstrainedVisual
Returns the visual's unconstrained preferred size.- Specified by:
getPreferredSize
in interfaceConstrainedVisual
- Overrides:
getPreferredSize
in classComponentSkin
- Returns:
- The preferred size (width and height) of this component.
Depending on the component this can be a static value or derived (as for a container) from its subcomponents, etc.
The default implementation simply calls
ConstrainedVisual.getPreferredWidth(int)
andConstrainedVisual.getPreferredHeight(int)
.
-
layout
public void layout()
Description copied from interface:Skin
If the component on which the skin is installed is a container, lays out the container's children.
-
paint
public void paint(java.awt.Graphics2D graphics)
Description copied from interface:Visual
Paints the visual.- Specified by:
paint
in interfaceVisual
- Overrides:
paint
in classContainerSkin
- Parameters:
graphics
- The graphics context in which to paint the visual.
-
getMinimumHandleLength
public int getMinimumHandleLength()
-
setMinimumHandleLength
public void setMinimumHandleLength(int minimumHandleLength)
-
getBorderColor
public java.awt.Color getBorderColor()
-
setBorderColor
public void setBorderColor(java.awt.Color borderColor)
-
setBorderColor
public final void setBorderColor(java.lang.String borderColor)
-
setBorderColor
public final void setBorderColor(int borderColor)
-
getScrollButtonImageColor
public java.awt.Color getScrollButtonImageColor()
-
setScrollButtonImageColor
public void setScrollButtonImageColor(java.awt.Color scrollButtonImageColor)
-
setScrollButtonImageColor
public final void setScrollButtonImageColor(java.lang.String scrollButtonImageColor)
-
setScrollButtonImageColor
public final void setScrollButtonImageColor(int scrollButtonImageColor)
-
getScrollButtonBackgroundColor
public java.awt.Color getScrollButtonBackgroundColor()
-
setScrollButtonBackgroundColor
public void setScrollButtonBackgroundColor(java.awt.Color scrollButtonBackgroundColor)
-
setScrollButtonBackgroundColor
public final void setScrollButtonBackgroundColor(java.lang.String scrollButtonBackgroundColor)
-
setScrollButtonBackgroundColor
public final void setScrollButtonBackgroundColor(int scrollButtonBackgroundColor)
-
getScrollButtonDisabledBackgroundColor
public java.awt.Color getScrollButtonDisabledBackgroundColor()
-
setScrollButtonDisabledBackgroundColor
public void setScrollButtonDisabledBackgroundColor(java.awt.Color scrollButtonDisabledBackgroundColor)
-
setScrollButtonDisabledBackgroundColor
public final void setScrollButtonDisabledBackgroundColor(java.lang.String scrollButtonDisabledBackgroundColor)
-
setScrollButtonDisabledBackgroundColor
public final void setScrollButtonDisabledBackgroundColor(int scrollButtonDisabledBackgroundColor)
-
getScrollButtonPressedBackgroundColor
public java.awt.Color getScrollButtonPressedBackgroundColor()
-
setScrollButtonPressedBackgroundColor
public void setScrollButtonPressedBackgroundColor(java.awt.Color scrollButtonPressedBackgroundColor)
-
setScrollButtonPressedBackgroundColor
public final void setScrollButtonPressedBackgroundColor(java.lang.String scrollButtonPressedBackgroundColor)
-
setScrollButtonPressedBackgroundColor
public final void setScrollButtonPressedBackgroundColor(int scrollButtonPressedBackgroundColor)
-
getScrollButtonHighlightedBackgroundColor
public java.awt.Color getScrollButtonHighlightedBackgroundColor()
-
setScrollButtonHighlightedBackgroundColor
public void setScrollButtonHighlightedBackgroundColor(java.awt.Color scrollButtonHighlightedBackgroundColor)
-
setScrollButtonHighlightedBackgroundColor
public final void setScrollButtonHighlightedBackgroundColor(java.lang.String scrollButtonHighlightedBackgroundColor)
-
setScrollButtonHighlightedBackgroundColor
public final void setScrollButtonHighlightedBackgroundColor(int scrollButtonHighlightedBackgroundColor)
-
mouseOut
public void mouseOut(Component component)
Description copied from interface:ComponentMouseListener
Called when the mouse exits a component.Default is to do nothing.
- Specified by:
mouseOut
in interfaceComponentMouseListener
- Overrides:
mouseOut
in classComponentSkin
- Parameters:
component
- Component that has now lost the mouse pointer.
-
mouseDown
public boolean mouseDown(Component component, Mouse.Button button, int x, int y)
Initiates automatic block scrolling. This only happens if the handle is visible since whether the user clicked before or after the handle determines the direction of the scrolling.- Specified by:
mouseDown
in interfaceComponentMouseButtonListener
- Overrides:
mouseDown
in classComponentSkin
- Parameters:
component
- The scroll bar.button
- The button that was pressed.x
- The x-coordinate of the event in the scroll bar's coordinate space.y
- The y-coordinate of the event in the scroll bar's coordinate space.- Returns:
true
to consume the event;false
to allow it to propagate (default).
-
mouseUp
public boolean mouseUp(Component component, Mouse.Button button, int x, int y)
Cancels automatic block scrolling.- Specified by:
mouseUp
in interfaceComponentMouseButtonListener
- Overrides:
mouseUp
in classComponentSkin
- Parameters:
component
- The scroll bar.button
- The button that was released.x
- The x-coordinate of the event in the scroll bar's coordinate space.y
- The y-coordinate of the event in the scroll bar's coordinate space.- Returns:
true
to consume the event;false
to allow it to propagate (default).
-
mouseWheel
public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
Updates the scroll bar's value.- Specified by:
mouseWheel
in interfaceComponentMouseWheelListener
- Overrides:
mouseWheel
in classComponentSkin
- Parameters:
component
- The scroll bar.scrollType
- Unit or block scrolling.scrollAmount
- The amount of scrolling.wheelRotation
--1
or1
for backward or forward scrolling, respectively.x
- The x-coordinate of the event in the scroll bar's coordinate space.y
- The y-coordinate of the event in the scroll bar's coordinate space.- Returns:
true
to consume the event;false
to allow it to propagate.
-
enabledChanged
public void enabledChanged(Component component)
Propagates the scroll bar's enabled state to the scroll buttons.- Specified by:
enabledChanged
in interfaceComponentStateListener
- Overrides:
enabledChanged
in classComponentSkin
- Parameters:
component
- The scroll bar.
-
orientationChanged
public void orientationChanged(ScrollBar scrollBar, Orientation previousOrientation)
Description copied from interface:ScrollBarListener
Called when a scroll bar's orientation has changed.- Specified by:
orientationChanged
in interfaceScrollBarListener
- Parameters:
scrollBar
- The scroll bar that changed orientation.previousOrientation
- The previous orientation.
-
scopeChanged
public void scopeChanged(ScrollBar scrollBar, int previousStart, int previousEnd, int previousExtent)
Description copied from interface:ScrollBarListener
Called when a scroll bar's scope has changed.- Specified by:
scopeChanged
in interfaceScrollBarListener
- Parameters:
scrollBar
- The scroll bar that changed.previousStart
- The previous start value.previousEnd
- The previous end value.previousExtent
- The previous scroll bar extent value.
-
unitIncrementChanged
public void unitIncrementChanged(ScrollBar scrollBar, int previousUnitIncrement)
Description copied from interface:ScrollBarListener
Called when a scroll bar's unit increment has changed.- Specified by:
unitIncrementChanged
in interfaceScrollBarListener
- Parameters:
scrollBar
- The scroll bar that changed.previousUnitIncrement
- The previous unit increment value.
-
blockIncrementChanged
public void blockIncrementChanged(ScrollBar scrollBar, int previousBlockIncrement)
Description copied from interface:ScrollBarListener
Called when a scroll bar's block increment has changed.- Specified by:
blockIncrementChanged
in interfaceScrollBarListener
- Parameters:
scrollBar
- The scroll bar that changed.previousBlockIncrement
- The previous block increment value.
-
valueChanged
public void valueChanged(ScrollBar scrollBar, int previousValue)
Description copied from interface:ScrollBarValueListener
Called when a scroll bar's value has changed.- Specified by:
valueChanged
in interfaceScrollBarValueListener
- Parameters:
scrollBar
- The scroll bar that is changing.previousValue
- The previous value of this scroll bar.
-
-