FileDocCategorySizeDatePackage
GlyphVector.javaAPI DocAndroid 1.5 API13767Wed May 06 22:41:54 BST 2009java.awt.font

GlyphVector

public abstract class GlyphVector extends Object implements Cloneable
The GlyphVector class contains a collection of glyphs with geometric information and each glyph's location. Each GlyphVector can be associated with only one Font. GlyphVector contains the following properties for each glyph:
  • the glyph position;
  • the transform of the glyph;
  • the metrics of the glyph in the context of the GlyphVector.
since
Android 1.0

Fields Summary
public static final int
FLAG_HAS_TRANSFORMS
The Constant FLAG_HAS_TRANSFORMS indicates that this GlyphVector has per-glyph transforms.
public static final int
FLAG_HAS_POSITION_ADJUSTMENTS
The Constant FLAG_HAS_POSITION_ADJUSTMENTS indicates that the GlyphVector has per-glyph position adjustments.
public static final int
FLAG_RUN_RTL
The Constant FLAG_RUN_RTL indicates that this GlyphVector has a right to left run direction.
public static final int
FLAG_COMPLEX_GLYPHS
The Constant FLAG_COMPLEX_GLYPHS indicates that this GlyphVector has a complex glyph to char mapping.
public static final int
FLAG_MASK
The Constant FLAG_MASK indicates a mask for supported flags from getLayoutFlags.
Constructors Summary
public GlyphVector()
Instantiates a new GlyphVector.

 // (|) mask of other flags

             
      
    
Methods Summary
public abstract booleanequals(java.awt.font.GlyphVector glyphVector)
Compares this GlyphVector with the specified GlyphVector objects.

param
glyphVector the GlyphVector object to be compared.
return
true, if this GlyphVector is equal to the specified GlyphVector object, false otherwise.

public abstract java.awt.FontgetFont()
Gets the font of this GlyphVector.

return
the font of this GlyphVector.

public abstract java.awt.font.FontRenderContextgetFontRenderContext()
Gets the FontRenderContext of this GlyphVector.

return
the FontRenderContext of this GlyphVector.

public intgetGlyphCharIndex(int glyphIndex)
Gets the first logical character's index of the specified glyph.

param
glyphIndex the glyph index.
return
the the first logical character's index.

        // default implemetation one-to-one
        return glyphIndex;
    
public int[]getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)
Gets an array of the character indices of the specified glyphs.

param
beginGlyphIndex the index of the first glyph to return information for.
param
numEntries the number of glyph indices to return.
param
codeReturn the array into which the resulting character indices will be written.
return
an array of character indices for the specifies glyphs.

        if (codeReturn == null) {
            codeReturn = new int[numEntries];
        }

        for (int i = 0; i < numEntries; i++) {
            codeReturn[i] = getGlyphCharIndex(i + beginGlyphIndex);
        }
        return codeReturn;
    
public abstract intgetGlyphCode(int glyphIndex)
Gets the glyph code of the specified glyph.

param
glyphIndex the index in this GlyphVector which corresponds to the glyph from which to retrieve the glyphcode.
return
the glyphcode of the specified glyph.

public abstract int[]getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)
Gets an array of the glyph codes of the specified glyphs.

param
beginGlyphIndex the index into this GlyphVector at which to start retrieving glyph codes.
param
numEntries the number of glyph codes.
param
codeReturn the array into which the resulting glyphcodes will be written.
return
the array of the glyph codes.

public abstract java.awt.font.GlyphJustificationInfogetGlyphJustificationInfo(int glyphIndex)
Gets the justification information of the glyph whose index is specified.

param
glyphIndex the glyph index.
return
the GlyphJustificationInfo for the specified glyph.

public abstract java.awt.ShapegetGlyphLogicalBounds(int glyphIndex)
Gets the logical bounds of the specified glyph in the GlyphVector.

param
glyphIndex the index in this GlyphVector of the glyph from which to retrieve its logical bounds
return
the logical bounds of the specified glyph in the GlyphVector.

public abstract java.awt.font.GlyphMetricsgetGlyphMetrics(int glyphIndex)
Gets the metrics of the glyph with the specified index in this GlyphVector.

param
glyphIndex index in this GlyphVector.
return
the metrics of the glyph with the specified index in this GlyphVector.

public java.awt.ShapegetGlyphOutline(int glyphIndex, float x, float y)
Gets a Shape object which defines the visual representation of the specified glyph in this GlyphVector, translated a distance of x in the X direction and y in the Y direction.

param
glyphIndex the glyth index in this GlyphVector.
param
x the distance in the X direction to translate the shape object before returning it.
param
y the distance in the Y direction to translate the shape object before returning it.
return
a Shape object which represents the visual representation of the specified glyph in this GlyphVector - glyph outline.

        Shape initialShape = getGlyphOutline(glyphIndex);
        AffineTransform trans = AffineTransform.getTranslateInstance(x, y);
        return trans.createTransformedShape(initialShape);
    
public abstract java.awt.ShapegetGlyphOutline(int glyphIndex)
Gets a Shape object which defines the visual representation of the specified glyph in this GlyphVector.

param
glyphIndex the glyth index in this GlyphVector.
return
a Shape object which represents the visual representation of the specified glyph in this GlyphVector - glyph outline.

public java.awt.RectanglegetGlyphPixelBounds(int index, java.awt.font.FontRenderContext frc, float x, float y)
Gets the pixel bounds of the glyph with the specified index in this GlyphVector which is rendered with the specified FontRenderContext at the specified location.

param
index the glyph index in this GlyphVector.
param
frc the FontRenderContext.
param
x the X coordinate of the GlyphVector's location.
param
y the Y coordinate of the GlyphVector's location.
return
a Rectangle bounds.

        Rectangle2D visualRect = getGlyphVisualBounds(index).getBounds2D();

        int minX = (int)Math.floor(visualRect.getMinX() + x);
        int minY = (int)Math.floor(visualRect.getMinY() + y);
        int width = (int)Math.ceil(visualRect.getMaxX() + x) - minX;
        int height = (int)Math.ceil(visualRect.getMaxY() + y) - minY;

        return new Rectangle(minX, minY, width, height);
    
public abstract java.awt.geom.Point2DgetGlyphPosition(int glyphIndex)
Gets the position of the specified glyph in this GlyphVector.

param
glyphIndex the glyph index in this GlyphVector.
return
the position of the specified glyph in this GlyphVector.

public abstract float[]getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)
Gets an array of the positions of the specified glyphs in this GlyphVector.

param
beginGlyphIndex the index of the first glyph to return information for.
param
numEntries the number of glyphs to return information for.
param
positionReturn the array where the result will be stored.
return
an array of glyph positions.

public abstract java.awt.geom.AffineTransformgetGlyphTransform(int glyphIndex)
Gets the transform of the specified glyph in this GlyphVector.

param
glyphIndex the glyph index in this GlyphVector.
return
the new transform of the glyph.

public abstract java.awt.ShapegetGlyphVisualBounds(int glyphIndex)
Gets the visual bounds of the specified glyph in the GlyphVector.

param
glyphIndex the glyph index in this GlyphVector.
return
the glyph visual bounds of the glyph with the specified index in the GlyphVector.

public intgetLayoutFlags()
Gets flags which describe the global state of the GlyphVector. The default implementation returns 0.

return
the layout flags

        // default implementation - returned value is 0
        return 0;
    
public abstract java.awt.geom.Rectangle2DgetLogicalBounds()
Gets the logical bounds of the GlyphVector.

return
the logical bounds of the GlyphVector.

public abstract intgetNumGlyphs()
Gets the number of glyphs in the GlyphVector.

return
the number of glyphs in the GlyphVector.

public abstract java.awt.ShapegetOutline(float x, float y)
Gets the visual representation of this GlyphVector rendered in x, y location as a Shape object.

param
x the x coordinate of the GlyphVector.
param
y the y coordinate of the GlyphVector.
return
the visual representation of this GlyphVector as a Shape object.

public abstract java.awt.ShapegetOutline()
Gets the visual representation of this GlyphVector as a Shape object.

return
the visual representation of this GlyphVector as a Shape object.

public java.awt.RectanglegetPixelBounds(java.awt.font.FontRenderContext frc, float x, float y)
Gets the pixel bounds of the GlyphVector when rendered at the specified location with the specified FontRenderContext.

param
frc the FontRenderContext.
param
x the X coordinate of the GlyphVector's location.
param
y the Y coordinate of the GlyphVector's location.
return
the pixel bounds

        // default implementation - integer Rectangle, that encloses visual
        // bounds rectangle
        Rectangle2D visualRect = getVisualBounds();

        int minX = (int)Math.floor(visualRect.getMinX() + x);
        int minY = (int)Math.floor(visualRect.getMinY() + y);
        int width = (int)Math.ceil(visualRect.getMaxX() + x) - minX;
        int height = (int)Math.ceil(visualRect.getMaxY() + y) - minY;

        return new Rectangle(minX, minY, width, height);
    
public abstract java.awt.geom.Rectangle2DgetVisualBounds()
Gets the visual bounds of the GlyphVector.

return
the visual bounds of the GlyphVector.

public abstract voidperformDefaultLayout()
Sets default layout to this GlyphVector.

public abstract voidsetGlyphPosition(int glyphIndex, java.awt.geom.Point2D newPos)
Sets the position of the specified glyph in this GlyphVector.

param
glyphIndex the glyph index in this GlyphVector.
param
newPos the new position of the glyph at the specified glyphIndex.

public abstract voidsetGlyphTransform(int glyphIndex, java.awt.geom.AffineTransform trans)
Sets the affine transform to a glyph with the specified index in this GlyphVector.

param
glyphIndex the glyth index in this GlyphVector.
param
trans the AffineTransform to be assigned to the specified glyph.