com.tensegrity.graphics
Interface TextOperations

All Known Implementing Classes:
AWTTextOperations, SWTTextOperations

public interface TextOperations

The TextOperations interface defines an object that is used within the graphics API to do calculations and operations like word wrapping of line shortening on text.

This abstraction is necessary because the graphics API supports different window toolkits like the sun swing toolkit or ibm swt. For the different toolkits the calculations on text may vary so that for each of the window toolkits there must be a facility to do the operations and calculation on text accordingly to the specific window toolkit.

Version:
$Id: TextOperations.java,v 1.15 2005/11/08 10:19:45 BurkhardWick Exp $
Author:
MichaelKegel

Field Summary
static int HORIZONTAL_ALIGNMENT_INDEX
          constant that tells about the index of a alignment constant
static int LINETYPE_STRIKETHROUGH
          Constants for the line type in the method computeLineCoordinates(FontFormat, Transform2D, String, int)
static int LINETYPE_UNDERLINE
          Constants for the line type in the method computeLineCoordinates(FontFormat, Transform2D, String, int)
static int VERTICAL_ALIGNMENT_INDEX
          constant that tells about the index of a alignment constant
 
Method Summary
 BoundingBox computeBoundingBox(java.lang.Object[] fontdata, BoundingBox bbox, Transform2D xform, java.lang.String text, int[] alignments, double textScaleX, double textScaleY)
           
 BoundingBox computeBoundingBox(java.lang.Object[] fontdata, BoundingBox bbox, Transform2D xform, java.lang.String text, int[] alignments, double textScaleX, double textScaleY, boolean multiline)
           
 double computeHeight(FontFormat font, Transform2D xform, java.lang.String text)
          Computes the height of the text given by text when using the FontFormat given by font and the transformation given by xform.
 double computeHeight(FontFormat font, Transform2D xform, java.lang.String text, boolean multiline)
          Computes the height of the text given by text when using the FontFormat given by font and the transformation given by xform.
 double computeHeight(java.lang.Object[] fontdata, Transform2D xform, java.lang.String text)
          Computes the height of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.
 double computeHeight(java.lang.Object[] fontdata, Transform2D xform, java.lang.String text, boolean multiline)
          Computes the height of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.
 Coordinate[] computeLineCoordinates(FontFormat font, Transform2D xform, java.lang.String text, int lineType)
          Computes the start and end coordinates of a line decorating a text given by text when using the FontFormat given by font and the transformation given by xform.
 Coordinate[] computeLineCoordinates(java.lang.Object[] fontData, Transform2D xform, java.lang.String text, int lineType)
          Computes the start and end coordinates of a line decorating a text given by text when using the FontFormat given by font and the transformation given by xform.
 Coordinate computeOrigin(java.lang.Object[] fontdata, BoundingBox bbox, Transform2D xform, java.lang.String text, int[] alignments, double[] lineScales)
          Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata and the transformation given by xform.
 Coordinate computeOrigin(java.lang.Object[] fontdata, BoundingBox bbox, Transform2D xform, java.lang.String text, int[] alignments, double[] lineScales, boolean multiline)
          Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata and the transformation given by xform.
 Coordinate computeOrigin(java.lang.Object[] fontdata, BoundingBox bbox, Transform2D xform, java.lang.String text, int[] alignments, double textScaleX, double textScaleY)
          Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.
 Coordinate computeOrigin(java.lang.Object[] fontdata, BoundingBox bbox, Transform2D xform, java.lang.String text, int[] alignments, double textScaleX, double textScaleY, boolean multiline)
          Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.
 double computeWidth(FontFormat font, Transform2D xform, java.lang.String text)
          Computes the width of the text given by text when using the FontFormat given by font and the transformation given by xform.
 double computeWidth(java.lang.Object[] fontdata, Transform2D xform, java.lang.String text)
          Computes the width of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.
 java.lang.String cutToWidth(FontFormat font, Transform2D xform, java.lang.String text, int width)
          Cuts the text given by text to the given width with respect to the FontFormat given by font and the transformation given by xform.
 java.lang.String cutToWidth(FontFormat font, Transform2D xform, java.lang.String text, int width, double textScaleX, double textScaleY)
          Cuts the text given by text to the given width with respect to the FontFormat given by font, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.
 java.lang.String cutToWidth(FontFormat font, Transform2D xform, java.lang.String text, int width, double textScaleX, double textScaleY, boolean keepFirstCharacter)
          Cuts the text given by text to the given width with respect to the FontFormat given by font, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.
 java.lang.String cutToWidth(java.lang.Object[] fontdata, Transform2D xform, java.lang.String text, int width)
          Cuts the text given by text to the given width with respect to the FontFormat redering data given by fontdata and the transformation given by xform.
 java.lang.String cutToWidth(java.lang.Object[] fontdata, Transform2D xform, java.lang.String text, int width, double textScaleX, double textScaleY)
          Cuts the text given by text to the given width with respect to the FontFormat redering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.
 java.lang.String cutToWidth(java.lang.Object[] fontdata, Transform2D xform, java.lang.String text, int width, double textScaleX, double textScaleY, boolean keepFirstCharacter)
          Cuts the text given by text to the given width with respect to the FontFormat redering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.
 void disableAntiAliasing()
          Disables the anti aliasing for calculations on text.
 void disableFractionalMetrics()
          Disables the anti aliasing for calculations on text.
 void enableAntiAliasing()
          Enables the anti aliasing for calculations on text.
 void enableFractionalMetrics()
          Enables fractional metrics for calculations on text.
 

Field Detail

LINETYPE_UNDERLINE

public static final int LINETYPE_UNDERLINE
Constants for the line type in the method computeLineCoordinates(FontFormat, Transform2D, String, int)

See Also:
Constant Field Values

LINETYPE_STRIKETHROUGH

public static final int LINETYPE_STRIKETHROUGH
Constants for the line type in the method computeLineCoordinates(FontFormat, Transform2D, String, int)

See Also:
Constant Field Values

VERTICAL_ALIGNMENT_INDEX

public static final int VERTICAL_ALIGNMENT_INDEX
constant that tells about the index of a alignment constant

See Also:
Constant Field Values

HORIZONTAL_ALIGNMENT_INDEX

public static final int HORIZONTAL_ALIGNMENT_INDEX
constant that tells about the index of a alignment constant

See Also:
Constant Field Values
Method Detail

enableAntiAliasing

public void enableAntiAliasing()
Enables the anti aliasing for calculations on text. This is necessary in order to calculate the correct sizes for text since they vary for antialiased and non antialiased text renderings.
NOTICE: This setting must be in consistence with the setting of the used Renderer.


disableAntiAliasing

public void disableAntiAliasing()
Disables the anti aliasing for calculations on text. This is necessary in order to calculate the correct sizes for text since they vary for antialiased and non antialiased text renderings.
NOTICE: This setting must be in consistence with the setting of the used Renderer.


enableFractionalMetrics

public void enableFractionalMetrics()
Enables fractional metrics for calculations on text. This is necessary in order to calculate the correct sizes for text since they vary for text calculated with or without fractional metrics.
NOTICE: This setting must be in consistence with the setting of the used Renderer.


disableFractionalMetrics

public void disableFractionalMetrics()
Disables the anti aliasing for calculations on text. This is necessary in order to calculate the correct sizes for text since they vary for text calculated with or without fractional metrics.
NOTICE: This setting must be in consistence with the setting of the used Renderer.


computeWidth

public double computeWidth(FontFormat font,
                           Transform2D xform,
                           java.lang.String text)
Computes the width of the text given by text when using the FontFormat given by font and the transformation given by xform.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the width for
Returns:
int the calculated width

computeWidth

public double computeWidth(java.lang.Object[] fontdata,
                           Transform2D xform,
                           java.lang.String text)
Computes the width of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the width for
Returns:
int the calculated width

computeHeight

public double computeHeight(FontFormat font,
                            Transform2D xform,
                            java.lang.String text)
Computes the height of the text given by text when using the FontFormat given by font and the transformation given by xform.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the height for
Returns:
int the calculated height

computeHeight

public double computeHeight(FontFormat font,
                            Transform2D xform,
                            java.lang.String text,
                            boolean multiline)
Computes the height of the text given by text when using the FontFormat given by font and the transformation given by xform.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the height for
multiline - if true, the line spacing will be included in the height
Returns:
int the calculated height

computeHeight

public double computeHeight(java.lang.Object[] fontdata,
                            Transform2D xform,
                            java.lang.String text)
Computes the height of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the height for
Returns:
int the calculated height

computeHeight

public double computeHeight(java.lang.Object[] fontdata,
                            Transform2D xform,
                            java.lang.String text,
                            boolean multiline)
Computes the height of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the height for
multiline - if true, the line spacing will be included in the height
Returns:
int the calculated height

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double[] lineScales)
Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata and the transformation given by xform.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
bbox - the BoundingBox to calculate the origin within
xform - the transformation to use for the calculation
text - the text to calculate the origin for
alignments - the alignments for the text
lineScales -
Returns:
Coordinate the calculated origin

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double[] lineScales,
                                boolean multiline)
Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata and the transformation given by xform.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
bbox - the BoundingBox to calculate the origin within
xform - the transformation to use for the calculation
text - the text to calculate the origin for
alignments - the alignments for the text
lineScales -
multiline - if true, the line spacing will be included in the height
Returns:
Coordinate the calculated origin

computeBoundingBox

public BoundingBox computeBoundingBox(java.lang.Object[] fontdata,
                                      BoundingBox bbox,
                                      Transform2D xform,
                                      java.lang.String text,
                                      int[] alignments,
                                      double textScaleX,
                                      double textScaleY)

computeBoundingBox

public BoundingBox computeBoundingBox(java.lang.Object[] fontdata,
                                      BoundingBox bbox,
                                      Transform2D xform,
                                      java.lang.String text,
                                      int[] alignments,
                                      double textScaleX,
                                      double textScaleY,
                                      boolean multiline)

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double textScaleX,
                                double textScaleY)
Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
bbox - the BoundingBox to calculate the origin within
xform - the transformation to use for the calculation
text - the text to calculate the origin for
alignments - the alignments for the text
textScaleX - the current scale for the text in x direction (view zoom)
textScaleY - the current scale for the text in y direction (view zoom)
Returns:
Coordinate the calculated origin

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double textScaleX,
                                double textScaleY,
                                boolean multiline)
Computes the origin for the text given by text within the BoundingBox given by bbox with respect to the alignments given by alignments, the FontFormat rendering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.

Parameters:
fontdata - the FontFormat rendering data to use for the calculation
bbox - the BoundingBox to calculate the origin within
xform - the transformation to use for the calculation
text - the text to calculate the origin for
alignments - the alignments for the text
textScaleX - the current scale for the text in x direction (view zoom)
textScaleY - the current scale for the text in y direction (view zoom)
multiline - if true, the line spacing will be included in the height
Returns:
Coordinate the calculated origin

cutToWidth

public java.lang.String cutToWidth(FontFormat font,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width)
Cuts the text given by text to the given width with respect to the FontFormat given by font and the transformation given by xform.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to cut
width - the maximum width for the remaining text
Returns:
String the cutted text

cutToWidth

public java.lang.String cutToWidth(java.lang.Object[] fontdata,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width)
Cuts the text given by text to the given width with respect to the FontFormat redering data given by fontdata and the transformation given by xform.

Parameters:
fontdata - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to cut
width - the maximum width for the remaining text
Returns:
String the cutted text

cutToWidth

public java.lang.String cutToWidth(FontFormat font,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY)
Cuts the text given by text to the given width with respect to the FontFormat given by font, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to cut
width - the maximum width for the remaining text
textScaleX - the current scale for the text in x direction (view zoom)
textScaleY - the current scale for the text in y direction (view zoom)
Returns:
String the cutted text

cutToWidth

public java.lang.String cutToWidth(FontFormat font,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY,
                                   boolean keepFirstCharacter)
Cuts the text given by text to the given width with respect to the FontFormat given by font, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to cut
width - the maximum width for the remaining text
textScaleX - the current scale for the text in x direction (view zoom)
textScaleY - the current scale for the text in y direction (view zoom)
keepFirstCharacter - true, to keep the first character of the line, even if it doesn't fit into the width
Returns:
String the cutted text

cutToWidth

public java.lang.String cutToWidth(java.lang.Object[] fontdata,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY)
Cuts the text given by text to the given width with respect to the FontFormat redering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.

Parameters:
fontdata - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to cut
width - the maximum width for the remaining text
textScaleX - the current scale for the text in x direction (view zoom)
textScaleY - the current scale for the text in y direction (view zoom)
Returns:
String the cutted text

cutToWidth

public java.lang.String cutToWidth(java.lang.Object[] fontdata,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY,
                                   boolean keepFirstCharacter)
Cuts the text given by text to the given width with respect to the FontFormat redering data given by fontdata, the transformation given by xform and the text scalings in x and y direction given by textScaleX and textScaleY.

Parameters:
fontdata - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to cut
width - the maximum width for the remaining text
textScaleX - the current scale for the text in x direction (view zoom)
textScaleY - the current scale for the text in y direction (view zoom)
keepFirstCharacter - true, to keep the first character of the line, even if it doesn't fit into the width
Returns:
String the cutted text

computeLineCoordinates

public Coordinate[] computeLineCoordinates(FontFormat font,
                                           Transform2D xform,
                                           java.lang.String text,
                                           int lineType)
Computes the start and end coordinates of a line decorating a text given by text when using the FontFormat given by font and the transformation given by xform.

Parameters:
font - the FontFormat to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the width for
lineType - The type of line: LINETYPE_UNDERLINE: Line under the text LINETYPE_STRIKETHROUGH: Line through the text
Returns:
int the calculated width

computeLineCoordinates

public Coordinate[] computeLineCoordinates(java.lang.Object[] fontData,
                                           Transform2D xform,
                                           java.lang.String text,
                                           int lineType)
Computes the start and end coordinates of a line decorating a text given by text when using the FontFormat given by font and the transformation given by xform.

Parameters:
fontData - the font format data to use for the calculation
xform - the transformation to use for the calculation
text - the text to calculate the width for
lineType - The type of line: LINETYPE_UNDERLINE: Line under the text LINETYPE_STRIKETHROUGH: Line through the text
Returns:
int the calculated width


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.