Package org.apache.pivot.wtk.skin.terra
Class TerraSpinnerSkin
- java.lang.Object
-
- org.apache.pivot.wtk.skin.ComponentSkin
-
- org.apache.pivot.wtk.skin.ContainerSkin
-
- org.apache.pivot.wtk.skin.terra.TerraSpinnerSkin
-
- All Implemented Interfaces:
ComponentKeyListener
,ComponentListener
,ComponentMouseButtonListener
,ComponentMouseListener
,ComponentMouseWheelListener
,ComponentStateListener
,ComponentTooltipListener
,ConstrainedVisual
,ContainerListener
,ContainerMouseListener
,Skin
,Spinner.Skin
,SpinnerListener
,SpinnerSelectionListener
,Visual
public class TerraSpinnerSkin extends ContainerSkin implements Spinner.Skin, SpinnerListener, SpinnerSelectionListener
Spinner skin.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
TerraSpinnerSkin.SpinButton
Spinner button.protected class
TerraSpinnerSkin.SpinButtonImage
Abstract base class for button images.protected class
TerraSpinnerSkin.SpinButtonSkin
Spinner button skin.protected class
TerraSpinnerSkin.SpinDownImage
protected class
TerraSpinnerSkin.SpinnerContent
Component that holds the content of a spinner.protected class
TerraSpinnerSkin.SpinnerContentSkin
SpinnerContent skin.protected class
TerraSpinnerSkin.SpinUpImage
-
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.SpinnerListener
SpinnerListener.Adapter, SpinnerListener.Listeners
-
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.SpinnerSelectionListener
SpinnerSelectionListener.Adapter, SpinnerSelectionListener.Listeners
-
-
Field Summary
Fields Modifier and Type Field Description static int
BUTTON_IMAGE_SIZE
-
Constructor Summary
Constructors Constructor Description TerraSpinnerSkin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
circularChanged(Spinner spinner)
Called when a spinner's circular property has changed.void
enabledChanged(Component component)
Called when a component's enabled state has changed.int
getBaseline(int width, int height)
Should be implemented in every subclass.java.awt.Color
getBorderColor()
java.awt.Color
getButtonBackgroundColor()
java.awt.Color
getButtonColor()
java.awt.Color
getColor()
Bounds
getContentBounds()
java.awt.Color
getDisabledColor()
java.awt.Font
getFont()
int
getPreferredHeight(int trialWidth)
Returns the visual's preferred height given the provided width constraint.int
getPreferredWidth(int trialHeight)
Returns the visual's preferred width given the provided height constraint.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.protected void
invalidateContent()
boolean
isSizeToContent()
void
itemRendererChanged(Spinner spinner, Spinner.ItemRenderer previousItemRenderer)
Called when a spinner's item renderer has changed.void
layout()
If the component on which the skin is installed is a container, lays out the container's children.boolean
mouseClick(Component component, Mouse.Button button, int x, int y, int count)
Called when a mouse button is clicked over a component.void
paint(java.awt.Graphics2D graphics)
Paints the visual.void
selectedIndexChanged(Spinner spinner, int previousSelectedIndex)
Called when a spinner's selected index has changed.void
selectedItemChanged(Spinner spinner, java.lang.Object previousSelectedItem)
Called when a spinners's selected item has changed.void
setBorderColor(int borderColorIndex)
void
setBorderColor(java.awt.Color borderColor)
void
setBorderColor(java.lang.String borderColorString)
void
setButtonBackgroundColor(int buttonBackgroundColorIndex)
void
setButtonBackgroundColor(java.awt.Color buttonBackgroundColor)
void
setButtonBackgroundColor(java.lang.String buttonBackgroundColorString)
void
setButtonColor(int buttonColorIndex)
void
setButtonColor(java.awt.Color buttonColor)
void
setButtonColor(java.lang.String buttonColorString)
void
setColor(int color)
void
setColor(java.awt.Color color)
void
setColor(java.lang.String color)
void
setDisabledColor(int disabledColorIndex)
void
setDisabledColor(java.awt.Color disabledColor)
void
setDisabledColor(java.lang.String disabledColorString)
void
setFont(java.awt.Font font)
void
setFont(java.lang.String fontString)
void
setFont(Dictionary<java.lang.String,?> fontDictionary)
void
setSize(int width, int height)
Set the final size of the component after layout has finished.void
setSizeToContent(boolean sizeToContent)
void
spinnerDataChanged(Spinner spinner, List<?> previousSpinnerData)
Called when a spinner's data 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, getColor, getComponent, getFocusRectangleStroke, getHeight, getPreferredSize, getSize, getTextInputMethodListener, getThemeFont, getWidth, heightLimitsChanged, invalidateComponent, keyPressed, keyReleased, keyTyped, locationChanged, menuHandlerChanged, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, setDefaultStyles, 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
-
-
-
-
Field Detail
-
BUTTON_IMAGE_SIZE
public static final int BUTTON_IMAGE_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setSize
public void setSize(int width, int height)
Description copied from class:ComponentSkin
Set the final size of the component after layout has finished.All subclasses must call this superclass method in order to set the
ComponentSkin.width
andComponentSkin.height
values, but may need to do additional calculations before doing so.- Specified by:
setSize
in interfaceConstrainedVisual
- Overrides:
setSize
in classComponentSkin
- Parameters:
width
- The new (final) width of the component after layout.height
- The new (final) height of the component after layout.
-
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 trialHeight)
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:
trialHeight
- 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 trialWidth)
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:
trialWidth
- The width by which to constrain the preferred height, or-1
for no constraint.- Returns:
- The preferred height given the width constraint.
-
getBaseline
public int getBaseline(int width, int height)
Description copied from class:ComponentSkin
Should be implemented in every subclass.The default implementation here simply returns -1 (no baseline).
- Specified by:
getBaseline
in interfaceConstrainedVisual
- Overrides:
getBaseline
in classComponentSkin
- Parameters:
width
- Constrained width to compute the baseline for.height
- Constrained height to compute the baseline for.- Returns:
- The baseline relative to the origin of this visual, or
-1
if this visual does not have a baseline.
-
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.
-
enabledChanged
public void enabledChanged(Component component)
Description copied from interface:ComponentStateListener
Called when a component's enabled state has changed.Called both when the component is enabled and when it is disabled. The component's
enabled
flag has already been set when this method is called so the new state can be determined by calling theComponent.isEnabled()
method.- Specified by:
enabledChanged
in interfaceComponentStateListener
- Overrides:
enabledChanged
in classComponentSkin
- Parameters:
component
- The component whose enabled state is changing.
-
mouseClick
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count)
Description copied from interface:ComponentMouseButtonListener
Called when a mouse button is clicked over a component.- Specified by:
mouseClick
in interfaceComponentMouseButtonListener
- Overrides:
mouseClick
in classComponentSkin
- Parameters:
component
- Component user the mouse pointer.button
- Which mouse button was clicked.x
- X position of the mouse.y
- Y position of the mouse.count
- Number of clicks (1 = single click, 2 = double click, etc.).- Returns:
true
to consume the event;false
to allow it to propagate (default).
-
invalidateContent
protected void invalidateContent()
-
getColor
public java.awt.Color getColor()
-
setColor
public void setColor(java.awt.Color color)
-
setColor
public final void setColor(java.lang.String color)
-
setColor
public final void setColor(int color)
-
getDisabledColor
public java.awt.Color getDisabledColor()
-
setDisabledColor
public void setDisabledColor(java.awt.Color disabledColor)
-
setDisabledColor
public final void setDisabledColor(java.lang.String disabledColorString)
-
setDisabledColor
public final void setDisabledColor(int disabledColorIndex)
-
getBorderColor
public java.awt.Color getBorderColor()
-
setBorderColor
public void setBorderColor(java.awt.Color borderColor)
-
setBorderColor
public final void setBorderColor(java.lang.String borderColorString)
-
setBorderColor
public final void setBorderColor(int borderColorIndex)
-
getButtonColor
public java.awt.Color getButtonColor()
-
setButtonColor
public void setButtonColor(java.awt.Color buttonColor)
-
setButtonColor
public final void setButtonColor(java.lang.String buttonColorString)
-
setButtonColor
public final void setButtonColor(int buttonColorIndex)
-
getButtonBackgroundColor
public java.awt.Color getButtonBackgroundColor()
-
setButtonBackgroundColor
public void setButtonBackgroundColor(java.awt.Color buttonBackgroundColor)
-
setButtonBackgroundColor
public final void setButtonBackgroundColor(java.lang.String buttonBackgroundColorString)
-
setButtonBackgroundColor
public final void setButtonBackgroundColor(int buttonBackgroundColorIndex)
-
getFont
public java.awt.Font getFont()
-
setFont
public void setFont(java.awt.Font font)
-
setFont
public final void setFont(java.lang.String fontString)
-
setFont
public final void setFont(Dictionary<java.lang.String,?> fontDictionary)
-
isSizeToContent
public boolean isSizeToContent()
-
setSizeToContent
public void setSizeToContent(boolean sizeToContent)
-
getContentBounds
public Bounds getContentBounds()
- Specified by:
getContentBounds
in interfaceSpinner.Skin
-
spinnerDataChanged
public void spinnerDataChanged(Spinner spinner, List<?> previousSpinnerData)
Description copied from interface:SpinnerListener
Called when a spinner's data has changed.- Specified by:
spinnerDataChanged
in interfaceSpinnerListener
- Parameters:
spinner
- The source of this event.previousSpinnerData
- What the spinner data used to be.
-
itemRendererChanged
public void itemRendererChanged(Spinner spinner, Spinner.ItemRenderer previousItemRenderer)
Description copied from interface:SpinnerListener
Called when a spinner's item renderer has changed.- Specified by:
itemRendererChanged
in interfaceSpinnerListener
- Parameters:
spinner
- The source of this event.previousItemRenderer
- What the item renderer used to be.
-
circularChanged
public void circularChanged(Spinner spinner)
Description copied from interface:SpinnerListener
Called when a spinner's circular property has changed.- Specified by:
circularChanged
in interfaceSpinnerListener
- Parameters:
spinner
- The source of this event.
-
selectedIndexChanged
public void selectedIndexChanged(Spinner spinner, int previousSelectedIndex)
Description copied from interface:SpinnerSelectionListener
Called when a spinner's selected index has changed.- Specified by:
selectedIndexChanged
in interfaceSpinnerSelectionListener
- Parameters:
spinner
- The source of the event.previousSelectedIndex
- If the selection changed directly, contains the index that was previously selected. Otherwise, contains the current selection.
-
selectedItemChanged
public void selectedItemChanged(Spinner spinner, java.lang.Object previousSelectedItem)
Description copied from interface:SpinnerSelectionListener
Called when a spinners's selected item has changed.- Specified by:
selectedItemChanged
in interfaceSpinnerSelectionListener
- Parameters:
spinner
- The source of the event.previousSelectedItem
- The item that was previously selected, ornull
if the previous selection cannot be determined.
-
-