java.lang.Object
java.awt.font.GlyphVector
- 所有已实现的接口:
Cloneable
GlyphVector
对象是一个字形集合,其中包含用于将每个字形放置在转换坐标空间中的几何信息,该坐标空间对应于最终显示 GlyphVector
的设备。
GlyphVector
不尝试对其包含的字形序列进行任何解释。顺序相邻字形之间的关系仅用于确定字形在视觉坐标空间中的位置。
GlyphVector
的实例由 Font
创建。
在可以缓存文本中间表示的文本处理应用程序中,GlyphVector
的创建和后续缓存以供在渲染期间使用是向用户呈现字符视觉表示的最快方法。
GlyphVector
仅与一个 Font
相关联,并且可以提供仅与此 Font
有关的有用数据。此外,从 GlyphVector
获得的指标通常不是几何可缩放的,因为像素化和间距取决于 Font
中的网格拟合算法。为了便于准确测量 GlyphVector
及其组成字形,您必须在创建 GlyphVector
时指定缩放变换、抗锯齿模式和分数度量模式。这些特性可以从目标设备中导出。
对于 GlyphVector
中的每个字形,您可以获得:
- 字形的位置
- 与字形关联的转换
GlyphVector
上下文中字形的度量。在不同的转换、应用程序指定的渲染提示和GlyphVector
中字形的特定实例下,字形的度量可能不同。
改变用于创建 GlyphVector
的数据不会改变 GlyphVector
的状态。
提供了调整 GlyphVector
中字形位置的方法。这些方法最适合为字形的呈现执行对齐操作的应用程序。
提供了在 GlyphVector
中转换单个字形的方法。这些方法主要用于特殊效果。
提供了返回整个 GlyphVector
或 GlyphVector
中的单个字形的视觉、逻辑和像素边界的方法。
提供了为 GlyphVector
和 GlyphVector
中的各个字形返回 Shape
的方法。
- 参见:
-
字段摘要
字段修饰符和类型Field描述static final int
与 getLayoutFlags 一起使用的标志,指示此GlyphVector
具有复杂的字形到字符映射(不按照与运行方向匹配的严格升序或降序一对一地将字形映射到字符)。static final int
与 getLayoutFlags 一起使用的标志,表示此GlyphVector
具有位置调整。static final int
与 getLayoutFlags 一起使用的标志,指示此GlyphVector
具有每个字形转换。static final int
来自 getLayoutFlags 的受支持标志的掩码。static final int
与 getLayoutFlags 一起使用的标志,指示此GlyphVector
具有从右到左的运行方向。 -
构造方法总结
构造方法 -
方法总结
修饰符和类型方法描述abstract boolean
equals
(GlyphVector set) 测试指定的GlyphVector
是否完全等于这个GlyphVector
。abstract Font
getFont()
返回与此GlyphVector
关联的Font
。abstract FontRenderContext
返回与此GlyphVector
关联的FontRenderContext
。int
getGlyphCharIndex
(int glyphIndex) 返回指定字形的字符索引。int[]
getGlyphCharIndices
(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字符索引。abstract int
getGlyphCode
(int glyphIndex) 返回指定字形的字形代码。abstract int[]
getGlyphCodes
(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字形代码数组。abstract GlyphJustificationInfo
getGlyphJustificationInfo
(int glyphIndex) 将指定索引处的字形的对齐信息返回到此GlyphVector
中。abstract Shape
getGlyphLogicalBounds
(int glyphIndex) 返回此GlyphVector
中指定字形的逻辑边界。abstract GlyphMetrics
getGlyphMetrics
(int glyphIndex) 将指定索引处的字形指标返回到此GlyphVector
中。abstract Shape
getGlyphOutline
(int glyphIndex) 返回一个Shape
,其内部对应于此GlyphVector
中指定字形的视觉表示。getGlyphOutline
(int glyphIndex, float x, float y) 返回一个Shape
,其内部对应于此GlyphVector
中指定字形的视觉表示,偏移到 x,y。getGlyphPixelBounds
(int index, FontRenderContext renderFRC, float x, float y) 当此GlyphVector
在给定位置处具有给定FontRenderContext
的Graphics
中呈现时,返回索引处字形的像素边界。abstract Point2D
getGlyphPosition
(int glyphIndex) 返回指定字形相对于此GlyphVector
原点的位置。abstract float[]
getGlyphPositions
(int beginGlyphIndex, int numEntries, float[] positionReturn) 返回指定字形的字形位置数组。abstract AffineTransform
getGlyphTransform
(int glyphIndex) 返回此GlyphVector
中指定字形的转换。abstract Shape
getGlyphVisualBounds
(int glyphIndex) 返回GlyphVector
中指定字形的视觉边界。int
返回描述 GlyphVector 全局状态的标志。abstract Rectangle2D
返回此GlyphVector
的逻辑边界。abstract int
返回此GlyphVector
中的字形数。abstract Shape
返回一个Shape
,其内部对应于此GlyphVector
的视觉表示。abstract Shape
getOutline
(float x, float y) 返回一个Shape
,其内部对应于此GlyphVector
在 x、y 处呈现时的视觉表示。getPixelBounds
(FontRenderContext renderFRC, float x, float y) 返回在给定位置处具有给定FontRenderContext
的图形中呈现时此GlyphVector
的像素边界。abstract Rectangle2D
返回此GlyphVector
的视觉边界视觉边界是此GlyphVector
轮廓的边界框。abstract void
为这个GlyphVector
中的每个字形分配默认位置。abstract void
setGlyphPosition
(int glyphIndex, Point2D newPos) 在此GlyphVector
中设置指定字形的位置。abstract void
setGlyphTransform
(int glyphIndex, AffineTransform newTX) 在此GlyphVector
中设置指定字形的变换。
-
字段详细信息
-
FLAG_HAS_TRANSFORMS
public static final int FLAG_HAS_TRANSFORMS与 getLayoutFlags 一起使用的标志,指示此GlyphVector
具有每个字形转换。- 自从:
- 1.4
- 参见:
-
FLAG_HAS_POSITION_ADJUSTMENTS
public static final int FLAG_HAS_POSITION_ADJUSTMENTS与 getLayoutFlags 一起使用的标志,表示此GlyphVector
具有位置调整。当这是真的时,字形位置与字形的累积默认进步不匹配(例如,如果字距调整已经完成)。- 自从:
- 1.4
- 参见:
-
FLAG_RUN_RTL
public static final int FLAG_RUN_RTL与 getLayoutFlags 一起使用的标志,指示此GlyphVector
具有从右到左的运行方向。这是指字形到字符的映射,并不意味着字形的视觉位置必须按此顺序排列,尽管通常它们会如此。- 自从:
- 1.4
- 参见:
-
FLAG_COMPLEX_GLYPHS
public static final int FLAG_COMPLEX_GLYPHS与 getLayoutFlags 一起使用的标志,指示此GlyphVector
具有复杂的字形到字符映射(不按照与运行方向匹配的严格升序或降序一对一地将字形映射到字符)。- 自从:
- 1.4
- 参见:
-
FLAG_MASK
public static final int FLAG_MASK来自 getLayoutFlags 的受支持标志的掩码。只应测试掩码重写的位。- 自从:
- 1.4
- 参见:
-
-
构造方法详细信息
-
GlyphVector
protected GlyphVector()子类调用的构造方法。
-
-
方法详情
-
getFont
返回与此GlyphVector
关联的Font
。- 返回:
Font
用于创建此GlyphVector
。- 参见:
-
getFontRenderContext
返回与此GlyphVector
关联的FontRenderContext
。- 返回:
FontRenderContext
用于创建此GlyphVector
。- 参见:
-
performDefaultLayout
public abstract void performDefaultLayout()为这个GlyphVector
中的每个字形分配默认位置。这会破坏在这个GlyphVector
初始布局期间生成的信息。 -
getNumGlyphs
public abstract int getNumGlyphs()返回此GlyphVector
中的字形数。- 返回:
-
此
GlyphVector
中的字形数。
-
getGlyphCode
public abstract int getGlyphCode(int glyphIndex) 返回指定字形的字形代码。除了创建此GlyphVector
的Font
对象之外,此返回值对任何其他对象都没有意义。- 参数:
glyphIndex
- 此GlyphVector
中的索引对应于从中检索字形代码的字形。- 返回:
-
指定
glyphIndex
处字形的字形代码。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数
-
getGlyphCodes
public abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字形代码数组。除了用于创建此GlyphVector
的Font
之外,此返回值的内容对任何其他内容均无意义。在处理字形代码时,使用此方法是为了方便和提高性能。如果没有传入数组,则创建一个新数组。- 参数:
beginGlyphIndex
- 开始检索字形代码的GlyphVector
的索引numEntries
- 要检索的字形代码数codeReturn
- 接收字形代码然后返回的数组- 返回:
- 指定字形的字形代码数组。
- 抛出:
IllegalArgumentException
- 如果numEntries
小于 0IndexOutOfBoundsException
- 如果beginGlyphIndex
小于 0IndexOutOfBoundsException
- 如果beginGlyphIndex
和numEntries
的总和大于此GlyphVector
中的字形数
-
getGlyphCharIndex
public int getGlyphCharIndex(int glyphIndex) 返回指定字形的字符索引。字符索引是字形表示的第一个逻辑字符的索引。默认实现假定字形到字符的一对一、从左到右映射。- 参数:
glyphIndex
- 字形的索引- 返回:
- 字形表示的第一个字符的索引
- 自从:
- 1.4
-
getGlyphCharIndices
public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字符索引。字符索引是字形表示的第一个逻辑字符的索引。索引按字形顺序返回。默认实现为每个字形调用 getGlyphCharIndex,出于性能原因,子类化者可能希望重写此实现。在处理字形代码时使用此方法是为了方便和提高性能。如果没有传入数组,则创建一个新数组。- 参数:
beginGlyphIndex
- 第一个字形的索引numEntries
- 字形索引的数量codeReturn
- 返回字符索引的数组- 返回:
- 一组字符索引,每个字形一个。
- 自从:
- 1.4
-
getLogicalBounds
返回此GlyphVector
的逻辑边界。在将此GlyphVector
与视觉上相邻的GlyphVector
对象相关联时使用此方法。- 返回:
-
一个
Rectangle2D
是这个GlyphVector
的逻辑边界。
-
getVisualBounds
返回此GlyphVector
的视觉边界视觉边界是此GlyphVector
轮廓的边界框。由于像素的光栅化和对齐,此框可能不会包含受渲染此GlyphVector
影响的所有像素。- 返回:
-
一个
Rectangle2D
是这个GlyphVector
的边界框。
-
getPixelBounds
返回在给定位置处具有给定FontRenderContext
的图形中呈现时此GlyphVector
的像素边界。 renderFRC 不必与此GlyphVector
的FontRenderContext
相同,并且可以为空。如果为 null,则使用此GlyphVector
的FontRenderContext
。默认实现返回视觉边界、x、y 的偏移量并四舍五入到下一个整数值(即返回一个包含视觉边界的整数矩形)并忽略 FRC。子类应该覆盖这个方法。- 参数:
renderFRC
-Graphics
的FontRenderContext
。x
- 渲染此GlyphVector
的 x 坐标。y
- 渲染此GlyphVector
的 y 坐标。- 返回:
-
a
Rectangle
限制会受影响的像素。 - 自从:
- 1.4
-
getOutline
返回一个Shape
,其内部对应于此GlyphVector
的视觉表示。- 返回:
Shape
是这个GlyphVector
的轮廓。
-
getOutline
返回一个Shape
,其内部对应于此GlyphVector
在 x、y 处呈现时的视觉表示。- 参数:
x
- 这个GlyphVector
的 X 坐标。y
- 这个GlyphVector
的 Y 坐标。- 返回:
-
一个
Shape
是这个GlyphVector
在指定坐标处呈现时的轮廓。
-
getGlyphOutline
返回一个Shape
,其内部对应于此GlyphVector
中指定字形的视觉表示。此方法返回的轮廓位于每个单独字形的原点周围。- 参数:
glyphIndex
- 这个GlyphVector
的索引- 返回:
-
一个
Shape
是此GlyphVector
的指定glyphIndex
处的字形轮廓。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数
-
getGlyphOutline
返回一个Shape
,其内部对应于此GlyphVector
中指定字形的视觉表示,偏移到 x,y。此方法返回的轮廓位于每个单独字形的原点周围。- 参数:
glyphIndex
- 这个GlyphVector
的索引x
- 这个GlyphVector
位置的 X 坐标y
- 这个GlyphVector
位置的Y坐标- 返回:
-
一个
Shape
是在指定坐标处呈现时此GlyphVector
的指定glyphIndex
处的字形轮廓。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数- 自从:
- 1.4
-
getGlyphPosition
返回指定字形相对于此GlyphVector
原点的位置。如果glyphIndex
等于此GlyphVector
中的字形数,则此方法返回最后一个字形之后的位置。这个位置用来定义整个GlyphVector
的前进。- 参数:
glyphIndex
- 这个GlyphVector
的索引- 返回:
-
一个
Point2D
对象,它是指定glyphIndex
处字形的位置。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于此GlyphVector
中的字形数- 参见:
-
setGlyphPosition
在此GlyphVector
中设置指定字形的位置。如果glyphIndex
等于此GlyphVector
中的字形数,则此方法设置最后一个字形之后的位置。这个位置用来定义整个GlyphVector
的前进。- 参数:
glyphIndex
- 这个GlyphVector
的索引newPos
- 将字形定位在指定的glyphIndex
的Point2D
- 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于此GlyphVector
中的字形数- 参见:
-
getGlyphTransform
返回此GlyphVector
中指定字形的转换。变换是相对于字形位置的。如果没有应用特殊变换,可以返回null
。空返回表示身份转换。- 参数:
glyphIndex
- 这个GlyphVector
的索引- 返回:
-
一个
AffineTransform
,它是指定glyphIndex
处字形的转换。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数- 参见:
-
setGlyphTransform
在此GlyphVector
中设置指定字形的变换。变换是相对于字形位置的。newTX
的null
参数表示没有对指定的字形应用特殊变换。此方法可用于旋转、镜像、平移和缩放字形。添加转换可能会导致显着的性能变化。- 参数:
glyphIndex
- 这个GlyphVector
的索引newTX
-glyphIndex
处字形的新变换- 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数- 参见:
-
getLayoutFlags
public int getLayoutFlags()返回描述 GlyphVector 全局状态的标志。下面未描述的标志是保留的。对于位置调整、转换、rtl 和复杂标志,默认实现返回 0(表示 false)。子类应该重写这个方法,并确保它正确地描述了 GlyphVector 并对应于相关调用的结果。- 返回:
- 一个包含描述状态的标志的 int
- 自从:
- 1.4
- 参见:
-
getGlyphPositions
public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn) 返回指定字形的字形位置数组。在处理字形位置时使用此方法是为了方便和提高性能。如果没有传入数组,则创建一个新数组。从位置零开始的偶数数组条目是编号为beginGlyphIndex + position/2
的字形的 X 坐标。从位置一开始的奇数数组条目是编号为beginGlyphIndex + (position-1)/2
的字形的 Y 坐标。如果beginGlyphIndex
等于此GlyphVector
中的字形数,则此方法获取最后一个字形之后的位置,该位置用于定义整个GlyphVector
的前进。- 参数:
beginGlyphIndex
- 开始检索字形位置的索引numEntries
- 要检索的字形数positionReturn
- 接收字形位置然后返回的数组。- 返回:
-
由
beginGlyphIndex
和numEntries
指定的字形位置数组。 - 抛出:
IllegalArgumentException
- 如果numEntries
小于 0IndexOutOfBoundsException
- 如果beginGlyphIndex
小于 0IndexOutOfBoundsException
- 如果beginGlyphIndex
和numEntries
的总和大于此GlyphVector
中的字形数加一
-
getGlyphLogicalBounds
返回此GlyphVector
中指定字形的逻辑边界。这些逻辑边界共有四个边,其中两个边平行于字形变换下的基线,另外两个边与相邻字形共享(如果它们存在)。此方法可用于指定字形的命中测试、将插入符号定位在字形的前缘或后缘,以及在指定字形周围绘制高亮区域。- 参数:
glyphIndex
- 此GlyphVector
的索引对应于从中检索其逻辑边界的字形- 返回:
Shape
是指定glyphIndex
处字形的逻辑边界。- 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数- 参见:
-
getGlyphVisualBounds
返回GlyphVector
中指定字形的视觉边界。此方法返回的边界位于每个单独字形的原点周围。- 参数:
glyphIndex
- 此GlyphVector
的索引对应于从中检索其视觉边界的字形- 返回:
Shape
是指定glyphIndex
处字形的视觉边界。- 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数- 参见:
-
getGlyphPixelBounds
当此GlyphVector
在给定位置处具有给定FontRenderContext
的Graphics
中呈现时,返回索引处字形的像素边界。 renderFRC 不必与此GlyphVector
的FontRenderContext
相同,并且可以为空。如果为 null,则使用此GlyphVector
的FontRenderContext
。默认实现返回字形的视觉边界,偏移到 x、y 并四舍五入到下一个整数值,并忽略 FRC。子类应该覆盖这个方法。- 参数:
index
- 字形的索引。renderFRC
-Graphics
的FontRenderContext
。x
- 渲染此GlyphVector
的 X 位置。y
- 渲染此GlyphVector
的 Y 位置。- 返回:
-
a
Rectangle
限制会受影响的像素。 - 自从:
- 1.4
-
getGlyphMetrics
将指定索引处的字形指标返回到此GlyphVector
中。- 参数:
glyphIndex
- 此GlyphVector
的索引对应于从中检索其指标的字形- 返回:
-
一个
GlyphMetrics
对象,表示指定glyphIndex
处的字形指标到此GlyphVector
中。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数
-
getGlyphJustificationInfo
将指定索引处的字形的对齐信息返回到此GlyphVector
中。- 参数:
glyphIndex
- 此GlyphVector
的索引对应于从中检索其对齐属性的字形- 返回:
-
一个
GlyphJustificationInfo
对象,表示指定glyphIndex
处字形的对齐属性到此GlyphVector
中。 - 抛出:
IndexOutOfBoundsException
- 如果glyphIndex
小于 0 或大于或等于此GlyphVector
中的字形数
-
equals
测试指定的GlyphVector
是否完全等于这个GlyphVector
。- 参数:
set
- 指定的GlyphVector
进行测试- 返回:
true
如果指定的GlyphVector
等于这个GlyphVector
;false
否则。
-