de.enough.polish.ui.texteffects
Class SmileyTextEffect

java.lang.Object
  extended by de.enough.polish.ui.TextEffect
      extended by de.enough.polish.ui.texteffects.SmileyTextEffect
All Implemented Interfaces:
Serializable

public class SmileyTextEffect
extends TextEffect

Renders textual smileys with images.

Activate the smiley text effect by specifying text-effect: smiley; in your polish.css file.

Copyright (c) 2007 Enough Software

 history
        16-July-2007 - Andre creation
 

Author:
Andre Schmidt, j2mepolish@enough.de, Robert Virkus, j2mepolish@enough.de

Nested Class Summary
 class SmileyTextEffect.Smiley
           
 
Field Summary
protected  java.lang.String currentSmiley
           
static SmileyTextEffect.Smiley[] smileyList
           
protected  java.util.Hashtable smileyMap
           
 
Fields inherited from class de.enough.polish.ui.TextEffect
style
 
Constructor Summary
SmileyTextEffect()
          Creates a text with smileys
 
Method Summary
 void drawString(java.lang.String text, int textColor, int x, int y, int orientation, javax.microedition.lcdui.Graphics g)
          Paints the text and applies the text effect.
 int getFontHeight()
          Retrieves the font height by default.
protected  int getSmiley(java.lang.String line)
           
protected  void init()
           
 int stringWidth(java.lang.String str)
          Calculates the width of the given text.
 java.lang.String[] wrap(java.lang.String text, javax.microedition.lcdui.Font font, int firstLineWidth, int lineWidth)
          Wraps the text into several lines.
 void wrap(java.lang.String value, javax.microedition.lcdui.Font font, int completeWidth, int firstLineWidth, int lineWidth, ArrayList list)
           
 
Methods inherited from class de.enough.polish.ui.TextEffect
animate, animate, drawStrings, getFont, getLeftX, getRgbData, getRgbData, getRgbData, getTopY, getTopY, hideNotify, releaseResources, setStyle, showNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

smileyList

public static SmileyTextEffect.Smiley[] smileyList

smileyMap

protected java.util.Hashtable smileyMap

currentSmiley

protected java.lang.String currentSmiley
Constructor Detail

SmileyTextEffect

public SmileyTextEffect()
Creates a text with smileys

Method Detail

init

protected void init()

stringWidth

public int stringWidth(java.lang.String str)
Description copied from class: TextEffect
Calculates the width of the given text. By default getFont().stringWidth(text) is returned.

Overrides:
stringWidth in class TextEffect
Parameters:
str - the text of which the width should be determined
Returns:
the width of the text

getFontHeight

public int getFontHeight()
Description copied from class: TextEffect
Retrieves the font height by default.

Overrides:
getFontHeight in class TextEffect
Returns:
the height of the font

wrap

public java.lang.String[] wrap(java.lang.String text,
                               javax.microedition.lcdui.Font font,
                               int firstLineWidth,
                               int lineWidth)
Description copied from class: TextEffect
Wraps the text into several lines.

Overrides:
wrap in class TextEffect
Parameters:
text - the text
font - used font
firstLineWidth - width of the first line
lineWidth - width of following lines
Returns:
an arrays with strings all fitting into the specified dimensions

wrap

public void wrap(java.lang.String value,
                 javax.microedition.lcdui.Font font,
                 int completeWidth,
                 int firstLineWidth,
                 int lineWidth,
                 ArrayList list)

drawString

public void drawString(java.lang.String text,
                       int textColor,
                       int x,
                       int y,
                       int orientation,
                       javax.microedition.lcdui.Graphics g)
Description copied from class: TextEffect
Paints the text and applies the text effect.

Specified by:
drawString in class TextEffect
Parameters:
text - the text
textColor - the color of the text
x - x coordinate
y - y coordinate
orientation - the orientation, e.g. Graphics.TOP | Graphics.LEFT or Graphics.TOP | Graphics.HCENTER
g - the graphics context

getSmiley

protected int getSmiley(java.lang.String line)