org.apache.pivot.wtk.skin
Class TextAreaSkin

java.lang.Object
  extended by org.apache.pivot.wtk.skin.ComponentSkin
      extended by org.apache.pivot.wtk.skin.TextAreaSkin
All Implemented Interfaces:
ComponentKeyListener, ComponentListener, ComponentMouseButtonListener, ComponentMouseListener, ComponentMouseWheelListener, ComponentStateListener, ComponentTooltipListener, ConstrainedVisual, Skin, TextArea.Skin, TextAreaContentListener, TextAreaListener, TextAreaSelectionListener, Visual
Direct Known Subclasses:
TerraTextAreaSkin

public class TextAreaSkin
extends ComponentSkin
implements TextArea.Skin, TextAreaListener, TextAreaContentListener, TextAreaSelectionListener

Text area skin.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.TextAreaListener
TextAreaListener.Adapter
 
Nested classes/interfaces inherited from interface org.apache.pivot.wtk.TextAreaContentListener
TextAreaContentListener.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
TextAreaSkin()
           
 
Method Summary
 void editableChanged(TextArea textArea)
          Called when a text area's 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.
 boolean getAcceptsEnter()
           
 boolean getAcceptsTab()
          Gets current value of style that determines the behavior of TAB and Ctrl-TAB characters.
 Color getBackgroundColor()
           
 int getBaseline(int width, int height)
          Returns the baseline for a given width and height.
 Bounds getCharacterBounds(int index)
          Returns the bounds of the character at a given index.
 Color getColor()
          Returns the foreground color of the text
 Font getFont()
          Returns the font of the text
 Color getInactiveColor()
           
 Color getInactiveSelectionBackgroundColor()
           
 Color getInactiveSelectionColor()
           
 int getInsertionPoint(int x, int y)
          Returns the insertion point for a given location.
 int getLineWidth()
           
 Insets getMargin()
          Returns the amount of space between the edge of the TextArea and its text
 int getNextInsertionPoint(int x, int from, TextArea.ScrollDirection direction)
          Returns the next insertion point given an x coordinate and a character index.
 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.
 int getRowAt(int index)
          Returns the row index of the character at a given index.
 int getRowCount()
          Returns the total number of rows in the text area.
 int getRowLength(int index)
          Returns the number of characters in the row containing a given character index.
 int getRowOffset(int index)
          Returns the index of the first character in the row containing a given character index.
 Area getSelection()
           
 Color getSelectionBackgroundColor()
           
 Color getSelectionColor()
           
 int getTabWidth()
          Returns the current setting of the "tabWidth" style (so "setText" uses the same value as Ctrl-Tab from user).
 boolean getWrapText()
           
 void install(Component component)
          Associates a skin with a component.
 boolean isOpaque()
          By default, skins are assumed to be opaque.
 boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation)
          TAB Transfers focus forwards
TAB + SHIFT Transfers focus backwards
 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(TextArea textArea, int previousMaximumLength)
          Called when a text area'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 paragraphInserted(TextArea textArea, int index)
          Called when a paragraph has been inserted into a text area's paragraph sequence.
 void paragraphsRemoved(TextArea textArea, int index, Sequence<TextArea.Paragraph> removed)
          Called when paragraphs have been removed from a text area's paragraph sequence.
 void selectionChanged(TextArea textArea, int previousSelectionStart, int previousSelectionLength)
          Called when a text area's selection state has changed.
 void setAcceptsEnter(boolean acceptsEnter)
           
 void setAcceptsTab(boolean acceptsTab)
          Sets current value of style that determines the behavior of TAB and Ctrl-TAB characters.
 void setBackgroundColor(Color backgroundColor)
           
 void setBackgroundColor(String backgroundColor)
           
 void setColor(Color color)
          Sets the foreground color of the text
 void setColor(String color)
          Sets the foreground color of the text
 void setFont(Dictionary<String,?> font)
          Sets the font of the text
 void setFont(Font font)
          Sets the font of the text
 void setFont(String font)
          Sets the font of the text
 void setInactiveColor(Color inactiveColor)
           
 void setInactiveColor(String inactiveColor)
           
 void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor)
           
 void setInactiveSelectionBackgroundColor(String inactiveSelectionBackgroundColor)
           
 void setInactiveSelectionColor(Color inactiveSelectionColor)
           
 void setInactiveSelectionColor(String inactiveSelectionColor)
           
 void setLineWidth(int lineWidth)
           
 void setMargin(Dictionary<String,?> margin)
          Sets the amount of space between the edge of the TextArea and its text
 void setMargin(Insets margin)
          Sets the amount of space between the edge of the TextArea and its text
 void setMargin(int margin)
          Sets the amount of space between the edge of the TextArea and its text
 void setMargin(Number margin)
          Sets the amount of space between the edge of the TextArea and its text
 void setMargin(String margin)
          Sets the amount of space between the edge of the TextArea and its text
 void setSelectionBackgroundColor(Color selectionBackgroundColor)
           
 void setSelectionBackgroundColor(String selectionBackgroundColor)
           
 void setSelectionColor(Color selectionColor)
           
 void setSelectionColor(String selectionColor)
           
 void setTabWidth(int tabWidth)
           
 void setWrapText(boolean wrapText)
           
 void textChanged(TextArea textArea)
          Called when a text area's text has changed.
 
Methods inherited from class org.apache.pivot.wtk.skin.ComponentSkin
cursorChanged, decodeFont, dragSourceChanged, dropTargetChanged, getBaseline, getComponent, getHeight, getWidth, heightLimitsChanged, invalidateComponent, isFocusable, keyReleased, locationChanged, menuHandlerChanged, mouseOut, mouseOver, mouseWheel, nameChanged, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, repaintComponent, repaintComponent, setSize, 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

TextAreaSkin

public TextAreaSkin()
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

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

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.

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.

isOpaque

public boolean isOpaque()
Description copied from class: ComponentSkin
By default, skins are assumed to be opaque.

Specified by:
isOpaque in interface Skin
Overrides:
isOpaque in class ComponentSkin
Returns:
true if this skin is opaque; false if any part of it is transparent or translucent.

getInsertionPoint

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

Specified by:
getInsertionPoint in interface TextArea.Skin

getNextInsertionPoint

public int getNextInsertionPoint(int x,
                                 int from,
                                 TextArea.ScrollDirection direction)
Description copied from interface: TextArea.Skin
Returns the next insertion point given an x coordinate and a character index.

Specified by:
getNextInsertionPoint in interface TextArea.Skin

getRowAt

public int getRowAt(int index)
Description copied from interface: TextArea.Skin
Returns the row index of the character at a given index.

Specified by:
getRowAt in interface TextArea.Skin

getRowOffset

public int getRowOffset(int index)
Description copied from interface: TextArea.Skin
Returns the index of the first character in the row containing a given character index.

Specified by:
getRowOffset in interface TextArea.Skin

getRowLength

public int getRowLength(int index)
Description copied from interface: TextArea.Skin
Returns the number of characters in the row containing a given character index.

Specified by:
getRowLength in interface TextArea.Skin

getRowCount

public int getRowCount()
Description copied from interface: TextArea.Skin
Returns the total number of rows in the text area.

Specified by:
getRowCount in interface TextArea.Skin

getCharacterBounds

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

Specified by:
getCharacterBounds in interface TextArea.Skin

getSelection

public Area getSelection()

getFont

public Font getFont()
Returns the font of the text


setFont

public void setFont(Font font)
Sets the font of the text


setFont

public final void setFont(String font)
Sets the font of the text

Parameters:
font - A font specification

setFont

public final void setFont(Dictionary<String,?> font)
Sets the font of the text

Parameters:
font - A dictionary describing a font

getColor

public Color getColor()
Returns the foreground color of the text


setColor

public void setColor(Color color)
Sets the foreground color of the text


setColor

public final void setColor(String color)
Sets the foreground color of the text

Parameters:
color - Any of the color values recognized by Pivot.

getBackgroundColor

public Color getBackgroundColor()

setBackgroundColor

public void setBackgroundColor(Color backgroundColor)

setBackgroundColor

public final void setBackgroundColor(String backgroundColor)

getInactiveColor

public Color getInactiveColor()

setInactiveColor

public void setInactiveColor(Color inactiveColor)

setInactiveColor

public final void setInactiveColor(String inactiveColor)

getSelectionColor

public Color getSelectionColor()

setSelectionColor

public void setSelectionColor(Color selectionColor)

setSelectionColor

public final void setSelectionColor(String selectionColor)

getSelectionBackgroundColor

public Color getSelectionBackgroundColor()

setSelectionBackgroundColor

public void setSelectionBackgroundColor(Color selectionBackgroundColor)

setSelectionBackgroundColor

public final void setSelectionBackgroundColor(String selectionBackgroundColor)

getInactiveSelectionColor

public Color getInactiveSelectionColor()

setInactiveSelectionColor

public void setInactiveSelectionColor(Color inactiveSelectionColor)

setInactiveSelectionColor

public final void setInactiveSelectionColor(String inactiveSelectionColor)

getInactiveSelectionBackgroundColor

public Color getInactiveSelectionBackgroundColor()

setInactiveSelectionBackgroundColor

public void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor)

setInactiveSelectionBackgroundColor

public final void setInactiveSelectionBackgroundColor(String inactiveSelectionBackgroundColor)

getMargin

public Insets getMargin()
Returns the amount of space between the edge of the TextArea and its text


setMargin

public void setMargin(Insets margin)
Sets the amount of space between the edge of the TextArea and its text


setMargin

public final void setMargin(Dictionary<String,?> margin)
Sets the amount of space between the edge of the TextArea and its text

Parameters:
margin - A dictionary with keys in the set {left, top, bottom, right}.

setMargin

public final void setMargin(int margin)
Sets the amount of space between the edge of the TextArea and its text


setMargin

public final void setMargin(Number margin)
Sets the amount of space between the edge of the TextArea and its text


setMargin

public final void setMargin(String margin)
Sets the amount of space between the edge of the TextArea and its text

Parameters:
margin - A string containing an integer or a JSON dictionary with keys left, top, bottom, and/or right.

getWrapText

public boolean getWrapText()

setWrapText

public void setWrapText(boolean wrapText)

getAcceptsEnter

public boolean getAcceptsEnter()

setAcceptsEnter

public void setAcceptsEnter(boolean acceptsEnter)

getAcceptsTab

public boolean getAcceptsTab()
Gets current value of style that determines the behavior of TAB and Ctrl-TAB characters.

Returns:
true if TAB inserts an appropriate number of spaces, while Ctrl-TAB shifts focus to next component. false (default) means TAB shifts focus and Ctrl-TAB inserts spaces.

setAcceptsTab

public void setAcceptsTab(boolean acceptsTab)
Sets current value of style that determines the behavior of TAB and Ctrl-TAB characters.

Parameters:
acceptsTab - true if TAB inserts an appropriate number of spaces, while Ctrl-TAB shifts focus to next component. false (default) means TAB shifts focus and Ctrl-TAB inserts spaces.

getTabWidth

public int getTabWidth()
Description copied from interface: TextArea.Skin
Returns the current setting of the "tabWidth" style (so "setText" uses the same value as Ctrl-Tab from user).

Specified by:
getTabWidth in interface TextArea.Skin

setTabWidth

public void setTabWidth(int tabWidth)

getLineWidth

public int getLineWidth()

setLineWidth

public void setLineWidth(int lineWidth)

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)
Description copied from class: ComponentSkin
TAB Transfers focus forwards
TAB + SHIFT Transfers focus backwards

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

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.

maximumLengthChanged

public void maximumLengthChanged(TextArea textArea,
                                 int previousMaximumLength)
Description copied from interface: TextAreaListener
Called when a text area's maximum length has changed.

Specified by:
maximumLengthChanged in interface TextAreaListener

editableChanged

public void editableChanged(TextArea textArea)
Description copied from interface: TextAreaListener
Called when a text area's editable state has changed.

Specified by:
editableChanged in interface TextAreaListener

paragraphInserted

public void paragraphInserted(TextArea textArea,
                              int index)
Description copied from interface: TextAreaContentListener
Called when a paragraph has been inserted into a text area's paragraph sequence.

Specified by:
paragraphInserted in interface TextAreaContentListener
Parameters:
textArea - The source of the event.
index - The index at which the paragraph was inserted.

paragraphsRemoved

public void paragraphsRemoved(TextArea textArea,
                              int index,
                              Sequence<TextArea.Paragraph> removed)
Description copied from interface: TextAreaContentListener
Called when paragraphs have been removed from a text area's paragraph sequence.

Specified by:
paragraphsRemoved in interface TextAreaContentListener
Parameters:
textArea - The source of the event.
index - The starting index from which the paragraphs were removed.
removed - The paragraphs that were removed.

textChanged

public void textChanged(TextArea textArea)
Description copied from interface: TextAreaContentListener
Called when a text area's text has changed.

Specified by:
textChanged in interface TextAreaContentListener
Parameters:
textArea - The source of the event.

selectionChanged

public void selectionChanged(TextArea textArea,
                             int previousSelectionStart,
                             int previousSelectionLength)
Description copied from interface: TextAreaSelectionListener
Called when a text area's selection state has changed.

Specified by:
selectionChanged in interface TextAreaSelectionListener