ewe.ui.formatted
Class TextFormatter

java.lang.Object
  extended byewe.data.DataObject
      extended byewe.ui.formatted.TextFormatter
All Implemented Interfaces:
Comparable, Copyable, DataUnit
Direct Known Subclasses:
HotSpot

public class TextFormatter
extends DataObject

A TextFormatter is used to format all or some of the text of a single line of an mTextPad display.


Field Summary
 Color backgroundColor
           
 int borderWidth
           
static Object CIRCLE
           
 Color color
          If this is not null then the text will be redrawn in this color if the FONT_CHANGE flag is set in fontFlags.
 int cursor
           
 Object data
           
static Object DIAMOND
           
 int endCharacter
          The index of the last character in the last line being covered by the formatter.
static int FONT_CHANGE
          This is a fontFlag.
static int FONT_FREEZE
           
 int fontFlags
          This can be a combination of FONT_CHANGE along with Font.BOLD, Font.UNDERLINE and Font.ITALIC.
 String fontName
          The name of the new font to use (FONT_CHANGE must be set).
 int fontSize
          The amount to change the font to (FONT_CHANGE must be set).
 int fontSizeChange
          The amount to change the font size by (FONT_CHANGE must be set).
 int groupID
          The ID of the group this formatter belongs to.
 int groupIndex
          The index of this formatter in the group this formatter belongs to.
 int hSpace
           
 IImage image
           
 int imageChar
          The character that comes after the image.
 int imageLine
          The line that the image is actually on.
 int imageX
           
 int imageY
           
 String label
           
 int leftMarginShift
           
static int LINE_ADD_FIRST_LINE_HEADER
          This is a possible lineFlag.
static int LINE_ALIGN_NOW
          This is a possible lineFlag.
static int LINE_BACKGROUND_COLOR_CHANGE
          This is a possible lineFlag.
static int LINE_CANCEL_ALIGNMENTS
          This is a possible lineFlag.
static int LINE_CENTERED
          This is a possible lineFlag.
static int LINE_DRAW_RULE
          This is a possible lineFlag.
static int LINE_HEADER_RIGHT_ALIGN
          This is a possible lineFlag.
static int LINE_LEFT_MARGIN_SHIFT_IS_CHARACTERS
          This is a possible lineFlag.
static int LINE_RESPLIT
          This is a possible lineFlag.
static int LINE_RIGHT_ALIGNED
          This is a possible lineFlag.
 int lineFlags
          This can be a combination of the LINE_XXX values.
 TextFormatter linkedTo
           
 Font newFont
          If you set this to a Font, the fontFlags, fontSizeChange and fontName values are ignored and this is used instead.
 boolean notUsed
           
 int numLines
          The number of lines covered by the formatter.
 int resplitWidthChange
           
static Object SOLID_CIRCLE
           
 int startCharacter
          The first character in the line being covered by the formatter.
 int startLine
          The first line of text covered by the formatter - where 0 indicates the first line of the display.
 Object toolTip
           
 int vSpace
           
 
Constructor Summary
TextFormatter()
           
TextFormatter(int line, int character, int length)
           
TextFormatter(int startLine, int numLines, int fontFlags, int lineFlags)
           
TextFormatter(int line, int character, int length, int fontFlags, int lineFlags)
           
 
Method Summary
 boolean applyAfter()
          Returns if this need to be applied at the end of the line.
 boolean applyBefore()
          Returns if this need to be applied at the start or during the line.
protected  void applySpecialFormat(mTextPad source, int lineIndex, DisplayLine theLine, FormattedTextSpecs format)
           
 DisplayLine creatingFor(mTextPad pad, DisplayLine firstLine, int numLines, int lineIndex)
          This gives the TextFormatter the chance to actually alter the lines being displayed.
protected  void drawSpecialFormat(mTextPad source, int lineIndex, DisplayLine theLine, FormattedTextSpecs format, Graphics g, Color background)
           
static IImage getBrokenImage()
           
 Range getCharRange(int lineIndex, DisplayLine theLine, Range dest)
           
 TextFormatter getEndFormatter(TextFormatter dest)
           
 Font getFont(Font baseFont, int useSize)
           
protected  FontMetrics getFontMetrics(mTextPad pad, FontMetrics baseFont)
           
 TextFormatter getStartFormatter(TextFormatter dest)
           
 Object getToolTip()
           
static IImage getUnknownImage()
           
 boolean isOnImage(mTextPad source, int xPosition, FormattedTextSpecs specs)
           
 String rangeToString()
           
 void repaint(mTextPad pad, Graphics gr)
           
protected  void replace(mTextPad pad, DisplayLine firstLine, int numLines, DisplayLine newLines)
           
protected  DisplayLine resplit(mTextPad pad, DisplayLine firstLine, int numLines, int forWidth, String newText)
           
 String toString()
          Return a String representation of this object.
 
Methods inherited from class ewe.data.DataObject
_getSetField, appendAllFields, compareTo, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode
 

Field Detail

startLine

public int startLine
The first line of text covered by the formatter - where 0 indicates the first line of the display.


numLines

public int numLines
The number of lines covered by the formatter. - if it is greater than 1, then this is a block level formatter and the "character" and "length" members are not used.


startCharacter

public int startCharacter
The first character in the line being covered by the formatter. If this is -1 then it is assumed that this formatter will not have any effect on the displayed text, but is really only used as some sort of flag or marker for the line or lines


endCharacter

public int endCharacter
The index of the last character in the last line being covered by the formatter. If this is -1 then it is assumed that the formatter is applied to ALL characters in ALL the lines covered by the formatter.


color

public Color color
If this is not null then the text will be redrawn in this color if the FONT_CHANGE flag is set in fontFlags.


FONT_CHANGE

public static final int FONT_CHANGE
This is a fontFlag. Other fontFlags could be Font.BOLD, Font.UNDERLINE and Font.ITALIC.

See Also:
Constant Field Values

FONT_FREEZE

public static final int FONT_FREEZE
See Also:
Constant Field Values

fontFlags

public int fontFlags
This can be a combination of FONT_CHANGE along with Font.BOLD, Font.UNDERLINE and Font.ITALIC.


lineFlags

public int lineFlags
This can be a combination of the LINE_XXX values.


LINE_CENTERED

public static final int LINE_CENTERED
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_RIGHT_ALIGNED

public static final int LINE_RIGHT_ALIGNED
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_RESPLIT

public static final int LINE_RESPLIT
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_ADD_FIRST_LINE_HEADER

public static final int LINE_ADD_FIRST_LINE_HEADER
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_LEFT_MARGIN_SHIFT_IS_CHARACTERS

public static final int LINE_LEFT_MARGIN_SHIFT_IS_CHARACTERS
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_HEADER_RIGHT_ALIGN

public static final int LINE_HEADER_RIGHT_ALIGN
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_DRAW_RULE

public static final int LINE_DRAW_RULE
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_ALIGN_NOW

public static final int LINE_ALIGN_NOW
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_CANCEL_ALIGNMENTS

public static final int LINE_CANCEL_ALIGNMENTS
This is a possible lineFlag.

See Also:
Constant Field Values

LINE_BACKGROUND_COLOR_CHANGE

public static final int LINE_BACKGROUND_COLOR_CHANGE
This is a possible lineFlag.

See Also:
Constant Field Values

backgroundColor

public Color backgroundColor

data

public Object data

toolTip

public Object toolTip

cursor

public int cursor

leftMarginShift

public int leftMarginShift

resplitWidthChange

public int resplitWidthChange

label

public String label

image

public IImage image

imageLine

public int imageLine
The line that the image is actually on.


imageChar

public int imageChar
The character that comes after the image.


imageX

public int imageX

imageY

public int imageY

hSpace

public int hSpace

vSpace

public int vSpace

borderWidth

public int borderWidth

linkedTo

public TextFormatter linkedTo

notUsed

public boolean notUsed

fontSizeChange

public int fontSizeChange
The amount to change the font size by (FONT_CHANGE must be set).


fontSize

public int fontSize
The amount to change the font to (FONT_CHANGE must be set).


fontName

public String fontName
The name of the new font to use (FONT_CHANGE must be set).


newFont

public Font newFont
If you set this to a Font, the fontFlags, fontSizeChange and fontName values are ignored and this is used instead.


groupID

public int groupID
The ID of the group this formatter belongs to.


groupIndex

public int groupIndex
The index of this formatter in the group this formatter belongs to.


SOLID_CIRCLE

public static final Object SOLID_CIRCLE

CIRCLE

public static final Object CIRCLE

DIAMOND

public static final Object DIAMOND
Constructor Detail

TextFormatter

public TextFormatter()

TextFormatter

public TextFormatter(int line,
                     int character,
                     int length)

TextFormatter

public TextFormatter(int line,
                     int character,
                     int length,
                     int fontFlags,
                     int lineFlags)

TextFormatter

public TextFormatter(int startLine,
                     int numLines,
                     int fontFlags,
                     int lineFlags)
Method Detail

applyBefore

public boolean applyBefore()
Returns if this need to be applied at the start or during the line.


applyAfter

public boolean applyAfter()
Returns if this need to be applied at the end of the line.


getEndFormatter

public TextFormatter getEndFormatter(TextFormatter dest)

getStartFormatter

public TextFormatter getStartFormatter(TextFormatter dest)

getUnknownImage

public static IImage getUnknownImage()

getBrokenImage

public static IImage getBrokenImage()

rangeToString

public String rangeToString()

toString

public String toString()
Description copied from class: Object
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representing this object.

getToolTip

public Object getToolTip()

getFont

public Font getFont(Font baseFont,
                    int useSize)

getFontMetrics

protected FontMetrics getFontMetrics(mTextPad pad,
                                     FontMetrics baseFont)

getCharRange

public Range getCharRange(int lineIndex,
                          DisplayLine theLine,
                          Range dest)

applySpecialFormat

protected void applySpecialFormat(mTextPad source,
                                  int lineIndex,
                                  DisplayLine theLine,
                                  FormattedTextSpecs format)

isOnImage

public boolean isOnImage(mTextPad source,
                         int xPosition,
                         FormattedTextSpecs specs)

drawSpecialFormat

protected void drawSpecialFormat(mTextPad source,
                                 int lineIndex,
                                 DisplayLine theLine,
                                 FormattedTextSpecs format,
                                 Graphics g,
                                 Color background)

replace

protected void replace(mTextPad pad,
                       DisplayLine firstLine,
                       int numLines,
                       DisplayLine newLines)

resplit

protected DisplayLine resplit(mTextPad pad,
                              DisplayLine firstLine,
                              int numLines,
                              int forWidth,
                              String newText)

creatingFor

public DisplayLine creatingFor(mTextPad pad,
                               DisplayLine firstLine,
                               int numLines,
                               int lineIndex)
This gives the TextFormatter the chance to actually alter the lines being displayed.


repaint

public void repaint(mTextPad pad,
                    Graphics gr)