pivot.wtk.skin
Class TextAreaSkin

java.lang.Object
  extended by pivot.wtk.skin.ComponentSkin
      extended by pivot.wtk.skin.TextAreaSkin
All Implemented Interfaces:
ComponentKeyListener, ComponentLayoutListener, ComponentListener, ComponentMouseButtonListener, ComponentMouseListener, ComponentMouseWheelListener, ComponentStateListener, ConstrainedVisual, Skin, TextArea.Skin, TextAreaListener, TextAreaSelectionListener, Visual

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

Text area skin.

Author:
gbrown

Nested Class Summary
 class TextAreaSkin.DocumentView
          Document view.
 class TextAreaSkin.ElementView
          Abstract base class for element views.
 class TextAreaSkin.ImageNodeView
           
 class TextAreaSkin.NodeView
          Abstract base class for node views.
 class TextAreaSkin.ParagraphView
           
 class TextAreaSkin.TextNodeView
          Text node view.
 
Field Summary
static int PARAGRAPH_TERMINATOR_WIDTH
           
 
Fields inherited from class pivot.wtk.skin.ComponentSkin
SHOW_TOOLTIP_TIMEOUT
 
Constructor Summary
TextAreaSkin()
           
 
Method Summary
 void documentChanged(TextArea textArea, Document previousDocument)
          Called when a text area's document has changed.
 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, boolean temporary)
          Called when a component's focused state has changed.
 int getCharacterAt(int x, int y)
          Returns the offset of the character at a given location.
 Bounds getCharacterBounds(int offset)
          Returns the bounds of the character at a given offset within the document.
 java.awt.Font getFont()
           
 Insets getMargin()
           
 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.
 void install(Component component)
          Associates a skin with a component.
 boolean isBreakOnWhitespaceOnly()
           
 boolean isFocusable()
          By default, components are focusable.
 boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation)
          Called when a key has been pressed.
 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 locationChanged(Component component, int previousX, int previousY)
          Called when a component's location has changed.
 boolean mouseDown(Component component, Mouse.Button button, int x, int y)
          Called when a mouse button is pressed over a component.
 void paint(java.awt.Graphics2D graphics)
          Paints the visual.
 void selectionChanged(TextArea textArea, int previousSelectionStart, int previousSelectionLength)
          Called when a text area's selection state has changed.
 void setBreakOnWhitespaceOnly(boolean breakOnWhitespaceOnly)
           
 void setFont(java.awt.Font font)
           
 void setFont(java.lang.String font)
           
 void setMargin(Dictionary<java.lang.String,?> margin)
           
 void setMargin(Insets margin)
           
 void setMargin(int margin)
           
 void setMargin(java.lang.Number margin)
           
 void textKeyChanged(TextArea textArea, java.lang.String previousTextKey)
          Called when a text area's text key has changed.
 void uninstall()
          Dissociates a skin from a component.
 
Methods inherited from class pivot.wtk.skin.ComponentSkin
cursorChanged, decodeColor, displayableChanged, getComponent, getHeight, getWidth, invalidateComponent, keyReleased, mouseClick, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, parentChanged, preferredSizeChanged, repaintComponent, repaintComponent, repaintComponent, setSize, sizeChanged, styleUpdated, tooltipTextChanged, visibleChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAGRAPH_TERMINATOR_WIDTH

public static final int PARAGRAPH_TERMINATOR_WIDTH
See Also:
Constant Field Values
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.

uninstall

public void uninstall()
Description copied from interface: Skin
Dissociates a skin from a component.

Specified by:
uninstall in interface Skin
Overrides:
uninstall in class ComponentSkin

isFocusable

public boolean isFocusable()
Description copied from class: ComponentSkin
By default, components are focusable.

Specified by:
isFocusable in interface Skin
Overrides:
isFocusable in class ComponentSkin
Returns:
true if this skin is focusable; false, otherwise.

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

paint

public void paint(java.awt.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.

getCharacterAt

public int getCharacterAt(int x,
                          int y)
Description copied from interface: TextArea.Skin
Returns the offset of the character at a given location.

Specified by:
getCharacterAt in interface TextArea.Skin
Returns:
The character offset at the given location.

getCharacterBounds

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

Specified by:
getCharacterBounds in interface TextArea.Skin
Returns:
The bounds of the character at the given offset.

getFont

public java.awt.Font getFont()

setFont

public void setFont(java.awt.Font font)

setFont

public final void setFont(java.lang.String font)

getMargin

public Insets getMargin()

setMargin

public void setMargin(Insets margin)

setMargin

public final void setMargin(Dictionary<java.lang.String,?> margin)

setMargin

public final void setMargin(int margin)

setMargin

public final void setMargin(java.lang.Number margin)

isBreakOnWhitespaceOnly

public boolean isBreakOnWhitespaceOnly()

setBreakOnWhitespaceOnly

public void setBreakOnWhitespaceOnly(boolean breakOnWhitespaceOnly)

locationChanged

public void locationChanged(Component component,
                            int previousX,
                            int previousY)
Description copied from interface: ComponentListener
Called when a component's location has changed.

Specified by:
locationChanged in interface ComponentListener
Overrides:
locationChanged in class ComponentSkin

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.

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 interface: ComponentKeyListener
Called when a key has been pressed.

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.

Specified by:
enabledChanged in interface ComponentStateListener
Overrides:
enabledChanged in class ComponentSkin

focusedChanged

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

Specified by:
focusedChanged in interface ComponentStateListener
Overrides:
focusedChanged in class ComponentSkin

documentChanged

public void documentChanged(TextArea textArea,
                            Document previousDocument)
Description copied from interface: TextAreaListener
Called when a text area's document has changed.

Specified by:
documentChanged 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

textKeyChanged

public void textKeyChanged(TextArea textArea,
                           java.lang.String previousTextKey)
Description copied from interface: TextAreaListener
Called when a text area's text key has changed.

Specified by:
textKeyChanged in interface TextAreaListener

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