gnu.java.awt.font

Class GNUGlyphVector

Implemented Interfaces:
Cloneable

public class GNUGlyphVector
extends GlyphVector

The GNU implementation of the abstract GlyphVector class, which uses the services provided by a FontDelegate for its functionality.

Field Summary

Fields inherited from class java.awt.font.GlyphVector

FLAG_COMPLEX_GLYPHS, FLAG_HAS_POSITION_ADJUSTMENTS, FLAG_HAS_TRANSFORMS, FLAG_MASK, FLAG_RUN_RTL

Constructor Summary

GNUGlyphVector(FontDelegate fontDelegate, Font font, FontRenderContext renderContext, int[] glyphs)
Constructs a new GNUGlyphVector.

Method Summary

boolean
equals(GlyphVector other)
Determines whether another GlyphVector is for the same font and rendering context, uses the same glyphs and positions them to the same location.
Font
getFont()
Returns the font of the glyphs in this GlyphVector.
FontRenderContext
getFontRenderContext()
Returns the FontRenderContext that is used to calculate the extent and position of the glyphs.
int
getGlyphCode(int glyphIndex)
Determines the glyph number by index in this vector.
int[]
getGlyphCodes(int firstGlyphIndex, int numEntries, int[] outCodes)
Returns a slice of this GlyphVector.
GlyphJustificationInfo
getGlyphJustificationInfo(int glyphIndex)
Determines the justification information for the glyph at the specified index.
Shape
getGlyphLogicalBounds(int glyphIndex)
GlyphMetrics
getGlyphMetrics(int glyphIndex)
Determines the metrics of the glyph at the specified index.
Shape
getGlyphOutline(int glyphIndex)
Determines the shape of the specified glyph.
Shape
getGlyphOutline(int glyphIndex, int type)
Point2D
getGlyphPosition(int glyphIndex)
Determines the position of the specified glyph, or the total advance width and height of the vector.
float[]
getGlyphPositions(int firstGlyphIndex, int numGlyphs, float[] outPositions)
Returns the positions of a range of glyphs in this vector.
AffineTransform
getGlyphTransform(int glyphIndex)
Returns the affine transformation that is applied to the glyph at the specified index.
Shape
getGlyphVisualBounds(int glyphIndex)
int
getLayoutFlags()
Returns flags that can be used for optimizing the rendering of this GlyphVector.
Rectangle2D
getLogicalBounds()
int
getNumGlyphs()
Determines the number of glyphs in this GlyphVector.
Shape
getOutline()
Returns the shape of this GlyphVector.
Shape
getOutline(float x, float y)
Returns the shape of this GlyphVector, translated to the specified position.
Shape
getOutline(float x, float y, int type)
Rectangle2D
getVisualBounds()
void
performDefaultLayout()
Moves each glyph in the vector to its default position.
void
setGlyphPosition(int glyphIndex, Point2D position)
Moves the specified glyph to a new position, or changes the advance width and height of the entire glyph vector.
void
setGlyphTransform(int glyphIndex, AffineTransform transform)
Applies an affine transformation to the glyph at the specified index.

Methods inherited from class java.awt.font.GlyphVector

equals, getFont, getFontRenderContext, getGlyphCharIndex, getGlyphCharIndices, getGlyphCode, getGlyphCodes, getGlyphJustificationInfo, getGlyphLogicalBounds, getGlyphMetrics, getGlyphOutline, getGlyphOutline, getGlyphPixelBounds, getGlyphPosition, getGlyphPositions, getGlyphTransform, getGlyphVisualBounds, getLayoutFlags, getLogicalBounds, getNumGlyphs, getOutline, getOutline, getPixelBounds, getVisualBounds, performDefaultLayout, setGlyphPosition, setGlyphTransform

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

GNUGlyphVector

public GNUGlyphVector(FontDelegate fontDelegate,
                      Font font,
                      FontRenderContext renderContext,
                      int[] glyphs)
Constructs a new GNUGlyphVector.
Parameters:
fontDelegate - the FontDelegate that creates this vector.
font - the Font that this GlyphVector will return for getFont(). That object is also used to determine the point size, which affects the affine transformation used by the font scaler.
renderContext - an object with parameters for font rendering, such as whether anti-aliasing is enabled.
glyphs - the glyphs in this vector.

Method Details

equals

public boolean equals(GlyphVector other)
Determines whether another GlyphVector is for the same font and rendering context, uses the same glyphs and positions them to the same location.
Overrides:
equals in interface GlyphVector
Parameters:
other - the GlyphVector to compare with.
Returns:
true if the two vectors are equal, false otherwise.

getFont

public Font getFont()
Returns the font of the glyphs in this GlyphVector.
Overrides:
getFont in interface GlyphVector

getFontRenderContext

public FontRenderContext getFontRenderContext()
Returns the FontRenderContext that is used to calculate the extent and position of the glyphs.
Overrides:
getFontRenderContext in interface GlyphVector

getGlyphCode

public int getGlyphCode(int glyphIndex)
Determines the glyph number by index in this vector. Glyph numbers are specific to each font, so two fonts will likely assign different numbers to the same glyph.
Overrides:
getGlyphCode in interface GlyphVector
Parameters:
glyphIndex - the index of the glyph whose glyph number is to be retrieved.
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

getGlyphCodes

public int[] getGlyphCodes(int firstGlyphIndex,
                           int numEntries,
                           int[] outCodes)
Returns a slice of this GlyphVector.
Overrides:
getGlyphCodes in interface GlyphVector
Parameters:
firstGlyphIndex - the index of the first glyph in the returned slice.
numEntries - the size of the returned slice.
outCodes - a pre-allocated array for storing the slice, or null to cause allocation of a new array.
Returns:
a slice of this GlyphVector. If outCodes is null, the slice will be stored into a freshly allocated array; otherwise, the result will be stored into outCodes.

getGlyphJustificationInfo

public GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex)
Determines the justification information for the glyph at the specified index.
Overrides:
getGlyphJustificationInfo in interface GlyphVector
Parameters:
glyphIndex - the index of the glyph whose justification information is to be retrieved.
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

getGlyphLogicalBounds

public Shape getGlyphLogicalBounds(int glyphIndex)
Overrides:
getGlyphLogicalBounds in interface GlyphVector

getGlyphMetrics

public GlyphMetrics getGlyphMetrics(int glyphIndex)
Determines the metrics of the glyph at the specified index.
Overrides:
getGlyphMetrics in interface GlyphVector
Parameters:
glyphIndex - the index of the glyph whose metrics is to be retrieved.
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

getGlyphOutline

public Shape getGlyphOutline(int glyphIndex)
Determines the shape of the specified glyph.
Overrides:
getGlyphOutline in interface GlyphVector
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

getGlyphOutline

public Shape getGlyphOutline(int glyphIndex,
                             int type)

getGlyphPosition

public Point2D getGlyphPosition(int glyphIndex)
Determines the position of the specified glyph, or the total advance width and height of the vector.
Overrides:
getGlyphPosition in interface GlyphVector
Parameters:
glyphIndex - the index of the glyph in question. If this value equals getNumGlyphs(), the position after the last glyph will be returned, which is the total advance width and height of the vector.
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

getGlyphPositions

public float[] getGlyphPositions(int firstGlyphIndex,
                                 int numGlyphs,
                                 float[] outPositions)
Returns the positions of a range of glyphs in this vector.
Overrides:
getGlyphPositions in interface GlyphVector
Parameters:
firstGlyphIndex - the index of the first glyph whose position is retrieved.
numGlyphs - the number of glyphs whose positions are retrieved.
outPositions - an array for storing the results (the length must be at least twice numGlyphs), or null for freshly allocating an array.
Returns:
an array with the glyph positions. The horizontal position of the i-th glyph is at index 2 * i, the vertical position at index 2 * i + 1.
Throws:
IllegalArgumentException - if numGlyphs is less than zero.
IndexOutOfBoundsException - if either firstGlyphIndex or (firstGlyphIndex + numGlyphs) is not in the range [0 .. getNumGlyphs() - 1].

getGlyphTransform

public AffineTransform getGlyphTransform(int glyphIndex)
Returns the affine transformation that is applied to the glyph at the specified index.
Overrides:
getGlyphTransform in interface GlyphVector
Parameters:
glyphIndex - the index of the glyph whose transformation is to be retrieved.
Returns:
an affine transformation, or null for the identity transformation.
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

getGlyphVisualBounds

public Shape getGlyphVisualBounds(int glyphIndex)
Overrides:
getGlyphVisualBounds in interface GlyphVector

getLayoutFlags

public int getLayoutFlags()
Returns flags that can be used for optimizing the rendering of this GlyphVector.
Overrides:
getLayoutFlags in interface GlyphVector
Returns:
a bit mask with the applicable flags set.
Since:
1.4

getLogicalBounds

public Rectangle2D getLogicalBounds()
Overrides:
getLogicalBounds in interface GlyphVector

getNumGlyphs

public int getNumGlyphs()
Determines the number of glyphs in this GlyphVector.
Overrides:
getNumGlyphs in interface GlyphVector

getOutline

public Shape getOutline()
Returns the shape of this GlyphVector.
Overrides:
getOutline in interface GlyphVector

getOutline

public Shape getOutline(float x,
                        float y)
Returns the shape of this GlyphVector, translated to the specified position.
Overrides:
getOutline in interface GlyphVector
Parameters:
x - the horizontal position for rendering this vector.
y - the vertical position for rendering this vector.

getOutline

public Shape getOutline(float x,
                        float y,
                        int type)

getVisualBounds

public Rectangle2D getVisualBounds()
Overrides:
getVisualBounds in interface GlyphVector

performDefaultLayout

public void performDefaultLayout()
Moves each glyph in the vector to its default position.
Overrides:
performDefaultLayout in interface GlyphVector

setGlyphPosition

public void setGlyphPosition(int glyphIndex,
                             Point2D position)
Moves the specified glyph to a new position, or changes the advance width and height of the entire glyph vector.

Note that the position of an individual glyph may also affected by its affine transformation.

Overrides:
setGlyphPosition in interface GlyphVector
Parameters:
glyphIndex - the index of the moved glyph. If glyphIndex equals the total number of glyphs in this vector, the advance width and height of the vector is changed.
position - the new position of the glyph.
Throws:
IndexOutOfBoundsException - if glyphIndex is not in the range .

setGlyphTransform

public void setGlyphTransform(int glyphIndex,
                              AffineTransform transform)
Applies an affine transformation to the glyph at the specified index.
Overrides:
setGlyphTransform in interface GlyphVector
Parameters:
glyphIndex - the index of the glyph to which the transformation is applied.
transform - the affine transformation for the glyph, or null for an identity transformation.

GNUGlyphVector.java -- The GNU implementation of GlyphVector. Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.