com.tensegrity.graphics.swt
Class SWTTextOperations

java.lang.Object
  extended bycom.tensegrity.graphics.swt.SWTTextOperations
All Implemented Interfaces:
TextOperations

public class SWTTextOperations
extends java.lang.Object
implements TextOperations

The SWTTextOperations class is the implementation of the TextOperations interface for the SWT toolkit.

An instance of this class has to be registered on the GraphicConfiguration class in order to inform the graphics API that it is running in the context of the SWT toolkit.

Notice that due to limitations on the SWT Device, the following method currently have an empty implementation:

Version:
$Id: SWTTextOperations.java,v 1.32 2005/12/09 15:21:07 ArndHouben Exp $
Author:
S�bastien Guyon
See Also:
GraphicConfiguration.registerTextOperationsInstance(TextOperations)

Field Summary
 
Fields inherited from interface com.tensegrity.graphics.TextOperations
HORIZONTAL_ALIGNMENT_INDEX, LINETYPE_STRIKETHROUGH, LINETYPE_UNDERLINE, VERTICAL_ALIGNMENT_INDEX
 
Constructor Summary
SWTTextOperations()
           Default constructor.
 
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 mutliline)
           
 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()
          Not implemented in the context of the SWT toolkit.
 void disableFractionalMetrics()
          Not implemented in the context of the SWT toolkit.
 void enableAntiAliasing()
          Not implemented in the context of the SWT toolkit.
 void enableFractionalMetrics()
          Not implemented in the context of the SWT toolkit.
static int getAscent(org.eclipse.swt.graphics.Font f)
          Returns the ascent for Font f.
static int getDescent(org.eclipse.swt.graphics.Font f)
          Returns the ascent for Font f.
static int getLeadingArea(org.eclipse.swt.graphics.Font f)
          Returns the leading area for Font f.
protected static org.eclipse.swt.graphics.Point getTextDimension(java.lang.String s, org.eclipse.swt.graphics.Font f)
          Returns the dimensions of the String s using the font f.
static BoundingBox getTextExtents(java.lang.String text, org.eclipse.swt.graphics.Font f)
          Returns the Dimensions of the given text, converting newlines and tabs appropriately.
static int getTextHeight(java.lang.String s, org.eclipse.swt.graphics.Font f)
          Returns the height of s in Font f.
static int getTextWidth(java.lang.String s, org.eclipse.swt.graphics.Font f)
          Returns the width of s in Font f.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWTTextOperations

public SWTTextOperations()

Default constructor.

Method Detail

enableAntiAliasing

public void enableAntiAliasing()
Not implemented in the context of the SWT toolkit.

Specified by:
enableAntiAliasing in interface TextOperations
See Also:
TextOperations.enableAntiAliasing()

disableAntiAliasing

public void disableAntiAliasing()
Not implemented in the context of the SWT toolkit.

Specified by:
disableAntiAliasing in interface TextOperations
See Also:
TextOperations.disableAntiAliasing()

enableFractionalMetrics

public void enableFractionalMetrics()
Not implemented in the context of the SWT toolkit.

Specified by:
enableFractionalMetrics in interface TextOperations
See Also:
TextOperations.enableFractionalMetrics()

disableFractionalMetrics

public void disableFractionalMetrics()
Not implemented in the context of the SWT toolkit.

Specified by:
disableFractionalMetrics in interface TextOperations
See Also:
TextOperations.disableFractionalMetrics()

computeWidth

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

Specified by:
computeWidth in interface TextOperations
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)
Description copied from interface: TextOperations
Computes the width of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.

Specified by:
computeWidth in interface TextOperations
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(java.lang.Object[] fontdata,
                            Transform2D xform,
                            java.lang.String text)
Description copied from interface: TextOperations
Computes the height of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.

Specified by:
computeHeight in interface TextOperations
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(FontFormat font,
                            Transform2D xform,
                            java.lang.String text)
Description copied from interface: TextOperations
Computes the height of the text given by text when using the FontFormat given by font and the transformation given by xform.

Specified by:
computeHeight in interface TextOperations
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

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double textScaleX,
                                double textScaleY)
Description copied from interface: TextOperations
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.

Specified by:
computeOrigin in interface TextOperations
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

computeBoundingBox

public BoundingBox computeBoundingBox(java.lang.Object[] fontdata,
                                      BoundingBox bbox,
                                      Transform2D xform,
                                      java.lang.String text,
                                      int[] alignments,
                                      double textScaleX,
                                      double textScaleY)
Specified by:
computeBoundingBox in interface TextOperations

getTextDimension

protected static org.eclipse.swt.graphics.Point getTextDimension(java.lang.String s,
                                                                 org.eclipse.swt.graphics.Font f)
Returns the dimensions of the String s using the font f. Tab expansion and carriage return processing are performed.

Parameters:
s - the string
f - the font
Returns:
the text's dimensions
See Also:
GC.textExtent(String)

getTextExtents

public static BoundingBox getTextExtents(java.lang.String text,
                                         org.eclipse.swt.graphics.Font f)
Returns the Dimensions of the given text, converting newlines and tabs appropriately.

Parameters:
text - the text
f - the font
Returns:
the dimensions of the given text

getTextWidth

public static int getTextWidth(java.lang.String s,
                               org.eclipse.swt.graphics.Font f)
Returns the width of s in Font f.

Parameters:
s - the string
f - the font
Returns:
the width

getAscent

public static int getAscent(org.eclipse.swt.graphics.Font f)
Returns the ascent for Font f.

Parameters:
f - the font
Returns:
the ascent

getLeadingArea

public static int getLeadingArea(org.eclipse.swt.graphics.Font f)
Returns the leading area for Font f.

Parameters:
f - the font
Returns:
the leading area

getDescent

public static int getDescent(org.eclipse.swt.graphics.Font f)
Returns the ascent for Font f.

Parameters:
f - the font
Returns:
the ascent

getTextHeight

public static int getTextHeight(java.lang.String s,
                                org.eclipse.swt.graphics.Font f)
Returns the height of s in Font f.

Parameters:
s - the string
f - the font
Returns:
the height of s in Font f

cutToWidth

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

Specified by:
cutToWidth in interface TextOperations
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(FontFormat font,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY,
                                   boolean keepFirstCharacter)
Description copied from interface: TextOperations
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.

Specified by:
cutToWidth in interface TextOperations
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)
Description copied from interface: TextOperations
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.

Specified by:
cutToWidth in interface TextOperations
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)
Description copied from interface: TextOperations
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.

Specified by:
cutToWidth in interface TextOperations
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(java.lang.Object[] fontdata,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY,
                                   boolean keepFirstCharacter)
Description copied from interface: TextOperations
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.

Specified by:
cutToWidth in interface TextOperations
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

cutToWidth

public java.lang.String cutToWidth(java.lang.Object[] fontdata,
                                   Transform2D xform,
                                   java.lang.String text,
                                   int width,
                                   double textScaleX,
                                   double textScaleY)
Description copied from interface: TextOperations
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.

Specified by:
cutToWidth in interface TextOperations
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

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double[] lineScales)
Description copied from interface: TextOperations
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.

Specified by:
computeOrigin in interface TextOperations
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

computeLineCoordinates

public Coordinate[] computeLineCoordinates(FontFormat font,
                                           Transform2D xform,
                                           java.lang.String text,
                                           int lineType)
Description copied from interface: TextOperations
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.

Specified by:
computeLineCoordinates in interface TextOperations
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: TextOperations.LINETYPE_UNDERLINE: Line under the text TextOperations.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)
Description copied from interface: TextOperations
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.

Specified by:
computeLineCoordinates in interface TextOperations
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: TextOperations.LINETYPE_UNDERLINE: Line under the text TextOperations.LINETYPE_STRIKETHROUGH: Line through the text
Returns:
int the calculated width

computeHeight

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

Specified by:
computeHeight in interface TextOperations
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,
                            boolean multiline)
Description copied from interface: TextOperations
Computes the height of the text given by text when using the FontFormat rendering data given by fontdata and the transformation given by xform.

Specified by:
computeHeight in interface TextOperations
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,
                                boolean multiline)
Description copied from interface: TextOperations
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.

Specified by:
computeOrigin in interface TextOperations
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,
                                      boolean mutliline)
Specified by:
computeBoundingBox in interface TextOperations

computeOrigin

public Coordinate computeOrigin(java.lang.Object[] fontdata,
                                BoundingBox bbox,
                                Transform2D xform,
                                java.lang.String text,
                                int[] alignments,
                                double textScaleX,
                                double textScaleY,
                                boolean multiline)
Description copied from interface: TextOperations
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.

Specified by:
computeOrigin in interface TextOperations
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


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