- java.lang.Object
-
- java.awt.font.GlyphVector
-
- All Implemented Interfaces:
-
Cloneable
public abstract class GlyphVector extends Object implements Cloneable
GlyphVector对象是包含几何信息的字形的集合,用于在对应于最终显示GlyphVector的设备的变换的坐标空间中放置每个字形。GlyphVector不会尝试对其包含的字形序列的任何解释。 序列中相邻字形之间的关系仅用于确定字形在视觉坐标空间中的位置。实例
GlyphVector由创建Font。在可以缓存文本的中间表示的文本处理应用中,用于渲染期间的
GlyphVector创建和后续高速缓存是向用户呈现字符的可视表示的最快方法。A
GlyphVector与正好一个Font相关联,并且可以提供仅对于该Font有用的数据。 此外,从GlyphVector获得的GlyphVector通常不是几何可缩放的,因为像素化和间隔取决于Font网格拟合算法。 为了方便对GlyphVector及其组件字形的精确测量,您必须在创建GlyphVector时指定缩放变换,反混叠模式和小数度量模式。 这些特性可以从目标设备导出。对于
GlyphVector每个字形,您可以获取:- 字形的位置
- 与字形相关联的转换
- 字形在
GlyphVector的上下文中的GlyphVector。 在不同的变换,应用程序指定的渲染提示和GlyphVector中的字形的具体实例中,字形的度量可能不同。
改变用于创建数据
GlyphVector不会改变的状态GlyphVector。提供了方法来调整字形在
GlyphVector内的GlyphVector。 这些方法对于正在执行用于呈现字形的对齐操作的应用程序是最合适的。提供了方法来转换
GlyphVector内的各个字形。 这些方法主要用于特殊效果。提供一些方法以返回两个整个的视觉,逻辑和像素范围
GlyphVector的内或各个字形的GlyphVector。提供了方法来为
GlyphVector和GlyphVector中的单个字形返回一个GlyphVector。- 另请参见:
-
Font,GlyphMetrics,TextLayout
-
-
Field Summary
Fields Modifier and Type Field 描述 static intFLAG_COMPLEX_GLYPHS与getLayoutFlags一起使用的标志,表示该GlyphVector具有复杂的字形到字符映射(一个不以符合运行方向的严格升序或降序的方式将字形映射到字符一对一)。static intFLAG_HAS_POSITION_ADJUSTMENTS与getLayoutFlags一起使用的标志,表示此GlyphVector具有位置调整。static intFLAG_HAS_TRANSFORMS与getLayoutFlags一起使用的标志,表示此GlyphVector具有每个字形转换。static intFLAG_MASK来自getLayoutFlags的支持标志的掩码。static intFLAG_RUN_RTL与getLayoutFlags一起使用的标志,表示此GlyphVector具有从右到左的运行方向。
-
构造方法摘要
构造方法 Constructor 描述 GlyphVector()
-
方法摘要
所有方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 abstract booleanequals(GlyphVector set)测试指定的GlyphVector完全等于此GlyphVector。abstract FontgetFont()返回Font与此GlyphVector相关联。abstract FontRenderContextgetFontRenderContext()返回FontRenderContext与此相关GlyphVector。intgetGlyphCharIndex(int glyphIndex)返回指定字形的字符索引。int[]getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)返回指定字形的字符索引。abstract intgetGlyphCode(int glyphIndex)返回指定字形的字形代码。abstract int[]getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)返回指定字形的字形数组。abstract GlyphJustificationInfogetGlyphJustificationInfo(int glyphIndex)将指定索引中的字形的对齐信息返回到此GlyphVector。abstract ShapegetGlyphLogicalBounds(int glyphIndex)返回此GlyphVector指定字形的逻辑边界。abstract GlyphMetricsgetGlyphMetrics(int glyphIndex)将指定索引中的字形的度量返回到此GlyphVector。abstract ShapegetGlyphOutline(int glyphIndex)返回一个Shape其内部对应于此GlyphVector指定字形的视觉表示。ShapegetGlyphOutline(int glyphIndex, float x, float y)返回一个Shape其内部对应于该GlyphVector内的指定字形的视觉表示,偏移到x,y。RectanglegetGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y)当这个返回index字形的像素边界GlyphVector在渲染Graphics给定FontRenderContext在给定位置。abstract Point2DgetGlyphPosition(int glyphIndex)返回指定字形相对于此GlyphVector的原点的GlyphVector。abstract float[]getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)返回指定字形的字形位置数组。abstract AffineTransformgetGlyphTransform(int glyphIndex)返回此GlyphVector指定字形的变换。abstract ShapegetGlyphVisualBounds(int glyphIndex)返回GlyphVector指定字形的视觉边界。intgetLayoutFlags()返回描述GlyphVector全局状态的标志。abstract Rectangle2DgetLogicalBounds()返回此GlyphVector的逻辑边界。abstract intgetNumGlyphs()返回此GlyphVector的字形数。abstract ShapegetOutline()返回一个Shape其内部对应于此GlyphVector的视觉表示。abstract ShapegetOutline(float x, float y)返回一个Shape其内部对应于这个GlyphVector在x,y渲染时的视觉表示。RectanglegetPixelBounds(FontRenderContext renderFRC, float x, float y)在给定位置的给定FontRenderContext的图形中渲染时,返回此GlyphVector的像素边界。abstract Rectangle2DgetVisualBounds()返回此GlyphVector的边界GlyphVector视觉边界是这个GlyphVector轮廓的边界框。abstract voidperformDefaultLayout()为此GlyphVector每个字形分配默认位置。abstract voidsetGlyphPosition(int glyphIndex, Point2D newPos)设置此GlyphVector指定字形的位置。abstract voidsetGlyphTransform(int glyphIndex, AffineTransform newTX)设置此GlyphVector指定字形的变换。
-
-
-
字段详细信息
-
FLAG_HAS_TRANSFORMS
public static final int FLAG_HAS_TRANSFORMS
与getLayoutFlags一起使用的标志,表示此GlyphVector具有每个字形转换。- 从以下版本开始:
- 1.4
- 另请参见:
- Constant Field Values
-
FLAG_HAS_POSITION_ADJUSTMENTS
public static final int FLAG_HAS_POSITION_ADJUSTMENTS
与getLayoutFlags一起使用的标志,表示该GlyphVector具有位置调整。 当这是真的,字形位置与字形的累积默认进度不匹配(例如,如果已经完成了字距调整)。- 从以下版本开始:
- 1.4
- 另请参见:
- Constant Field Values
-
FLAG_RUN_RTL
public static final int FLAG_RUN_RTL
与getLayoutFlags一起使用的标志,表示此GlyphVector具有从右到左的运行方向。 这是指字形到字符映射,并不意味着字形的视觉位置必然按照这个顺序,尽管通常它们将是。- 从以下版本开始:
- 1.4
- 另请参见:
- Constant Field Values
-
FLAG_COMPLEX_GLYPHS
public static final int FLAG_COMPLEX_GLYPHS
与getLayoutFlags一起使用的标志,表示该GlyphVector具有复杂的字形到字符映射(一个不以符合运行方向的严格升序或降序的方式将字形映射到字符一对一)。- 从以下版本开始:
- 1.4
- 另请参见:
- Constant Field Values
-
FLAG_MASK
public static final int FLAG_MASK
来自getLayoutFlags的支持标志的掩码。 只有面罩覆盖的位才能被测试。- 从以下版本开始:
- 1.4
- 另请参见:
- Constant Field Values
-
-
方法详细信息
-
getFont
public abstract Font getFont()
返回Font与此GlyphVector相关联。- 结果
-
Font用于创建这个GlyphVector。 - 另请参见:
-
Font
-
getFontRenderContext
public abstract FontRenderContext getFontRenderContext()
返回FontRenderContext与此相关GlyphVector。- 结果
-
FontRenderContext用于创建这个GlyphVector。 - 另请参见:
-
FontRenderContext,Font
-
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)返回指定字形的字形数组。Font用于创建此GlyphVector的Font之外,此返回值的内容是无意义的。 当处理字形时,该方法用于方便和性能。 如果没有传入数组,则会创建一个新数组。- 参数
-
beginGlyphIndex- 这个GlyphVector的索引开始检索字形 -
numEntries- 要检索的字形数的数量 -
codeReturn- 接收字形并返回的数组 - 结果
- 指定字形的字形数组数组。
- 异常
-
IllegalArgumentException- 如果numEntries小于0 -
IndexOutOfBoundsException- 如果beginGlyphIndex小于0 -
IndexOutOfBoundsException-如果总和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
public abstract Rectangle2D getLogicalBounds()
返回此GlyphVector的逻辑边界。 当定位GlyphVector与视觉上相邻的GlyphVector对象相关时使用此方法。- 结果
-
一个
Rectangle2D,它是此的逻辑边界GlyphVector。
-
getVisualBounds
public abstract Rectangle2D getVisualBounds()
返回这个GlyphVector的视觉边界视觉边界是这个GlyphVector的轮廓的边界框。 由于像素的光栅化和对齐,可能这个框不会包含所有受渲染影响的像素GlyphVector。- 结果
-
一个
Rectangle2D这是这个GlyphVector的边框。
-
getPixelBounds
public Rectangle getPixelBounds(FontRenderContext renderFRC, float x, float y)
在给定位置的给定FontRenderContext的图形中渲染时,返回此GlyphVector的像素边界。 renderFRC不需要与此GlyphVector的FontRenderContext相同,并且可以为null。 如果为空,则使用该FontRenderContext的GlyphVector。 默认实现返回可视边界,偏移量为x,y,并舍入到下一个整数值(即返回一个包围视觉边界的整数矩形),并忽略FRC。 子类应该覆盖此方法。- 参数
-
renderFRC-FontRenderContext的Graphics。 -
x- 呈现这个GlyphVector的x坐标。 -
y- 渲染这个GlyphVector的y坐标。 - 结果
-
一个
Rectangle限制将受影响的像素。 - 从以下版本开始:
- 1.4
-
getOutline
public abstract Shape getOutline()
返回一个Shape其内部对应于该GlyphVector的视觉表示。- 结果
-
一个
Shape是这个GlyphVector的轮廓。
-
getOutline
public abstract Shape getOutline(float x, float y)
返回一个Shape其内部对应于在x,y呈现时的GlyphVector的视觉表示。- 参数
-
x- 这个GlyphVector的X坐标。 -
y- 这个GlyphVector的Y坐标。 - 结果
-
一个
Shape是这个GlyphVector的轮廓,当在指定的坐标渲染时。
-
getGlyphOutline
public abstract Shape getGlyphOutline(int glyphIndex)
返回一个Shape其内部对应于该GlyphVector指定字形的视觉表示。 通过此方法返回的轮廓位于每个单个字形的原点周围。- 参数
-
glyphIndex- 该指数GlyphVector - 结果
-
一个
Shape是这个GlyphVector指定的glyphIndex的字形轮廓。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数
-
getGlyphOutline
public Shape getGlyphOutline(int glyphIndex, float x, float y)
返回一个Shape其内部对应于该GlyphVector内的指定字形的视觉表示,偏移到x,y。 通过此方法返回的轮廓位于每个单个字形的原点周围。- 参数
-
glyphIndex- 索引到这个GlyphVector -
x- 这个GlyphVector的位置的X坐标 -
y- 这个位置的Y坐标GlyphVector - 结果
-
一个
Shape是在指定的坐标处呈现glyphIndex的GlyphVector的字形的轮廓。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数 - 从以下版本开始:
- 1.4
-
getGlyphPosition
public abstract Point2D getGlyphPosition(int glyphIndex)
返回指定字形相对于该GlyphVector的原点的GlyphVector。 如果glyphIndex于此GlyphVector的字形数,则此方法返回最后一个字形后的位置。 这个位置用于定义整个GlyphVector。- 参数
-
glyphIndex- 该指数GlyphVector - 结果
-
一个
Point2D对象,它是在指定的glyphIndex处的字形位置。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于此GlyphVector的字形数 - 另请参见:
-
setGlyphPosition(int, java.awt.geom.Point2D)
-
setGlyphPosition
public abstract void setGlyphPosition(int glyphIndex, Point2D newPos)设置此GlyphVector指定字形的位置。 如果glyphIndex等于在这个字形数GlyphVector,此方法设置的最后一个字形后的位置。 这个位置用来定义整个GlyphVector。- 参数
-
glyphIndex- 索引到这个GlyphVector -
newPos-Point2D在Point2D定位字形在指定的glyphIndex - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于此GlyphVector的字形数 - 另请参见:
-
getGlyphPosition(int)
-
getGlyphTransform
public abstract AffineTransform getGlyphTransform(int glyphIndex)
返回此GlyphVector指定字形的变换。 该变换是相对于字形位置。 如果没有应用特殊转换,可以返回null。 空返回表示身份转换。- 参数
-
glyphIndex- 索引到这个GlyphVector - 结果
-
一个
AffineTransform这是在指定的glyphIndex的字形的变换。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数 - 另请参见:
-
setGlyphTransform(int, java.awt.geom.AffineTransform)
-
setGlyphTransform
public abstract void setGlyphTransform(int glyphIndex, AffineTransform newTX)设置此GlyphVector指定字形的变换。 该变换是相对于字形位置。 甲null参数为newTX表示被应用于指定字形没有特殊的变换。 该方法可用于旋转,反射,翻译和缩放字形。 添加变换可能导致显着的性能变化。- 参数
-
glyphIndex- 索引到这个GlyphVector -
newTX- 字形的新变换在glyphIndex - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于该字形数GlyphVector - 另请参见:
-
getGlyphTransform(int)
-
getLayoutFlags
public int getLayoutFlags()
返回描述GlyphVector全局状态的标志。 下面没有描述的标志是保留的。 默认实现为位置调整,变换,rtl和复杂标志返回0(意思是假)。 子类应该覆盖此方法,并确保它正确地描述了GlyphVector并对应于相关调用的结果。- 结果
- 一个包含描述状态的标志的int
- 从以下版本开始:
- 1.4
- 另请参见:
-
FLAG_HAS_POSITION_ADJUSTMENTS,FLAG_HAS_TRANSFORMS,FLAG_RUN_RTL,FLAG_COMPLEX_GLYPHS,FLAG_MASK
-
getGlyphPositions
public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)返回指定字形的字形位置数组。 当处理字形位置时,该方法用于方便和性能。 如果没有传入数组,则会创建一个新数组。 以位置零开始的偶数编号的数组条目是beginGlyphIndex + position/2为beginGlyphIndex + position/2的字形的X坐标。 以位置1开始的奇数编号的数组条目是beginGlyphIndex + (position-1)/2为beginGlyphIndex + (position-1)/2的字形的Y坐标。 如果beginGlyphIndex等于字形在这个数量GlyphVector,这种方法获取的位置的最后字形后,该位置用于定义整个的提前GlyphVector。- 参数
-
beginGlyphIndex- 开始检索字形位置的索引 -
numEntries- 要检索的字形数 -
positionReturn- 接收字形位置然后返回的数组。 - 结果
-
由
beginGlyphIndex和numEntries指定的字形位置数组。 - 异常
-
IllegalArgumentException- 如果numEntries小于0 -
IndexOutOfBoundsException- 如果beginGlyphIndex小于0 -
IndexOutOfBoundsException- 如果beginGlyphIndex和numEntries的总和大于此GlyphVector加上的字形数
-
getGlyphLogicalBounds
public abstract Shape getGlyphLogicalBounds(int glyphIndex)
返回此GlyphVector指定字形的逻辑边界。 这些逻辑边界共有四个边,其中两个边在字形变换下平行于基线,而另外两个边与存在的相邻字形共享。 该方法对于指定字形的命中测试,在符号的前导或后沿定位插入符号以及用于在指定字形周围绘制高亮区域是有用的。- 参数
-
glyphIndex- 对应于从其检索其逻辑边界的字形的此GlyphVector中的索引 - 结果
-
一个
Shape这是在指定的glyphIndex的字形的逻辑边界。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数 - 另请参见:
-
getGlyphVisualBounds(int)
-
getGlyphVisualBounds
public abstract Shape getGlyphVisualBounds(int glyphIndex)
返回GlyphVector指定字形的视觉边界。 此方法返回的边界位于每个单个字形的原点周围。- 参数
-
glyphIndex- 对应于从其中检索其视觉边界的字形的此GlyphVector中的索引 - 结果
-
一个
Shape这是在指定的glyphIndex的字形的视觉边界。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数 - 另请参见:
-
getGlyphLogicalBounds(int)
-
getGlyphPixelBounds
public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y)
当这个返回index字形的像素边界GlyphVector在渲染Graphics给定FontRenderContext在给定位置。 renderFRC不需要与此GlyphVector的FontRenderContext相同,并且可以为null。 如果为null,则使用该FontRenderContext的GlyphVector。 默认实现返回字形的视觉边界,偏移量为x,y,并舍入到下一个整数值,并忽略FRC。 子类应该覆盖此方法。- 参数
-
index- 字形的索引。 -
renderFRC-FontRenderContext的Graphics。 -
x- 要呈现这个GlyphVector的X位置。 -
y- 要渲染这个GlyphVector的Y位置。 - 结果
-
一个
Rectangle限制将受影响的像素。 - 从以下版本开始:
- 1.4
-
getGlyphMetrics
public abstract GlyphMetrics getGlyphMetrics(int glyphIndex)
将指定索引中的字形的度量返回到此GlyphVector。- 参数
-
glyphIndex- 这个GlyphVector的索引对应于从中检索其指标的字形 - 结果
-
一个
GlyphMetrics对象,表示字形的在指定的指标glyphIndex到此GlyphVector。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数
-
getGlyphJustificationInfo
public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex)
将指定索引中的字形的对齐信息返回到此GlyphVector。- 参数
-
glyphIndex- 这个GlyphVector中的索引对应于从中检索其对齐属性的字形 - 结果
-
一个
GlyphJustificationInfo对象,表示字形的在指定的调整属性glyphIndex到此GlyphVector。 - 异常
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于或等于此GlyphVector的字形数
-
equals
public abstract boolean equals(GlyphVector set)
测试指定的GlyphVector完全等于此GlyphVector。- 参数
-
set- 指定的GlyphVector进行测试 - 结果
-
true如果指定的GlyphVector等于这个GlyphVector; 否则为false。
-
-