Class HyperText


  extended by Object
      extended by Component
          extended by HyperText

public class HyperText
extends Component

HyperText is multiline text component that supports different text styles and embedded links. All whitespace is treated literally. HyperText requires non-zero preferred width.

All the normal style decorations can be used for text and link spans, with following exceptions:

HyperText has following special style customizations:


See HyperText-example.


Constructor Summary
HyperText(Style style)
          Creates a new HyperText.
 
Method Summary
 void appendLink(Style style, String text, Object data)
          Adds a new link span into this hyper text.
 void appendMarkup(Map styles, String markup)
          Appends more text into this hyper text using tagged format.
 void appendMarkup(String stylePrefix, String markup)
          Appends more text into this hyper text using tagged format.
 void appendText(Style style, String text)
          Adds a new text span into this hyper text.
 void clear()
          Clears the contents of this hyper text component.
 
Methods inherited from class Component
add, appendText, find, first, get, getAction, getData, getElement, getFlags, getImage, getLocation, getParent, getShell, getSize, getStyle, getText, getViewPort, hasLinefeed, indexOf, insert, isFocusable, isShown, isVisible, isWrapping, last, operator_get, operator_set, remove, remove, repaint, set, setAction, setData, setElement, setFlags, setImage, setLocation, setPreferredHeight, setPreferredSize, setPreferredWidth, setStyle, setText, size
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HyperText

public HyperText(Style style)
Creates a new HyperText.

Parameters:
style - Style for this hyper text
Method Detail

clear

public void clear()
Clears the contents of this hyper text component.

Overrides:
clear in class Component

appendText

public void appendText(Style style,
                       String text)
Adds a new text span into this hyper text.

Parameters:
style - Text style
text - Text to append

appendLink

public void appendLink(Style style,
                       String text,
                       Object data)
Adds a new link span into this hyper text.

Parameters:
style - Text style. Focused variant is used when link is focused.
text - Text to append
data - Non-null data attachment. When link is "opened" the OPEN_LINK action is sent to Script.actionPerformed(Shell, Component, int) or ActionCallback along with Component that contains the specified data.

appendMarkup

public void appendMarkup(Map styles,
                         String markup)

Appends more text into this hyper text using tagged format. Only simple tags may appear on markup (no support for attributes). All text outside tags is ignored.

Example text:

   <h1>Title</h1>
   <p>
     Quick brown <b>fox</b> jumps over lazy <a DOG1>dog</a>!
   </p>
 

Any tag will become a link if the name of tag is followed by space character, in which case the rest of tag body is considered as link id string. This id string can be retrieved from source Component using Component.getData() at Script.actionPerformed(Shell, Component, int) or ActionCallback callbacks. The action id of notifying link "opening" is OPEN_LINK.

Links on this HyperText appear child Components; Component.get(int) and Component.size() can be used to access them.

Parameters:
styles - Collection of text styles (String to Style mappings). Mappings must match the tags used on markup, for instance, in above example there must be "h1", "p", "a" and "b" tags.
markup - Content to add in tagged format.
See Also:
appendMarkup(String, String)

appendMarkup

public void appendMarkup(String stylePrefix,
                         String markup)

Appends more text into this hyper text using tagged format. Only simple tags may appear on markup (no support for attributes). All text outside tags is ignored. Styles are taken directly from widget stylesheet, optionally prefixed with specified string.

Parameters:
stylePrefix - Optional prefix fo append to tags to form name of style
markup - Content to add in tagged format.
See Also:
appendMarkup(Map, String)