com.jmex.bui
Class BTextArea

java.lang.Object
  extended by com.jmex.bui.BComponent
      extended by com.jmex.bui.BContainer
          extended by com.jmex.bui.BTextArea

public class BTextArea
extends BContainer

Displays one or more lines of text which may contain basic formatting (changing of color, toggling bold, italic and underline). Newline characters in the appended text will result in line breaks in the on-screen layout.


Nested Class Summary
protected static class BTextArea.Line
          Contains the segments of text on a single line.
protected static class BTextArea.Run
          Used to associate a style with a run of text.
 
Nested classes/interfaces inherited from class com.jmex.bui.BContainer
BContainer.ChildOp
 
Field Summary
protected  ColorRGBA[] _effcols
           
protected  int[] _effsizes
           
protected  int[] _haligns
           
protected  ArrayList<BTextArea.Line> _lines
           
protected  BoundedRangeModel _model
           
protected  int _prefWidth
           
protected  ArrayList<BTextArea.Run> _runs
           
protected  int[] _teffects
           
protected  BTextFactory[] _textfacts
           
protected  int[] _valigns
           
static int BOLD
          A font style constant.
static int ITALIC
          A font style constant.
static int PLAIN
          A font style constant.
static int UNDERLINE
          A font style constant.
 
Fields inherited from class com.jmex.bui.BContainer
_children, _layout
 
Fields inherited from class com.jmex.bui.BComponent
_alpha, _backgrounds, _bbuf, _borders, _colors, _cursor, _enabled, _height, _hover, _insets, _listeners, _parent, _preferredSize, _properties, _styleClass, _tipmouse, _tipStyle, _tiptext, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
BTextArea()
           
BTextArea(String text)
           
 
Method Summary
 void appendText(String text)
          Appends text with the foreground color in the plain style.
 void appendText(String text, ColorRGBA color)
          Appends text with the specified color in the plain style.
 void appendText(String text, ColorRGBA color, int style)
          Appends text with the specified color and style.
 void appendText(String text, int style)
          Appends text with the foreground color in the specified style.
protected  int[] checkNonDefault(int[] styles, int defval)
           
 void clearText()
          Clears out the text displayed in this area.
protected  Dimension computePreferredSize(int whint, int hhint)
          Computes and returns a preferred size for this component.
protected  void configureStyle(BStyleSheet style)
          Instructs this component to fetch its style configuration from the supplied style sheet.
protected  String getDefaultStyleClass()
          Returns the default stylesheet class to be used for all instances of this component.
 ColorRGBA getEffectColor()
          Returns the color to use for our text effect.
 int getEffectSize()
          Returns the effect size for this component's text.
 int getHorizontalAlignment()
          Returns the horizontal alignment for this component's text.
 int getLineCount()
          Returns the number of lines of text contained in this area.
 BoundedRangeModel getScrollModel()
          Returns a model that can be wired to a scroll bar to allow scrolling up and down through the lines in this text area.
 int getTextEffect()
          Returns the effect for this component's text.
 BTextFactory getTextFactory()
          Returns a text factory suitable for creating text in the style defined by the component's current state.
 int getVerticalAlignment()
          Returns the vertical alignment for this component's text.
protected  void layout()
          Instructs this component to lay itself out.
protected  void modelDidChange()
          Called when our model has changed (due to scrolling by a scroll bar or a call to scrollToLine(int), etc.).
protected  void refigureContents(int width)
          Reflows the entirety of our text.
protected  void renderComponent(Renderer renderer)
          Renders any custom bits for this component.
 void scrollToLine(int line)
          Scrolls our display such that the sepecified line is visible.
 void setEnabled(boolean enabled)
          Sets this components enabled state.
 void setPreferredWidth(int width)
          Configures the preferred width of this text area (the preferred height will be calculated from the font).
 void setText(String text)
          Clears any text in this text area and appends the supplied text.
protected  void wasAdded()
          This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).
protected  void wasRemoved()
          This method is called when we are removed from a hierarchy that is connected to a top-level window.
 
Methods inherited from class com.jmex.bui.BContainer
add, add, add, add, applyOperation, getComponent, getComponentCount, getComponentIndex, getHitComponent, getLayoutManager, getNextFocus, getPreviousFocus, remove, remove, removeAll, replace, setAlpha, setLayoutManager, setVisible, validate
 
Methods inherited from class com.jmex.bui.BComponent
acceptsFocus, addListener, applyDefaultStates, boundsToString, changeCursor, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getCursor, getFocusTarget, getHeight, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleClass, getTooltipText, getWidth, getWindow, getX, getY, hasFocus, intersectScissorBox, invalidate, isAdded, isEnabled, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, restoreScissorState, setBackground, setBounds, setCursor, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleClass, setTooltipRelativeToMouse, setTooltipText, stateDidChange, updateCursor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAIN

public static final int PLAIN
A font style constant.

See Also:
Constant Field Values

BOLD

public static final int BOLD
A font style constant.

See Also:
Constant Field Values

ITALIC

public static final int ITALIC
A font style constant.

See Also:
Constant Field Values

UNDERLINE

public static final int UNDERLINE
A font style constant.

See Also:
Constant Field Values

_haligns

protected int[] _haligns

_valigns

protected int[] _valigns

_teffects

protected int[] _teffects

_effsizes

protected int[] _effsizes

_effcols

protected ColorRGBA[] _effcols

_textfacts

protected BTextFactory[] _textfacts

_model

protected BoundedRangeModel _model

_prefWidth

protected int _prefWidth

_runs

protected ArrayList<BTextArea.Run> _runs

_lines

protected ArrayList<BTextArea.Line> _lines
Constructor Detail

BTextArea

public BTextArea()

BTextArea

public BTextArea(String text)
Method Detail

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment for this component's text.


getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment for this component's text.


setPreferredWidth

public void setPreferredWidth(int width)
Configures the preferred width of this text area (the preferred height will be calculated from the font).


getScrollModel

public BoundedRangeModel getScrollModel()
Returns a model that can be wired to a scroll bar to allow scrolling up and down through the lines in this text area.


setText

public void setText(String text)
Clears any text in this text area and appends the supplied text.


appendText

public void appendText(String text)
Appends text with the foreground color in the plain style.


appendText

public void appendText(String text,
                       ColorRGBA color)
Appends text with the specified color in the plain style.


appendText

public void appendText(String text,
                       int style)
Appends text with the foreground color in the specified style.


appendText

public void appendText(String text,
                       ColorRGBA color,
                       int style)
Appends text with the specified color and style.


clearText

public void clearText()
Clears out the text displayed in this area.


scrollToLine

public void scrollToLine(int line)
Scrolls our display such that the sepecified line is visible.


getLineCount

public int getLineCount()
Returns the number of lines of text contained in this area.


getTextFactory

public BTextFactory getTextFactory()
Returns a text factory suitable for creating text in the style defined by the component's current state.


getTextEffect

public int getTextEffect()
Returns the effect for this component's text.


getEffectSize

public int getEffectSize()
Returns the effect size for this component's text.


getEffectColor

public ColorRGBA getEffectColor()
Returns the color to use for our text effect.


setEnabled

public void setEnabled(boolean enabled)
Description copied from class: BComponent
Sets this components enabled state. A component that is not enabled should not respond to user interaction and should render itself in such a way as not to afford user interaction.

Overrides:
setEnabled in class BContainer

getDefaultStyleClass

protected String getDefaultStyleClass()
Description copied from class: BComponent
Returns the default stylesheet class to be used for all instances of this component. Derived classes will likely want to override this method and set up a default class for their type of component.

Overrides:
getDefaultStyleClass in class BContainer

wasAdded

protected void wasAdded()
Description copied from class: BComponent
This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).

Overrides:
wasAdded in class BContainer

wasRemoved

protected void wasRemoved()
Description copied from class: BComponent
This method is called when we are removed from a hierarchy that is connected to a top-level window. If we wish to clean up after things done in BComponent.wasAdded(), this is a fine place to do so.

Overrides:
wasRemoved in class BContainer

configureStyle

protected void configureStyle(BStyleSheet style)
Description copied from class: BComponent
Instructs this component to fetch its style configuration from the supplied style sheet. This method is called when a component is added to the interface hierarchy.

Overrides:
configureStyle in class BComponent

checkNonDefault

protected int[] checkNonDefault(int[] styles,
                                int defval)

layout

protected void layout()
Description copied from class: BComponent
Instructs this component to lay itself out. This is called as a result of the component changing size.

Overrides:
layout in class BContainer

renderComponent

protected void renderComponent(Renderer renderer)
Description copied from class: BComponent
Renders any custom bits for this component. This is called with the graphics context translated to (0, 0) relative to this component.

Overrides:
renderComponent in class BContainer

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: BComponent
Computes and returns a preferred size for this component. This method is called if no overriding preferred size has been supplied.

Overrides:
computePreferredSize in class BContainer
Returns:
the computed preferred size of this component in a newly created Dimension instance which will be adopted (and modified) by the caller.

refigureContents

protected void refigureContents(int width)
Reflows the entirety of our text.


modelDidChange

protected void modelDidChange()
Called when our model has changed (due to scrolling by a scroll bar or a call to scrollToLine(int), etc.).



Copyright © 2008 Michael Bayne. All Rights Reserved.