ewe.fx
Class FormattedTextSpecs

java.lang.Object
  extended byewe.fx.FormattedTextSpecs

public class FormattedTextSpecs
extends Object

This is used for calculated formatted text metrics.


Field Summary
 Color backgroundColor
           
 int[] calculatedPositions
          If this is not null these will be the calculated positions of each character in a String.
 char[] charsToDraw
           
 int displayLineHeight
          This is the height of the line (in pixels) that the formatted text will be displayed in.
 int displayLineWidth
          This is the width of the line (in pixels) that the formatted text will be displayed in.
 int extraSpaceUsed
          The extra space used by other formatters.
 int firstCharPosition
          The position (in pixels) of the leftmost character on the line when displayed.
 boolean isFormatted
          This is used by getWidthAndPositions().
 int leftMargin
          Space to put before the first character on the line.
static int LINE_FLAG_CANCEL_ALIGNMENTS
           
 int lineFlags
          This can be one of the LINE_FLAG_XXXX values.
 FontMetrics metrics
          Metrics for the text.
 int numCharsToDraw
           
 int options
          There are currently no options defined.
 int rightMargin
          The position (in pixels) of the leftmost character on the line when displayed.
 int tabCharacterWidth
          If this is greater than 0, it is taken to be the number of characters wide a Tab stop will be.
 int tabPixelWidth
          If this is greater than 0, it is taken to be the number of pixels wide a Tab stop will be.
 
Constructor Summary
FormattedTextSpecs()
           
 
Method Summary
protected  int[] adjustPositions(int startFrom, int change)
          Adjust the positions of the characters as currently specified by calculatedPositions.
 int[] changeAndAdjustPositions(int[] newPositions, int startFrom, int length)
           
static int getTabWidth(FormattedTextSpecs fts, FontMetrics fm)
          Return the tabWidth in pixels.
static int getWidthAndPositions(String s, FormattedTextSpecs fts, FontMetrics fm, boolean alwaysFormatted)
          Calculate the positions of each character in the String.
 int[] insertSpace(int beforeCharacter, int space)
           
 int widthOf(int startFrom, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

options

public int options
There are currently no options defined.


tabCharacterWidth

public int tabCharacterWidth
If this is greater than 0, it is taken to be the number of characters wide a Tab stop will be. If you set it to zero, then you should set tabPixelWidth to be greater than 0. By default it is 8.

See Also:
tabPixelWidth

tabPixelWidth

public int tabPixelWidth
If this is greater than 0, it is taken to be the number of pixels wide a Tab stop will be.

See Also:
tabCharacterWidth

calculatedPositions

public int[] calculatedPositions
If this is not null these will be the calculated positions of each character in a String.


metrics

public FontMetrics metrics
Metrics for the text.


isFormatted

public boolean isFormatted
This is used by getWidthAndPositions(). If it discovers no formatting it will set it false.


firstCharPosition

public int firstCharPosition
The position (in pixels) of the leftmost character on the line when displayed.


leftMargin

public int leftMargin
Space to put before the first character on the line.


rightMargin

public int rightMargin
The position (in pixels) of the leftmost character on the line when displayed.


extraSpaceUsed

public int extraSpaceUsed
The extra space used by other formatters.


displayLineWidth

public int displayLineWidth
This is the width of the line (in pixels) that the formatted text will be displayed in.


displayLineHeight

public int displayLineHeight
This is the height of the line (in pixels) that the formatted text will be displayed in.


charsToDraw

public char[] charsToDraw

numCharsToDraw

public int numCharsToDraw

LINE_FLAG_CANCEL_ALIGNMENTS

public static int LINE_FLAG_CANCEL_ALIGNMENTS

lineFlags

public int lineFlags
This can be one of the LINE_FLAG_XXXX values.


backgroundColor

public Color backgroundColor
Constructor Detail

FormattedTextSpecs

public FormattedTextSpecs()
Method Detail

getTabWidth

public static int getTabWidth(FormattedTextSpecs fts,
                              FontMetrics fm)
Return the tabWidth in pixels.


getWidthAndPositions

public static int getWidthAndPositions(String s,
                                       FormattedTextSpecs fts,
                                       FontMetrics fm,
                                       boolean alwaysFormatted)
Calculate the positions of each character in the String. If the String is formatted (i.e. has TAB) characters in it) then the variable isFormatted will be set true and the calculatedPositions variable will hold the positions of each character.

Parameters:
s - The string to check.
fts - The FormattedTextSpecs for the calculation.
fm - The FontMetrics being used.
alwaysFormatted - if this is true consider it to always be formatted.
Returns:
the full width of the String.

adjustPositions

protected int[] adjustPositions(int startFrom,
                                int change)
Adjust the positions of the characters as currently specified by calculatedPositions.

Parameters:
startFrom - The character to start adjusting from.
change - The amount to adjust the position.
Returns:
the adjusted positions.

insertSpace

public int[] insertSpace(int beforeCharacter,
                         int space)

changeAndAdjustPositions

public int[] changeAndAdjustPositions(int[] newPositions,
                                      int startFrom,
                                      int length)

widthOf

public int widthOf(int startFrom,
                   int length)