FileDocCategorySizeDatePackage
LineMetricsImpl.javaAPI DocAndroid 1.5 API11313Wed May 06 22:41:54 BST 2009org.apache.harmony.awt.gl.font

LineMetricsImpl

public class LineMetricsImpl extends LineMetrics implements Cloneable
LineMetrics implementation class.

Fields Summary
float[]
baselineOffsets
int
numChars
int
baseLineIndex
float
underlineThickness
float
underlineOffset
float
strikethroughThickness
float
strikethroughOffset
float
leading
float
height
float
ascent
float
descent
float
maxCharWidth
int
lUnderlineThickness
int
lUnderlineOffset
int
lStrikethroughThickness
int
lStrikethroughOffset
int
lLeading
int
lHeight
int
lAscent
int
lDescent
int
lMaxCharWidth
int
units_per_EM
Constructors Summary
public LineMetricsImpl(int len, float[] metrics, float[] _baselineData)
Creates LineMetricsImpl object from specified parameters. If baseline data parameter is null than {0, (-ascent+descent)/2, -ascent} values are used for baseline offsets.

param
len a number of characters
param
metrics an array of 16 elements with metrics values that can be initialized in native code.

metrics[0] - ascent

metrics[1] - descent

metrics[2] - external leading

metrics[3] - underline thickness

-metrics[4] - underline offset

metrics[5] - strikethrough thickness

-metrics[6] - strikethrough offset

metrics[7] - maximum char width

metrics[8] - ascent in pixels

metrics[9] - descent in pixles

metrics[10] - external leading in pixels

metrics[11] - underline thickness in pixels

-metrics[12] - underline offset in pixels

metrics[13] - strikethrough thickness in pixels

-metrics[14] - strikethrough offset in pixels

metrics[15] - maximum char width in pixels

param
_baselineData an array of 3 elements with baseline offsets metrics

_baselineData[0] - roman baseline offset

_baselineData[1] - center baseline offset

_baselineData[2] - hanging baseline offset


                                                                                                                                                                   
          
        numChars = len;

        ascent = metrics[0];    // Ascent of the font
        descent = metrics[1];   // Descent of the font
        leading = metrics[2];  // External leading
        height = metrics[0] + metrics[1] + metrics[2];  // Height of the font ( == (ascent + descent + leading))
    
public LineMetricsImpl(int _numChars, int _baseLineIndex, float[] _baselineOffsets, float _underlineThickness, float _underlineOffset, float _strikethroughThickness, float _strikethroughOffset, float _leading, float _height, float _ascent, float _descent, float _maxCharWidth)
Creates LineMetricsImpl object from specified parameters. If baseline data parameter is null than {0, (-ascent+descent)/2, -ascent} values are used for baseline offsets.

param
_numChars number of chars
param
_baseLineIndex index of the baseline offset
param
_baselineOffsets an array of baseline offsets
param
_underlineThickness underline thickness
param
_underlineOffset underline offset
param
_strikethroughThickness strikethrough thickness
param
_strikethroughOffset strinkethrough offset
param
_leading leading of the font
param
_height font height
param
_ascent ascent of the font
param
_descent descent of the font
param
_maxCharWidth max char width


        numChars = _numChars;
        baseLineIndex = _baseLineIndex;
        underlineThickness = _underlineThickness;
        underlineOffset = _underlineOffset;
        strikethroughThickness = _strikethroughThickness;
        strikethroughOffset = _strikethroughOffset;
        leading = _leading;
        height = _height;
        ascent = _ascent;
        descent = _descent;
        baselineOffsets = _baselineOffsets;
        lUnderlineThickness = (int) underlineThickness;
        lUnderlineOffset = (int) underlineOffset;
        lStrikethroughThickness = (int) strikethroughThickness;
        lStrikethroughOffset = (int) strikethroughOffset;
        lLeading = (int) leading;
        lHeight = (int) height;
        lAscent = (int) ascent;
        lDescent = (int) descent;
        maxCharWidth = _maxCharWidth;
    
public LineMetricsImpl()


    
Methods Summary
public java.lang.Objectclone()

        try{
            return super.clone();
        }catch (CloneNotSupportedException e){
            return null;
        }
    
public floatgetAscent()
Returns the ascent.

        return ascent;
    
public intgetBaselineIndex()
Returns index of the baseline, one of predefined constants.

        // Baseline index is the deafult baseline index value
        // taken from the TrueType table "BASE".
        return baseLineIndex;
    
public float[]getBaselineOffsets()
Returns offset of the baseline.

        // XXX: at the moment there only horizontal metrics are taken into
        // account. If there is no baseline information in TrueType font
        // file default values used: {0, -ascent, (-ascent+descent)/2}

        return baselineOffsets;
    
public floatgetDescent()
Returns the descent.

        return descent;
    
public floatgetHeight()
Returns the height of the font.

        //return height; // equals to (ascent + descent + leading);
    	return ascent + descent + leading;
    
public floatgetLeading()
Returns the leading.

        return leading;
    
public intgetLogicalAscent()
Returns the logical ascent.

        return lAscent;
    
public intgetLogicalDescent()
Returns the logical descent.

        return lDescent;
    
public intgetLogicalHeight()
Returns the logical height of the font.

        return lHeight; // equals to (ascent + descent + leading);
    
public intgetLogicalLeading()
Returns the logical leading.

        return lLeading;
    
public intgetLogicalMaxCharWidth()
Returns the logical size of the widest char.

        return lMaxCharWidth;
    
public intgetLogicalStrikethroughOffset()
Returns logical offset of the Strikethrough line.

        return lStrikethroughOffset;
    
public intgetLogicalStrikethroughThickness()
Returns logical thickness of the Strikethrough line.

        return lStrikethroughThickness;
    
public intgetLogicalUnderlineOffset()
Returns logical offset of the Underline.

        return lUnderlineOffset;
    
public intgetLogicalUnderlineThickness()
Returns logical thickness of the Underline.

        return lUnderlineThickness;
    
public floatgetMaxCharWidth()
Returns the size of the widest char.

        return maxCharWidth;
    
public intgetNumChars()
Returns a number of chars in specified text

        return numChars;
    
public floatgetStrikethroughOffset()
Returns offset of the Strikethrough line.

        return strikethroughOffset;
    
public floatgetStrikethroughThickness()
Returns thickness of the Strikethrough line.

        return strikethroughThickness;
    
public floatgetUnderlineOffset()
Returns offset of the Underline.

        return underlineOffset;
    
public floatgetUnderlineThickness()
Returns thickness of the Underline.

        return underlineThickness;
    
public voidscale(float scaleX, float scaleY)
All metrics are scaled according to scaleX and scaleY values. This function helps to recompute metrics according to the scale factors of desired AffineTransform.

param
scaleX scale X factor
param
scaleY scale Y factor

        float absScaleX = Math.abs(scaleX);
        float absScaleY = Math.abs(scaleY);

        underlineThickness *= absScaleY;
        underlineOffset *= scaleY;
        strikethroughThickness *= absScaleY;
        strikethroughOffset *= scaleY;
        leading *= absScaleY;
        height *= absScaleY;
        ascent *= absScaleY;
        descent *= absScaleY;

        if(baselineOffsets == null) {
            getBaselineOffsets();
        }

        for (int i=0; i< baselineOffsets.length; i++){
            baselineOffsets[i] *= scaleY;
        }

        lUnderlineThickness *= absScaleY;
        lUnderlineOffset *= scaleY;
        lStrikethroughThickness *= absScaleY;
        lStrikethroughOffset *= scaleY;
        lLeading  *= absScaleY;
        lHeight *= absScaleY;
        lAscent *= absScaleY;
        lDescent *= absScaleY;
        maxCharWidth *= absScaleX;

    
public voidsetNumChars(int num)
Set num chars to the desired value.

param
num specified number of chars

        numChars = num;