de.enough.polish.ui.texteffects
Class MessageTextEffect

java.lang.Object
  extended by de.enough.polish.ui.TextEffect
      extended by de.enough.polish.ui.texteffects.HtmlTextEffect
          extended by de.enough.polish.ui.texteffects.MessageTextEffect
All Implemented Interfaces:
Serializable, ItemCommandListener

public class MessageTextEffect
extends HtmlTextEffect

Allows to use simple HTML markup, message markup such as *bold*, /italic/ or _underlined_ and smileys for the design of the text. Typically this effect will be used for visualizes received or sent messages. Usage in polish.css:

 .myText {
         text-effect: message;
 }
 
Usage in Java:
 //#style myText
 StringItem item = new StringItem(null, "hello <div style=\"color: red\">red, red</div> <b>world</b> :-)" );
 

Author:
Robert Virkus

Nested Class Summary
static class MessageTextEffect.EmailMarkup
          A markup that surrounds a matching email address with a tag.
static interface MessageTextEffect.Markup
           
static class MessageTextEffect.MsisdnMarkup
          A markup that surrounds a matching email address with a tag.
static class MessageTextEffect.PatternMiddleMarkup
          A markup that surrounds a matching pattern with a tag.
static class MessageTextEffect.PatternStartMarkup
          A markup that surrounds a matching pattern with a tag.
static class MessageTextEffect.ReplacementMarkup
          A markup that replaces a static search string with a replacement Example:
static class MessageTextEffect.SurroundMarkup
          A markup that inserts text at the beginning and end of found matches.
 
Nested classes/interfaces inherited from class de.enough.polish.ui.texteffects.HtmlTextEffect
HtmlTextEffect.HtmlTextParser
 
Field Summary
 
Fields inherited from class de.enough.polish.ui.TextEffect
isTextSensitive, style
 
Constructor Summary
MessageTextEffect()
          Creates a new MessageTextEffect
 
Method Summary
static void addMarkup(MessageTextEffect.Markup markup)
          Adds a specific markup
static void clearDefaultMarkups()
          Removes all default markups
static String convertMarkup(String input)
           
static String convertMarkup(String inputText, ArrayList markupList)
           
static void setMidlet(MIDlet midlet, Command cmdOpenWebsite, Command cmdOpenMailto, Command cmdCall)
          Sets a midlet, so that email and web addresses can be resolved by opening them in the native browser
static void setMidlet(MIDlet midlet, Command cmdOpenWebsite, Command cmdOpenMailto, Command cmdCall)
          Sets a midlet, so that email and web addresses can be resolved by opening them in the native browser
 void wrap(StringItem parent, String htmlText, int textColor, Font meFont, int firstLineWidth, int lineWidth, int maxLines, String maxLinesAppendix, int maxLinesAppendixPosition, WrappedText wrappedText)
          Wraps the text into several lines and adds the result to the specified wrappedText.
 
Methods inherited from class de.enough.polish.ui.texteffects.HtmlTextEffect
calculateLinesHeight, commandAction, drawString, drawStrings, getFontHeight, setGlobalParser, setParser, setStyle, stringWidth
 
Methods inherited from class de.enough.polish.ui.TextEffect
animate, animate, charWidth, drawChar, drawStrings, drawStrings, getFont, getLeftX, getRgbData, getRgbData, getRgbData, getTopY, getTopY, hideNotify, onAttach, onDetach, releaseResources, setStyle, showNotify, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageTextEffect

public MessageTextEffect()
Creates a new MessageTextEffect

Method Detail

clearDefaultMarkups

public static void clearDefaultMarkups()
Removes all default markups


addMarkup

public static void addMarkup(MessageTextEffect.Markup markup)
Adds a specific markup

Parameters:
markup - the markup

setMidlet

public static void setMidlet(MIDlet midlet,
                             Command cmdOpenWebsite,
                             Command cmdOpenMailto,
                             Command cmdCall)
Sets a midlet, so that email and web addresses can be resolved by opening them in the native browser

Parameters:
midlet - the midlet
cmdOpenWebsite - the command for opening websites
cmdOpenMailto - the command for opening mailto/email addresses
cmdCall - the command for opening tel: numbers

setMidlet

public static void setMidlet(MIDlet midlet,
                             Command cmdOpenWebsite,
                             Command cmdOpenMailto,
                             Command cmdCall)
Sets a midlet, so that email and web addresses can be resolved by opening them in the native browser

Parameters:
midlet - the midlet
cmdOpenWebsite - the command for opening websites
cmdOpenMailto - the command for opening mailto/email addresses
cmdCall - the command for opening tel: numbers

wrap

public void wrap(StringItem parent,
                 String htmlText,
                 int textColor,
                 Font meFont,
                 int firstLineWidth,
                 int lineWidth,
                 int maxLines,
                 String maxLinesAppendix,
                 int maxLinesAppendixPosition,
                 WrappedText wrappedText)
Description copied from class: TextEffect
Wraps the text into several lines and adds the result to the specified wrappedText. The default implementation just calls TextUtil.wrap(text, font, firstLineWidth, lineWidth, maxLines, maxLinesAppendix).

Overrides:
wrap in class HtmlTextEffect
Parameters:
parent - the parent of this effect
htmlText - the text
textColor - color of the text
meFont - used font
firstLineWidth - width of the first line
lineWidth - width of following lines
maxLines - the maximum number of lines
maxLinesAppendix - the appendix that should be added to the last line when the line number is greater than maxLines
maxLinesAppendixPosition - either TextUtil.MAXLINES_APPENDIX_POSITION_AFTER or TextUtil.MAXLINES_APPENDIX_POSITION_BEFORE
wrappedText - the wrapped text object to which the single text lines should be added
See Also:
TextUtil.wrap(String, Font, int, int, int, String, int)

convertMarkup

public static String convertMarkup(String input)

convertMarkup

public static String convertMarkup(String inputText,
                                   ArrayList markupList)