com.yospace.yae.yogi
Class YogiTextArea

java.lang.Object
  |
  +--com.yospace.yae.yogi.YogiComponent
        |
        +--com.yospace.yae.yogi.YogiImageComponent
              |
              +--com.yospace.yae.yogi.YogiLabel
                    |
                    +--com.yospace.yae.yogi.YogiTextArea
All Implemented Interfaces:
RendererFactory

public class YogiTextArea
extends YogiLabel

YogiTextAreas are bascially YogiLabels that are rendered onto separate lines in the paint method. Be aware when overriding any methods that line breaks are cached and only updated when the text or the shape of the text area is changed. Methods such as setText are overridden here to make sure that a change in text, size, or font forces a recalculation of the line breaks.


Field Summary
static int BREAKING_STYLE_CHARACTER
          Word breaking constant used for setting the type of word breaking used within the YogiTextArea to allow words to break anywhere, i.e.
static int BREAKING_STYLE_HYPHEN
          Word breaking constant used for setting the type of word breaking used within the YogiTextArea to allow breaking a word across a line with the break being joined with a hyphen.
static int BREAKING_STYLE_WORD
          Word breaking constant used for setting the type of word breaking used within the YogiTextArea to allow breaking only at word boundaries.
static int PROPERTY_AUTO_RESIZE
          Constant for the automatic resize property
static int PROPERTY_BREAKING_STYLE
          Constant for the (word)breaking style property
 
Fields inherited from class com.yospace.yae.yogi.YogiLabel
PROPERTY_TEXT, PROPERTY_TEXT_PLACEMENT
 
Fields inherited from class com.yospace.yae.yogi.YogiImageComponent
PROPERTY_IMAGE
 
Fields inherited from class com.yospace.yae.yogi.YogiComponent
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, BORDER_DOTTED, BORDER_NONE, BORDER_PLAIN, BORDER_ROUNDED, BORDER_SOLID, COLOR_BACKGROUND, COLOR_BORDER, COLOR_FOREGROUND, FOCUS_DEFAULT, FOCUS_OFF, FOCUS_ON, PROPERTY_ALIGN, PROPERTY_BORDER_STYLE, PROPERTY_BOUNDS, PROPERTY_COLOR, PROPERTY_CONTEXT_ENABLED, PROPERTY_ENABLED, PROPERTY_FOCUS, PROPERTY_FOCUS_INDEX, PROPERTY_FOCUS_TRAVERSABLE, PROPERTY_FONT, PROPERTY_HOTKEY, PROPERTY_LOCATION, PROPERTY_OPAQUE, PROPERTY_SIZE, PROPERTY_VISIBLE, PROPERTY_X_INSET, PROPERTY_Y_INSET
 
Constructor Summary
YogiTextArea()
          Default constructor simply calls the superclass constructor.
YogiTextArea(java.lang.String text, Image image)
          Constructs a new text area and sets the text to be the given String and the default image to be the given Image.
 
Method Summary
 int getBreakingStyle()
          This method returns the current breaking style being used for the TextArea.
 java.lang.String getLine(int lineNumber)
          Returns the text that lies on the given line number.
 int getNumberOfLines()
          Returns the number of lines of text that the TextArea currently has.
 boolean isAutoResizable()
          This method allows the TextArea to be queried as to whether it will resize to fit the content.
 void setAutoResizable(boolean resize)
          This method allows the auto resizing of the TextArea to be switched on/off.
 void setBounds(int x, int y, int width, int height)
          Overridden in order to make sure that breaks are recalculated after a change in the bounds of the text area
 void setBreakingStyle(int style)
          This method allows the breaking style for the TextArea to be set programmatically.
 void setFont(Font font)
          Overridden in order to make sure that breaks are recalculated after a change in the font of the text area
 void setSize(int width, int height)
          Overridden in order to make sure that breaks are recalculated after a change in the size of the text area
 void setText(java.lang.String text)
          Sets the text in the text area.
 
Methods inherited from class com.yospace.yae.yogi.YogiLabel
getCellRendererComponent, getText, isTextOnRight, setTextImpl, setTextOnRight
 
Methods inherited from class com.yospace.yae.yogi.YogiImageComponent
getImage, getImageName, setImage, setImage
 
Methods inherited from class com.yospace.yae.yogi.YogiComponent
_debugPrintComponents, add, addPropertyChangeListener, bringForwards, bringInFrontOf, bringToFront, contains, containsComponent, ensureVisible, ensureVisible, findComponentAt, findCurrentFocus, findFirstFocus, findFocusDomainRoot, findFocusDomainRootImpl, findHotkeyComponent, findNextFocus, fireActionPerformedEvent, firePropertyChangeEvent, getAlign, getBorderStyle, getBounds, getColor, getColors, getComponent, getComponent, getComponentCount, getComponentIndex, getComponents, getFocusBounds, getFocusIndex, getFont, getGlobalLocation, getHeight, getHotkey, getId, getParent, getParent, getTreeLock, getUI, getWidth, getX, getXInset, getY, getYInset, hasFocus, isActive, isContextEnabled, isEnabled, isFocusDomainRoot, isFocusTraversable, isOpaque, isVisible, keyPressed, keyReleased, keyRepeated, paint, paintBackground, paintBorder, paintForeground, pointerDragged, pointerPressed, pointerReleased, remove, remove, removeAll, removePropertyChangeListener, repaint, repaint, repaintAfterRebounding, requestFocus, requestFocus, sendBackwards, sendBehind, sendToBack, setActionListener, setActive, setAlign, setBorderStyle, setColor, setColors, setContextEnabled, setDefaultColor, setEnabled, setFocusDomainRoot, setFocusIndex, setFocusTraversable, setHotkey, setId, setLocation, setNoFocus, setOpaque, setProperty, setUI, setVisible, setXInset, setYInset, updateUI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_BREAKING_STYLE

public static final int PROPERTY_BREAKING_STYLE
Constant for the (word)breaking style property

PROPERTY_AUTO_RESIZE

public static final int PROPERTY_AUTO_RESIZE
Constant for the automatic resize property

BREAKING_STYLE_CHARACTER

public static final int BREAKING_STYLE_CHARACTER
Word breaking constant used for setting the type of word breaking used within the YogiTextArea to allow words to break anywhere, i.e. at any character position.
See Also:
setBreakingStyle(int)

BREAKING_STYLE_WORD

public static final int BREAKING_STYLE_WORD
Word breaking constant used for setting the type of word breaking used within the YogiTextArea to allow breaking only at word boundaries.
See Also:
setBreakingStyle(int)

BREAKING_STYLE_HYPHEN

public static final int BREAKING_STYLE_HYPHEN
Word breaking constant used for setting the type of word breaking used within the YogiTextArea to allow breaking a word across a line with the break being joined with a hyphen.
See Also:
setBreakingStyle(int)
Constructor Detail

YogiTextArea

public YogiTextArea()
Default constructor simply calls the superclass constructor. Required by the XML building system.

YogiTextArea

public YogiTextArea(java.lang.String text,
                    Image image)
Constructs a new text area and sets the text to be the given String and the default image to be the given Image.
Parameters:
text - the default text for this text area.
image - the default image for this text area.
Method Detail

setBreakingStyle

public void setBreakingStyle(int style)
This method allows the breaking style for the TextArea to be set programmatically.
Parameters:
style - the style, must be one of BREAKING_STYLE_CHARACTER, BREAKING_STYLE_WORD,BREAKING_STYLE_HYPHEN.

getBreakingStyle

public int getBreakingStyle()
This method returns the current breaking style being used for the TextArea.
Returns:
the current breaking style, must be one of BREAKING_STYLE_CHARACTER, BREAKING_STYLE_WORD,BREAKING_STYLE_HYPHEN.

setAutoResizable

public void setAutoResizable(boolean resize)
This method allows the auto resizing of the TextArea to be switched on/off.
Parameters:
resize - true allows automatic resizing to fit the current content, false will lead to truncation if the content is too large for the TextArea.

isAutoResizable

public boolean isAutoResizable()
This method allows the TextArea to be queried as to whether it will resize to fit the content.
Returns:
true if the TextArea will resize automatically, false otherwise.

setText

public void setText(java.lang.String text)
Sets the text in the text area.
Overrides:
setText in class YogiLabel
Parameters:
text - the text to fill the text area with.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overridden in order to make sure that breaks are recalculated after a change in the bounds of the text area
Overrides:
setBounds in class YogiComponent
Parameters:
x - the desired x value.
y - the desired y value.
width - the desired width, or -1 to restore to UI defaults.
height - the desired height, or -1 to restore to UI defaults.

setSize

public void setSize(int width,
                    int height)
Overridden in order to make sure that breaks are recalculated after a change in the size of the text area
Overrides:
setSize in class YogiComponent
Parameters:
width - the new width in pixels, or -1 to restore to UI defaults.
height - the new height in pixels, or -1 to restore to UI defaults.

setFont

public void setFont(Font font)
Overridden in order to make sure that breaks are recalculated after a change in the font of the text area
Overrides:
setFont in class YogiComponent
Parameters:
font - the new font to be used, or null to restore to the UI delegate's default font.

getNumberOfLines

public int getNumberOfLines()
Returns the number of lines of text that the TextArea currently has.
Returns:
the current number of lines.

getLine

public java.lang.String getLine(int lineNumber)
Returns the text that lies on the given line number.
Parameters:
lineNumber - the line number that is requested.
Returns:
the text that lies on the requested line.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.