org.apache.pivot.wtk.skin.terra
Class TerraTextInputSkin

java.lang.Object
  extended by org.apache.pivot.wtk.skin.ComponentSkin
      extended by org.apache.pivot.wtk.skin.terra.TerraTextInputSkin
All Implemented Interfaces:
ComponentKeyListener, ComponentListener, ComponentMouseButtonListener, ComponentMouseListener, ComponentMouseWheelListener, ComponentStateListener, ComponentTooltipListener, ConstrainedVisual, Skin, TextInput.Skin, TextInputContentListener, TextInputListener, TextInputSelectionListener, Visual

public class TerraTextInputSkin
extends ComponentSkin
implements TextInput.Skin, TextInputListener, TextInputContentListener, TextInputSelectionListener

Text input skin.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.TextInputListener
TextInputListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.TextInputContentListener
TextInputContentListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentListener
ComponentListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentStateListener
ComponentStateListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseListener
ComponentMouseListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentMouseButtonListener
ComponentMouseButtonListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.ComponentKeyListener
ComponentKeyListener.Adapter
 
Constructor Summary
TerraTextInputSkin()
           
 
Method Summary
 void editableChanged(TextInput textInput)
          Called when the editable state has changed.
 void enabledChanged(Component component)
          Called when a component's enabled state has changed.
 void focusedChanged(Component component, Component obverseComponent)
          Called when a component's focused state has changed.
 Color getBackgroundColor()
           
 int getBaseline(int width, int height)
          Returns the baseline for a given width and height.
 Color getBorderColor()
           
 Bounds getCharacterBounds(int index)
          Returns the bounds of the character at a given index.
 Color getColor()
           
 Color getDisabledBackgroundColor()
           
 Color getDisabledBorderColor()
           
 Color getDisabledColor()
           
 Font getFont()
           
 HorizontalAlignment getHorizontalAlignment()
           
 Color getInactiveSelectionBackgroundColor()
           
 Color getInactiveSelectionColor()
           
 int getInsertionPoint(int x)
          Returns the insertion point for a given location.
 Color getInvalidBackgroundColor()
           
 Color getInvalidColor()
           
 Insets getPadding()
           
 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.
 Color getPromptColor()
           
 Color getSelectionBackgroundColor()
           
 Color getSelectionColor()
           
 void insertTextVetoed(TextInput textInput, Vote reason)
          Called when a text insertion has been vetoed.
 void install(Component component)
          Associates a skin with a component.
 boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation)
          DELETE Delete the character after the caret or the entire selection if there is one.
 boolean keyTyped(Component component, char character)
          Called when a key has been typed.
 void layout()
          If the component on which the skin is installed is a container, lays out the container's children.
 void maximumLengthChanged(TextInput textInput, int previousMaximumLength)
          Called when a text input's maximum length has changed.
 boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count)
          Called when a mouse button is clicked over a component.
 boolean mouseDown(Component component, Mouse.Button button, int x, int y)
          Called when a mouse button is pressed over a component.
 boolean mouseMove(Component component, int x, int y)
          Called when the mouse is moved over a component.
 boolean mouseUp(Component component, Mouse.Button button, int x, int y)
          Called when a mouse button is released over a component.
 void paint(Graphics2D graphics)
          Paints the visual.
 void passwordChanged(TextInput textInput)
          Called when a text input's password flag has changed.
 Vote previewInsertText(TextInput textInput, CharSequence text, int index)
          Called to preview a text insertion.
 Vote previewRemoveText(TextInput textInput, int index, int count)
          Called to preview a text removal.
 void promptChanged(TextInput textInput, String previousPrompt)
          Called when a text input's prompt has changed.
 void removeTextVetoed(TextInput textInput, Vote reason)
          Called when a text removal has been vetoed.
 void selectionChanged(TextInput textInput, int previousSelectionStart, int previousSelectionLength)
          Called when a text input's selection state has changed.
 void setBackgroundColor(Color backgroundColor)
           
 void setBackgroundColor(int color)
           
 void setBackgroundColor(String backgroundColor)
           
 void setBorderColor(Color borderColor)
           
 void setBorderColor(int color)
           
 void setBorderColor(String borderColor)
           
 void setColor(Color color)
           
 void setColor(int color)
           
 void setColor(String color)
           
 void setDisabledBackgroundColor(Color disabledBackgroundColor)
           
 void setDisabledBackgroundColor(int color)
           
 void setDisabledBackgroundColor(String disabledBackgroundColor)
           
 void setDisabledBorderColor(Color disabledBorderColor)
           
 void setDisabledBorderColor(int color)
           
 void setDisabledBorderColor(String disabledBorderColor)
           
 void setDisabledColor(Color disabledColor)
           
 void setDisabledColor(int disabledColor)
           
 void setDisabledColor(String disabledColor)
           
 void setFont(Dictionary<String,?> font)
           
 void setFont(Font font)
           
 void setFont(String font)
           
 void setHorizontalAlignment(HorizontalAlignment alignment)
           
 void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor)
           
 void setInactiveSelectionBackgroundColor(int color)
           
 void setInactiveSelectionBackgroundColor(String inactiveSelectionBackgroundColor)
           
 void setInactiveSelectionColor(Color inactiveSelectionColor)
           
 void setInactiveSelectionColor(int color)
           
 void setInactiveSelectionColor(String inactiveSelectionColor)
           
 void setInvalidBackgroundColor(Color color)
           
 void setInvalidBackgroundColor(int color)
           
 void setInvalidBackgroundColor(String color)
           
 void setInvalidColor(Color color)
           
 void setInvalidColor(int color)
           
 void setInvalidColor(String color)
           
 void setPadding(Dictionary<String,?> padding)
           
 void setPadding(Insets padding)
           
 void setPadding(int padding)
           
 void setPadding(Number padding)
           
 void setPadding(String padding)
           
 void setPromptColor(Color promptColor)
           
 void setPromptColor(int promptColor)
           
 void setPromptColor(String promptColor)
           
 void setSelectionBackgroundColor(Color selectionBackgroundColor)
           
 void setSelectionBackgroundColor(int color)
           
 void setSelectionBackgroundColor(String selectionBackgroundColor)
           
 void setSelectionColor(Color selectionColor)
           
 void setSelectionColor(int color)
           
 void setSelectionColor(String selectionColor)
           
 void setSize(int width, int height)
          Sets the visual's render size.
 void showCaret(boolean show)
           
 void strictValidationChanged(TextInput textInput)
          Called when a text input's strict validation flag has changed.
 void textChanged(TextInput textInput)
          Called when a text input's text has changed.
 void textInserted(TextInput textInput, int index, int count)
          Called when text has been inserted into a text input.
 void textRemoved(TextInput textInput, int index, int count)
          Called when text has been removed from a text input.
 void textSizeChanged(TextInput textInput, int previousTextSize)
          Called when a text input's text size has changed.
 void textValidatorChanged(TextInput textInput, Validator previousValidator)
          Called when the validator changes.
 void textValidChanged(TextInput textInput)
          Called when the text changes validity.
 
Methods inherited from class org.apache.pivot.wtk.skin.ComponentSkin
cursorChanged, decodeFont, dragSourceChanged, dropTargetChanged, getBaseline, getComponent, getHeight, getWidth, heightLimitsChanged, invalidateComponent, isFocusable, isOpaque, keyReleased, locationChanged, menuHandlerChanged, mouseOut, mouseOver, mouseWheel, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, sizeChanged, tooltipDelayChanged, tooltipTextChanged, tooltipTriggered, visibleChanged, widthLimitsChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerraTextInputSkin

public TerraTextInputSkin()
Method Detail

install

public void install(Component component)
Description copied from interface: Skin
Associates a skin with a component.

Specified by:
install in interface Skin
Overrides:
install in class ComponentSkin
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 interface ConstrainedVisual
Parameters:
height - The height by which to constrain the preferred width, or -1 for no 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 interface ConstrainedVisual
Parameters:
width - The width by which to constrain the preferred height, or -1 for no constraint.

getPreferredSize

public Dimensions getPreferredSize()
Description copied from interface: ConstrainedVisual
Returns the visual's unconstrained preferred size.

Specified by:
getPreferredSize in interface ConstrainedVisual
Overrides:
getPreferredSize in class ComponentSkin

getBaseline

public int getBaseline(int width,
                       int height)
Description copied from interface: ConstrainedVisual
Returns the baseline for a given width and height.

Specified by:
getBaseline in interface ConstrainedVisual
Overrides:
getBaseline in class ComponentSkin
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.

Specified by:
layout in interface Skin

paint

public void paint(Graphics2D graphics)
Description copied from interface: Visual
Paints the visual.

Specified by:
paint in interface Visual
Parameters:
graphics - The graphics context in which to paint the visual.

getInsertionPoint

public int getInsertionPoint(int x)
Description copied from interface: TextInput.Skin
Returns the insertion point for a given location.

Specified by:
getInsertionPoint in interface TextInput.Skin

getCharacterBounds

public Bounds getCharacterBounds(int index)
Description copied from interface: TextInput.Skin
Returns the bounds of the character at a given index.

Specified by:
getCharacterBounds in interface TextInput.Skin

getFont

public Font getFont()

setFont

public void setFont(Font font)

setFont

public final void setFont(String font)

setFont

public final void setFont(Dictionary<String,?> font)

getColor

public Color getColor()

setColor

public void setColor(Color color)

setColor

public final void setColor(String color)

setColor

public final void setColor(int color)

getPromptColor

public Color getPromptColor()

setPromptColor

public void setPromptColor(Color promptColor)

setPromptColor

public final void setPromptColor(String promptColor)

setPromptColor

public final void setPromptColor(int promptColor)

getDisabledColor

public Color getDisabledColor()

setDisabledColor

public void setDisabledColor(Color disabledColor)

setDisabledColor

public final void setDisabledColor(String disabledColor)

setDisabledColor

public final void setDisabledColor(int disabledColor)

getBackgroundColor

public Color getBackgroundColor()

setBackgroundColor

public void setBackgroundColor(Color backgroundColor)

setBackgroundColor

public final void setBackgroundColor(String backgroundColor)

setBackgroundColor

public final void setBackgroundColor(int color)

getInvalidColor

public Color getInvalidColor()

setInvalidColor

public void setInvalidColor(Color color)

setInvalidColor

public final void setInvalidColor(String color)

setInvalidColor

public final void setInvalidColor(int color)

getInvalidBackgroundColor

public Color getInvalidBackgroundColor()

setInvalidBackgroundColor

public void setInvalidBackgroundColor(Color color)

setInvalidBackgroundColor

public final void setInvalidBackgroundColor(String color)

setInvalidBackgroundColor

public final void setInvalidBackgroundColor(int color)

getDisabledBackgroundColor

public Color getDisabledBackgroundColor()

setDisabledBackgroundColor

public void setDisabledBackgroundColor(Color disabledBackgroundColor)

setDisabledBackgroundColor

public final void setDisabledBackgroundColor(String disabledBackgroundColor)

setDisabledBackgroundColor

public final void setDisabledBackgroundColor(int color)

getBorderColor

public Color getBorderColor()

setBorderColor

public void setBorderColor(Color borderColor)

setBorderColor

public final void setBorderColor(String borderColor)

setBorderColor

public final void setBorderColor(int color)

getDisabledBorderColor

public Color getDisabledBorderColor()

setDisabledBorderColor

public void setDisabledBorderColor(Color disabledBorderColor)

setDisabledBorderColor

public final void setDisabledBorderColor(String disabledBorderColor)

setDisabledBorderColor

public final void setDisabledBorderColor(int color)

getSelectionColor

public Color getSelectionColor()

setSelectionColor

public void setSelectionColor(Color selectionColor)

setSelectionColor

public final void setSelectionColor(String selectionColor)

setSelectionColor

public final void setSelectionColor(int color)

getSelectionBackgroundColor

public Color getSelectionBackgroundColor()

setSelectionBackgroundColor

public void setSelectionBackgroundColor(Color selectionBackgroundColor)

setSelectionBackgroundColor

public final void setSelectionBackgroundColor(String selectionBackgroundColor)

setSelectionBackgroundColor

public final void setSelectionBackgroundColor(int color)

getInactiveSelectionColor

public Color getInactiveSelectionColor()

setInactiveSelectionColor

public void setInactiveSelectionColor(Color inactiveSelectionColor)

setInactiveSelectionColor

public final void setInactiveSelectionColor(String inactiveSelectionColor)

setInactiveSelectionColor

public final void setInactiveSelectionColor(int color)

getInactiveSelectionBackgroundColor

public Color getInactiveSelectionBackgroundColor()

setInactiveSelectionBackgroundColor

public void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor)

setInactiveSelectionBackgroundColor

public final void setInactiveSelectionBackgroundColor(String inactiveSelectionBackgroundColor)

setInactiveSelectionBackgroundColor

public final void setInactiveSelectionBackgroundColor(int color)

getPadding

public Insets getPadding()

setPadding

public void setPadding(Insets padding)

setPadding

public final void setPadding(Dictionary<String,?> padding)

setPadding

public final void setPadding(int padding)

setPadding

public final void setPadding(Number padding)

setPadding

public final void setPadding(String padding)

getHorizontalAlignment

public HorizontalAlignment getHorizontalAlignment()

setHorizontalAlignment

public final void setHorizontalAlignment(HorizontalAlignment alignment)

mouseMove

public boolean mouseMove(Component component,
                         int x,
                         int y)
Description copied from interface: ComponentMouseListener
Called when the mouse is moved over a component.

Specified by:
mouseMove in interface ComponentMouseListener
Overrides:
mouseMove in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

mouseDown

public boolean mouseDown(Component component,
                         Mouse.Button button,
                         int x,
                         int y)
Description copied from interface: ComponentMouseButtonListener
Called when a mouse button is pressed over a component.

Specified by:
mouseDown in interface ComponentMouseButtonListener
Overrides:
mouseDown in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

mouseUp

public boolean mouseUp(Component component,
                       Mouse.Button button,
                       int x,
                       int y)
Description copied from interface: ComponentMouseButtonListener
Called when a mouse button is released over a component.

Specified by:
mouseUp in interface ComponentMouseButtonListener
Overrides:
mouseUp in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

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 interface ComponentMouseButtonListener
Overrides:
mouseClick in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

keyTyped

public boolean keyTyped(Component component,
                        char character)
Description copied from interface: ComponentKeyListener
Called when a key has been typed.

Specified by:
keyTyped in interface ComponentKeyListener
Overrides:
keyTyped in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.

keyPressed

public boolean keyPressed(Component component,
                          int keyCode,
                          Keyboard.KeyLocation keyLocation)
DELETE Delete the character after the caret or the entire selection if there is one.
BACKSPACE Delete the character before the caret or the entire selection if there is one.

HOME Move the caret to the beginning of the text.
LEFT + META Move the caret to the beginning of the text.

HOME + SHIFT Select from the caret to the beginning of the text.
LEFT + META + SHIFT Select from the caret to the beginning of the text.

END Move the caret to the end of the text.
RIGHT + META Move the caret to the end of the text.

END + SHIFT Select from the caret to the end of the text.
RIGHT + META + SHIFT Select from the caret to the end of the text.

LEFT Clear the selection and move the caret back by one character.
LEFT + SHIFT Add the previous character to the selection.
LEFT + CTRL Clear the selection and move the caret to the beginning of the text.
LEFT + CTRL + SHIFT Add all preceding text to the selection.

RIGHT Clear the selection and move the caret forward by one character.
RIGHT + SHIFT Add the next character to the selection.
RIGHT + CTRL Clear the selection and move the caret to the end of the text.
RIGHT + CTRL + SHIFT Add all subsequent text to the selection.

CommandModifier + A Select all.
CommandModifier + X Cut selection to clipboard (if not a password TextInput).
CommandModifier + C Copy selection to clipboard (if not a password TextInput).
CommandModifier + V Paste from clipboard.
CommandModifier + Z Undo.

Specified by:
keyPressed in interface ComponentKeyListener
Overrides:
keyPressed in class ComponentSkin
Returns:
true to consume the event; false to allow it to propagate.
See Also:
Platform.getCommandModifier()

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 the Component.isEnabled() method.

Specified by:
enabledChanged in interface ComponentStateListener
Overrides:
enabledChanged in class ComponentSkin
Parameters:
component - The component whose enabled state is changing.

focusedChanged

public void focusedChanged(Component component,
                           Component obverseComponent)
Description copied from interface: ComponentStateListener
Called when a component's focused state has changed.

This will be called both when a component gains focus and when it loses focus. The currently focused component has already been set when this method is called, so that the new state of the component can be determined by calling the Component.isFocused() method.

Specified by:
focusedChanged in interface ComponentStateListener
Overrides:
focusedChanged in class ComponentSkin
Parameters:
component - The component that is either gaining focus or the one that previously had focus and is now losing it.
obverseComponent - If the component is gaining focus, this is the component that is losing focus. If the component is losing focus this is the component that is gaining the focus instead.

textSizeChanged

public void textSizeChanged(TextInput textInput,
                            int previousTextSize)
Description copied from interface: TextInputListener
Called when a text input's text size has changed.

Specified by:
textSizeChanged in interface TextInputListener

maximumLengthChanged

public void maximumLengthChanged(TextInput textInput,
                                 int previousMaximumLength)
Description copied from interface: TextInputListener
Called when a text input's maximum length has changed.

Specified by:
maximumLengthChanged in interface TextInputListener

passwordChanged

public void passwordChanged(TextInput textInput)
Description copied from interface: TextInputListener
Called when a text input's password flag has changed.

Specified by:
passwordChanged in interface TextInputListener

promptChanged

public void promptChanged(TextInput textInput,
                          String previousPrompt)
Description copied from interface: TextInputListener
Called when a text input's prompt has changed.

Specified by:
promptChanged in interface TextInputListener

textValidatorChanged

public void textValidatorChanged(TextInput textInput,
                                 Validator previousValidator)
Description copied from interface: TextInputListener
Called when the validator changes.

Specified by:
textValidatorChanged in interface TextInputListener

strictValidationChanged

public void strictValidationChanged(TextInput textInput)
Description copied from interface: TextInputListener
Called when a text input's strict validation flag has changed.

Specified by:
strictValidationChanged in interface TextInputListener

textValidChanged

public void textValidChanged(TextInput textInput)
Description copied from interface: TextInputListener
Called when the text changes validity.

Specified by:
textValidChanged in interface TextInputListener

previewInsertText

public Vote previewInsertText(TextInput textInput,
                              CharSequence text,
                              int index)
Description copied from interface: TextInputContentListener
Called to preview a text insertion.

Specified by:
previewInsertText in interface TextInputContentListener
Parameters:
textInput - The source of the event.
text - The text that will be inserted.
index - The index at which the text will be inserted.

insertTextVetoed

public void insertTextVetoed(TextInput textInput,
                             Vote reason)
Description copied from interface: TextInputContentListener
Called when a text insertion has been vetoed.

Specified by:
insertTextVetoed in interface TextInputContentListener
Parameters:
textInput - The source of the event.
reason - The reason the event was vetoed.

textInserted

public void textInserted(TextInput textInput,
                         int index,
                         int count)
Description copied from interface: TextInputContentListener
Called when text has been inserted into a text input.

Specified by:
textInserted in interface TextInputContentListener
Parameters:
textInput - The source of the event.
index - The index at which the text was inserted.
count - The number of characters that were inserted.

previewRemoveText

public Vote previewRemoveText(TextInput textInput,
                              int index,
                              int count)
Description copied from interface: TextInputContentListener
Called to preview a text removal.

Specified by:
previewRemoveText in interface TextInputContentListener
Parameters:
textInput - The source of the event.
index - The starting index from which the text will be removed.

setSize

public void setSize(int width,
                    int height)
Description copied from interface: ConstrainedVisual
Sets the visual's render size.

Specified by:
setSize in interface ConstrainedVisual
Overrides:
setSize in class ComponentSkin

removeTextVetoed

public void removeTextVetoed(TextInput textInput,
                             Vote reason)
Description copied from interface: TextInputContentListener
Called when a text removal has been vetoed.

Specified by:
removeTextVetoed in interface TextInputContentListener
Parameters:
textInput - The source of the event.
reason - The reason the event was vetoed.

textRemoved

public void textRemoved(TextInput textInput,
                        int index,
                        int count)
Description copied from interface: TextInputContentListener
Called when text has been removed from a text input.

Specified by:
textRemoved in interface TextInputContentListener
Parameters:
textInput - The source of the event.
index - The index from which the text was removed.
count - The number of characters that were removed.

textChanged

public void textChanged(TextInput textInput)
Description copied from interface: TextInputContentListener
Called when a text input's text has changed.

Specified by:
textChanged in interface TextInputContentListener
Parameters:
textInput - The source of the event.

editableChanged

public void editableChanged(TextInput textInput)
Description copied from interface: TextInputListener
Called when the editable state has changed.

Specified by:
editableChanged in interface TextInputListener

selectionChanged

public void selectionChanged(TextInput textInput,
                             int previousSelectionStart,
                             int previousSelectionLength)
Description copied from interface: TextInputSelectionListener
Called when a text input's selection state has changed.

Specified by:
selectionChanged in interface TextInputSelectionListener
Parameters:
textInput - The source of the event.
previousSelectionStart - If the selection changed directly, the previous selection start index. Otherwise, the current selection start index.
previousSelectionLength - If the selection changed directly, the previous selection length. Otherwise, the current selection length.

showCaret

public void showCaret(boolean show)