public final class TextLayout extends Object implements Cloneable
TextLayout
是风格的字符数据不变的图形表示。
它提供了以下功能:
一个TextLayout
对象可以使用其draw
方法呈现。
TextLayout
可以直接或通过一个LineBreakMeasurer
建成使用。当直接构造时,源文本表示一个单独的段落。LineBreakMeasurer
允许样式文本被分解成适合特定宽度内的线。更多信息参见LineBreakMeasurer
文档。
TextLayout
建设逻辑过程如下:
TextAttribute.FONT
是目前使用的字体,否则通过计算一个默认字体使用已定义的属性从TextLayout
对象的方法返回的所有图形信息是相对的TextLayout
的起源,这是与它的左边缘的TextLayout
对象的基线相交。同时,坐标传递到TextLayout
对象的方法被认为是相对于TextLayout
物体的起源。客户通常需要翻译TextLayout
对象的坐标系统和坐标系统之间的另一个对象(如一个Graphics
对象)。
TextLayout
对象被构造样式的文本,但他们没有一个参考源文本保留。因此,在以前用来生成一个TextLayout
文本的变化不影响TextLayout
。
三种方法在TextLayout
对象(getNextRightHit
,getNextLeftHit
,和hitTestChar
)的TextHitInfo
返回实例。在这些TextHitInfo
对象中的偏移量是相对的TextLayout
开始,不用于创建TextLayout
文本。同样,TextLayout
方法接受TextHitInfo
实例作为参数的期望TextHitInfo
对象的偏移量是相对的TextLayout
,没有任何潜在的文本存储模型。
实例:
构建和绘制TextLayout
及其边框:
Graphics2D g = ...; Point2D loc = ...; Font font = Font.getFont("Helvetica-bold-italic"); FontRenderContext frc = g.getFontRenderContext(); TextLayout layout = new TextLayout("This is a string", font, frc); layout.draw(g, (float)loc.getX(), (float)loc.getY()); Rectangle2D bounds = layout.getBounds(); bounds.setRect(bounds.getX()+loc.getX(), bounds.getY()+loc.getY(), bounds.getWidth(), bounds.getHeight()); g.draw(bounds);
命中测试TextLayout
(确定哪些特征是在一个特定的图形位置):
Point2D click = ...; TextHitInfo hit = layout.hitTestChar( (float) (click.getX() - loc.getX()), (float) (click.getY() - loc.getY()));
响应右箭头键:
int insertionIndex = ...; TextHitInfo next = layout.getNextRightHit(insertionIndex); if (next != null) { // translate graphics to origin of layout on screen g.translate(loc.getX(), loc.getY()); Shape[] carets = layout.getCaretShapes(next.getInsertionIndex()); g.draw(carets[0]); if (carets[1] != null) { g.draw(carets[1]); } }
图中对应于源文本字符串的选择范围。选定区域可能无法在视觉上连续:
// selStart, selLimit should be relative to the layout, // not to the source text int selStart = ..., selLimit = ...; Color selectionColor = ...; Shape selection = layout.getLogicalHighlightShape(selStart, selLimit); // selection may consist of disjoint areas // graphics is assumed to be tranlated to origin of layout g.setColor(selectionColor); g.fill(selection);
绘制一个视觉上连续的选择范围。选择范围可以对应于原文中的一个以上的子串。相应的源文本子字符串的范围可以得到getLogicalRangesForVisualSelection()
:
注:字体的旋转可以使文本基线进行旋转,并与不同的旋转多个运行会导致基线弯曲或曲折。为了解释这个(罕见)的可能性,一些API返回指定指标和基线相对坐标带参数”(如提升、推进),和其他人在“标准坐标(例如getBounds)。在基线相对坐标图的值的“X”坐标沿基线的距离,(正X向前沿基线),和“Y”坐标到垂直于基线的距离在“X”(正Y是从基线向量顺时针方向90度)。在标准坐标值沿X轴和Y轴的测量,在用0、起源。为每个相关的接口的文档表示什么值是在什么坐标系统。在一般情况下,测量相关的原料药是在基线的相对坐标,而显示相关的原料药在标准的坐标。
Modifier and Type | Class and Description |
---|---|
static class |
TextLayout.CaretPolicy
定义了一个确定的强符号定位策略。
|
Modifier and Type | Field and Description |
---|---|
static TextLayout.CaretPolicy |
DEFAULT_CARET_POLICY
这
CaretPolicy 时使用的政策不是由客户指定。
|
Constructor and Description |
---|
TextLayout(AttributedCharacterIterator text, FontRenderContext frc)
构建从样式文本迭代器的一个
TextLayout 。
|
TextLayout(String string, Font font, FontRenderContext frc)
|
TextLayout(String string, Map<? extends AttributedCharacterIterator.Attribute,?> attributes, FontRenderContext frc)
构建了从
String 和一个属性
TextLayout 集。
|
Modifier and Type | Method and Description |
---|---|
protected Object |
clone()
复制这
TextLayout 。
|
void |
draw(Graphics2D g2, float x, float y)
这
TextLayout 呈现在指定的
Graphics2D 上下文指定位置。
|
boolean |
equals(Object obj)
返回
true 如果指定
Object 是
TextLayout 对象,如果指定的
Object 等于这
TextLayout 。
|
boolean |
equals(TextLayout rhs)
返回
true 如果两种布局都是平等的。
|
float |
getAdvance()
返回该
TextLayout 前进。
|
float |
getAscent()
返回该
TextLayout 上升。
|
byte |
getBaseline()
返回此
TextLayout 基线。
|
float[] |
getBaselineOffsets()
返回用于此
TextLayout 基线偏移阵列。
|
Shape |
getBlackBoxBounds(int firstEndpoint, int secondEndpoint)
返回指定范围内的字符的黑框范围。
|
Rectangle2D |
getBounds()
返回该
TextLayout 界限。
|
float[] |
getCaretInfo(TextHitInfo hit)
返回对应于
hit 插入符号信息。
|
float[] |
getCaretInfo(TextHitInfo hit, Rectangle2D bounds)
返回对应于
hit 插入符号信息。
|
Shape |
getCaretShape(TextHitInfo hit)
返回一个
Shape 代表在指定的打在这
TextLayout 自然界的符号。
|
Shape |
getCaretShape(TextHitInfo hit, Rectangle2D bounds)
返回一个
Shape 代表在指定的打在指定边界的符号。
|
Shape[] |
getCaretShapes(int offset)
返回两个路径对应的强与弱符号。
|
Shape[] |
getCaretShapes(int offset, Rectangle2D bounds)
返回两个路径对应的强与弱符号。
|
Shape[] |
getCaretShapes(int offset, Rectangle2D bounds, TextLayout.CaretPolicy policy)
返回两个路径对应的强与弱符号。
|
int |
getCharacterCount()
这
TextLayout 表示返回的字符数。
|
byte |
getCharacterLevel(int index)
返回
index 字符的水平。
|
float |
getDescent()
返回该
TextLayout 下降。
|
TextLayout |
getJustifiedLayout(float justificationWidth)
复制这
TextLayout 对齐到指定的宽度。
|
LayoutPath |
getLayoutPath()
返回layoutpath,或null如果布局路径,默认路径(X图前进,Y图偏移)。
|
float |
getLeading()
返回的
TextLayout 领先。
|
Shape |
getLogicalHighlightShape(int firstEndpoint, int secondEndpoint)
返回一个
Shape 外围逻辑选择在规定的范围内,延伸到这
TextLayout 自然界限。
|
Shape |
getLogicalHighlightShape(int firstEndpoint, int secondEndpoint, Rectangle2D bounds)
返回一个
Shape 外围逻辑选择在规定的范围内,扩展到指定的
bounds 。
|
int[] |
getLogicalRangesForVisualSelection(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint)
返回对应于一个视觉选择的文本的逻辑范围。
|
TextHitInfo |
getNextLeftHit(int offset)
返回到左下插入命中(上);如果没有这样的打击,返回
null 。
|
TextHitInfo |
getNextLeftHit(int offset, TextLayout.CaretPolicy policy)
返回到左下插入命中(上);如果没有这样的打击,返回
null 。
|
TextHitInfo |
getNextLeftHit(TextHitInfo hit)
返回到左下插入命中(上);如果没有这样的打击,返回
null 。
|
TextHitInfo |
getNextRightHit(int offset)
返回到正确的下一个符号的命中(底部);如果没有这样的打击,返回
null 。
|
TextHitInfo |
getNextRightHit(int offset, TextLayout.CaretPolicy policy)
返回到正确的下一个符号的命中(底部);如果没有这样的打击,返回
null 。
|
TextHitInfo |
getNextRightHit(TextHitInfo hit)
返回到正确的下一个符号的命中(底部);如果没有这样的打击,返回
null 。
|
Shape |
getOutline(AffineTransform tx)
返回一个
Shape 表示此
TextLayout 概述。
|
Rectangle |
getPixelBounds(FontRenderContext frc, float x, float y)
返回该
TextLayout 像素边界时,呈现在一个给定
FontRenderContext 在给定位置的图形。
|
float |
getVisibleAdvance()
返回该
TextLayout 前进,减去尾随空格。
|
Shape |
getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint)
返回一个
Shape 内附视觉选择在指定的范围,扩展到边界。
|
Shape |
getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint, Rectangle2D bounds)
返回一个路径包围的视觉选择指定的范围,扩展到
bounds 。
|
TextHitInfo |
getVisualOtherHit(TextHitInfo hit)
返回在指定的符号打对方打。
|
protected void |
handleJustify(float justificationWidth)
证明此布局。
|
int |
hashCode()
返回该
TextLayout 哈希代码。
|
TextHitInfo |
hitTestChar(float x, float y)
返回对应于指定点
TextHitInfo 。
|
TextHitInfo |
hitTestChar(float x, float y, Rectangle2D bounds)
返回对应于指定点
TextHitInfo 。
|
void |
hitToPoint(TextHitInfo hit, Point2D point)
在标准坐标中转换一个命中到一个点。
|
boolean |
isLeftToRight()
返回
true 如果这
TextLayout 有左到右库方向或
false 如果有权离开基地的方向。
|
boolean |
isVertical()
返回
true 如果这
TextLayout 垂直。
|
String |
toString()
返回此
TextLayout 调试信息。
|
public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY
CaretPolicy
时使用的政策不是由客户指定。根据这项政策,一个字符的方向为直线方向比在counterdirectional性格强相同的命中命中。如果字符的方向是相同的,一个字符的前缘上的命中强于一个字符的后缘上的命中。
public TextLayout(String string, Font font, FontRenderContext frc)
string
-显示文本
font
-用来将文本样式
Font
frc
-包含一个图形设备,需要正确衡量文本信息。文本的测量可以略有不同的设备分辨率不同,属性如抗锯齿。此参数没有指定
TextLayout
和用户空间之间的翻译。
public TextLayout(String string, Map<? extends AttributedCharacterIterator.Attribute,?> attributes, FontRenderContext frc)
String
和一个属性
TextLayout
集。
所有的文本都使用提供的属性样式。
string
必须指定一段文字因为整个段落是双向算法要求。
string
-显示文本
attributes
-属性用于将文本样式
frc
-包含一个图形设备,需要正确衡量文本信息。文本的测量可以略有不同的设备分辨率不同,属性如抗锯齿。此参数没有指定
TextLayout
和用户空间之间的翻译。
public TextLayout(AttributedCharacterIterator text, FontRenderContext frc)
TextLayout
。
迭代器必须指定一个单独的文本段落,因为双向算法需要一个完整的段落。
text
的样式显示文本
frc
-包含一个图形设备,需要正确衡量文本信息。文本的测量可以略有不同的设备分辨率不同,属性如抗锯齿。此参数没有指定
TextLayout
和用户空间之间的翻译。
protected Object clone()
TextLayout
。
public TextLayout getJustifiedLayout(float justificationWidth)
TextLayout
对齐到指定的宽度。
如果这TextLayout
已经证明,抛出一个异常。如果这TextLayout
对象的调整率为零,这一TextLayout
TextLayout
相同的返回。
justificationWidth
-宽度时使用的线的理由。为了最好的结果,它不应该太不同于当前的线的进展。
TextLayout
对齐到指定的宽度。
Error
如果布局已经合理,抛出一个错误。
protected void handleJustify(float justificationWidth)
一些代码可以依靠immutablity布局。subclassers不应该称之为直接,而是应该叫getjustifiedlayout,将调用此方法在这个布局的一个克隆,保留了原有的。
justificationWidth
-宽度时使用的线的理由。为了最好的结果,它不应该太不同于当前的线的进展。
getJustifiedLayout(float)
public byte getBaseline()
TextLayout
基线。基线是一个在
Font
定义的值,这是罗马,心挂。上升和下降是相对于基线。的
baselineOffsets
也相对于基线。
TextLayout
基线。
getBaselineOffsets()
,
Font
public float[] getBaselineOffsets()
TextLayout
基线偏移阵列。
数组中的一Font
定义的值的索引,这是罗马,心挂。该值是相对于这TextLayout
对象的基线,使getBaselineOffsets[getBaseline()] == 0
。偏移量是增加了TextLayout
对象的基线位置为新的基线得到的位置。
TextLayout
基线偏移阵列。
getBaseline()
,
Font
public float getAdvance()
TextLayout
前进。提前从起源到最右边的前进的距离(下面的)特征。这是在基线的相对坐标。
TextLayout
前进。
public float getVisibleAdvance()
TextLayout
前进,减去尾随空格。这是在基线的相对坐标。
TextLayout
尾随空格的进展。
getAdvance()
public float getAscent()
TextLayout
提升。提升是从顶部的距离(右)的
TextLayout
底线。它总是要么是正的或零。提升足以容纳上标文本是对提升、偏移和最大,和每一个字形基线。提升是从、所有文本基线的最大提升。它是在基线的相对坐标。
TextLayout
上升。
public float getDescent()
TextLayout
下降。下降是从基线到底的距离(左)的
TextLayout
。它总是要么是正的或零。的下降足以容纳下标文本是的血统,和最大偏移量,和每一个字形基线。这是从在、所有文本基线的最大下降。它是在基线的相对坐标。
TextLayout
下降。
public float getLeading()
TextLayout
领导。领导是建议行间这
TextLayout
间距。这是在基线的相对坐标。
主要是从领导、血统和基线计算,在TextLayout
所有glyphvectors算法大致如下:
maxD = 0; maxDL = 0; for (GlyphVector g in all glyphvectors) { maxD = max(maxD, g.getDescent() + offsets[g.getBaseline()]); maxDL = max(maxDL, g.getDescent() + g.getLeading() + offsets[g.getBaseline()]); } return maxDL - maxD;
TextLayout
领先。
public Rectangle2D getBounds()
TextLayout
边界。边界是标准坐标。
由于光栅化的影响,这个范围可能不把所有的、渲染的像素。
它可能无法与上升、下降完全一致,TextLayout
的起源或提前。
Rectangle2D
是这个
TextLayout
界限。
public Rectangle getPixelBounds(FontRenderContext frc, float x, float y)
TextLayout
像素边界时,呈现在一个给定
FontRenderContext
在给定位置的图形。图形渲染上下文可以用来创建这个
TextLayout
的
FontRenderContext
相同,并可以为空。如果它是空的,这
TextLayout
的
FontRenderContext
使用。
frc
的
Graphics
的
FontRenderContext
。
x
-位置的x坐标渲染这
TextLayout
。
y
-在纵坐标绘制这
TextLayout
。
Rectangle
包围的像素会有影响。
GlyphVector.getPixelBounds(java.awt.font.FontRenderContext, float, float)
public boolean isLeftToRight()
true
如果这
TextLayout
有左到右库方向或
false
如果有权离开基地的方向。的
TextLayout
有离开基地方向向右(LTR)或右至左(RTL)。基本方向是独立的文本行的实际方向,这可能是LTR,RTL,或混合。左到右布局默认应位置刷新左。如果布局是一个标签,标签从左到右,所以逻辑上连续的布局位置从左到右。RTL布局相反的是真实的。默认情况下,他们应该位置刷新左,标签右向左运行。
true
如果这
TextLayout
的基本方向是由左至右;
false
否则。
public boolean isVertical()
true
如果这
TextLayout
垂直。
true
TextLayout
垂直;
false
否则。
public int getCharacterCount()
TextLayout
表示返回的字符数。
TextLayout
字符数。
public float[] getCaretInfo(TextHitInfo hit, Rectangle2D bounds)
hit
插入信息。该数组的第一个元素是与基准符号的交叉口,沿基线的距离。数组的第二个元素是逆坡(运行/升)的符号,在这一点上的基线测定。
此方法是用于信息的使用。显示插入符,它是更好地使用getCaretShapes
。
hit
于这个
TextLayout
字符击中
bounds
的界限,构建了符号信息。边界是在基线的相对坐标。
getCaretShapes(int, Rectangle2D, TextLayout.CaretPolicy)
,
Font.getItalicAngle()
public float[] getCaretInfo(TextHitInfo hit)
hit
插入符号信息。该方法是一
getCaretInfo
方便超载和使用这
TextLayout
自然界限。
hit
于这个
TextLayout
字符击中
public TextHitInfo getNextRightHit(TextHitInfo hit)
null
。如果打字符索引越界,一个
IllegalArgumentException
抛出。
hit
于这个布局的性格打
null
插入符号。
public TextHitInfo getNextRightHit(int offset, TextLayout.CaretPolicy policy)
null
。命中是在指定的偏移量的强符号的权利,由指定的政策决定。返回的命中是强大的两个可能的命中,所确定的指定的政策。
offset
-插入抵消这
TextLayout
。不能小于0或大于
TextLayout
对象的字符数。
policy
-用于选择强符号的政策
null
。
public TextHitInfo getNextRightHit(int offset)
null
。命中是在指定的偏移量的强符号的权利,作为默认的政策决定。返回的命中是强大的两个可能的命中,所确定的默认策略。
offset
-插入抵消这
TextLayout
。不能小于0或大于
TextLayout
对象的字符数。
null
。
public TextHitInfo getNextLeftHit(TextHitInfo hit)
null
。如果打字符索引越界,一个
IllegalArgumentException
抛出。
hit
于这个
TextLayout
字符击中。
null
。
public TextHitInfo getNextLeftHit(int offset, TextLayout.CaretPolicy policy)
null
。命中是在指定的偏移量的强标记的左侧,由指定的政策决定。返回的命中是强大的两个可能的命中,所确定的指定的政策。
offset
-插入抵消这
TextLayout
。不能小于0或大于
TextLayout
对象的字符数。
policy
-用于选择强符号的政策
null
。
public TextHitInfo getNextLeftHit(int offset)
null
。命中是在指定的偏移量的强标记的左侧,作为默认的政策决定。返回的命中是强大的两个可能的命中,所确定的默认策略。
offset
-插入抵消这
TextLayout
。不能小于0或大于
TextLayout
对象的字符数。
null
。
public TextHitInfo getVisualOtherHit(TextHitInfo hit)
hit
-指定打击
public Shape getCaretShape(TextHitInfo hit, Rectangle2D bounds)
Shape
代表在指定的打在指定边界的符号。
hit
命中生成符号
bounds
的
TextLayout
使用生成符号的界限。边界是在基线的相对坐标。
Shape
代表符号。返回的形状是在标准坐标。
public Shape getCaretShape(TextHitInfo hit)
Shape
代表在指定的打在这
TextLayout
自然界的符号。
hit
命中生成符号
Shape
代表符号。返回的形状是在标准坐标。
public byte getCharacterLevel(int index)
index
字符的水平。指数1和
characterCount
分配这
TextLayout
基层。
index
-字符,得到水平指标
public Shape[] getCaretShapes(int offset, Rectangle2D bounds, TextLayout.CaretPolicy policy)
offset
-在这
TextLayout
偏移
bounds
的界限,延长克拉。边界是在基线的相对坐标。
policy
-指定
CaretPolicy
null
。返回的形状是在标准坐标系中的。
public Shape[] getCaretShapes(int offset, Rectangle2D bounds)
getCaretShapes
,使用默认的符号政策便利过载。
offset
-在这
TextLayout
偏移
bounds
的界限,延长克拉。这是在基线的相对坐标。
DEFAULT_CARET_POLICY
两路。这些都是在标准坐标系中。
public Shape[] getCaretShapes(int offset)
getCaretShapes
,使用默认的符号,这
TextLayout
政策对象的自然界限。
offset
-在这
TextLayout
偏移
DEFAULT_CARET_POLICY
两路。这些都是在标准坐标系中。
public int[] getLogicalRangesForVisualSelection(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint)
firstEndpoint
-视觉范围的一个端点
secondEndpoint
-视觉范围的其他端点。这个端点可以小于
firstEndpoint
。
getVisualHighlightShape(TextHitInfo, TextHitInfo, Rectangle2D)
public Shape getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint, Rectangle2D bounds)
bounds
。
如果选择包括最左边的(最高)的位置,选择延伸到左(上)的bounds
。如果选择包括最右边的(最低)的位置,选择延伸到右侧(底部)的界限。高度(垂直线的宽度)的选择一直延伸到bounds
。
虽然选择是连续的,逻辑上选定的文本可以不连续对混合方向的文本行。选定文本的逻辑范围可以检索使用getLogicalRangesForVisualSelection
。例如,考虑文本“ABCDEF”,大写字母从右向左的文本,在右至左线渲染,从0可视化选择(前缘')3T(“D”的后缘)。文本显示如下,以大胆的下划线代表选择方面:
defcba逻辑的选择范围是0-3,4-6(ABC,EF)因为视觉连续的文本在逻辑上是不连续的。还注意到,从布局上右边的位置(右边的“A”)被选中,选择延伸边界的权利。
firstEndpoint
-视觉选择的一端
secondEndpoint
-视觉选择的另一端
bounds
的边框来扩展选择。这是在基线的相对坐标。
Shape
包围的选择。这是在标准坐标。
getLogicalRangesForVisualSelection(TextHitInfo, TextHitInfo)
,
getLogicalHighlightShape(int, int, Rectangle2D)
public Shape getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint)
Shape
内附视觉选择在指定的范围,扩展到边界。该方法是一
getVisualHighlightShape
使用这
TextLayout
自然界方便过载。
firstEndpoint
-视觉选择的一端
secondEndpoint
-视觉选择的另一端
Shape
包围的选择。这是在标准坐标。
public Shape getLogicalHighlightShape(int firstEndpoint, int secondEndpoint, Rectangle2D bounds)
Shape
外围逻辑选择在规定的范围内,扩展到指定的
bounds
。
如果选择范围包括第一逻辑特征,选择扩展到bounds
部分在这TextLayout
开始。如果范围包括最后的逻辑特征,选择扩展到bounds
部分这TextLayout
结束后。高度(垂直线的宽度)的选择一直延伸到bounds
。
选择可以不连续对混合方向的文本行。只有在开始和极限之间的逻辑范围内的这些字符出现选择。例如,考虑文本“ABCDEF”,大写字母从右向左的文本,在右至左线呈现,一个合乎逻辑的选择从0到4('abcd”)。文本显示如下,以大胆的站在为选择,并强调:
延伸
Def中国男子篮球职业联赛选择不连续的因为所选字符视觉不连续。还注意到,由于范围包括第一逻辑特征(一),选择扩展到部分的
bounds
之前就开始布局,在这种情况下,(右至左线)的
bounds
的右边部分。
firstEndpoint
在字符范围端点选择
secondEndpoint
-汉字的范围选择的另一个端点。可比
firstEndpoint
。范围包括最小字符(firstendpoint,secondendpoint),但不包括最大(firstendpoint,secondendpoint)。
bounds
的边框来扩展选择。这是在基线的相对坐标。
getVisualHighlightShape(TextHitInfo, TextHitInfo, Rectangle2D)
public Shape getLogicalHighlightShape(int firstEndpoint, int secondEndpoint)
Shape
外围逻辑选择在规定的范围内,延伸到这
TextLayout
自然界限。该方法是一
getLogicalHighlightShape
使用这
TextLayout
自然界方便过载。
firstEndpoint
在字符范围端点选择
secondEndpoint
-汉字的范围选择的另一个端点。可比
firstEndpoint
。范围包括在最小的字符(firstendpoint,secondendpoint),但不包括最大(firstendpoint,secondendpoint)。
Shape
包围的选择。这是在标准坐标。
public Shape getBlackBoxBounds(int firstEndpoint, int secondEndpoint)
firstEndpoint
-字符范围的一端
secondEndpoint
-字符范围的另一端。可比
firstEndpoint
。
Shape
封闭黑盒的界限。这是在标准坐标。
public TextHitInfo hitTestChar(float x, float y, Rectangle2D bounds)
TextHitInfo
。坐标以外的
TextLayout
Map范围,点击第一个逻辑字符的前缘或后缘,最后的逻辑特征,适当的,无论该字符的位置线。只有沿着基线的方向是用来做这个评价。
x
- X偏离这
TextLayout
起源。这是在标准坐标。
y
- y的偏移量从本
TextLayout
起源。这是在标准坐标。
bounds
的
TextLayout
界限。这是在基线的相对坐标。
public TextHitInfo hitTestChar(float x, float y)
TextHitInfo
。该方法是一
hitTestChar
使用这
TextLayout
自然界方便过载。
x
- X偏离这
TextLayout
起源。这是在标准坐标。
y
- y的偏移量从本
TextLayout
起源。这是在标准坐标。
public int hashCode()
TextLayout
哈希代码。
hashCode
方法重写,继承类
Object
TextLayout
哈希代码。
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public boolean equals(Object obj)
true
如果指定
Object
是
TextLayout
对象,如果指定的
Object
等于这
TextLayout
。
equals
方法重写,继承类
Object
obj
-
Object
测试平等
true
如果指定
Object
等于这
TextLayout
;
false
否则。
Object.hashCode()
,
HashMap
public boolean equals(TextLayout rhs)
true
如果两种布局都是平等的。如果它们包含在同一阶等glyphvectors布局等。
rhs
-
TextLayout
相比这
TextLayout
true
如果指定
TextLayout
等于这
TextLayout
。
public String toString()
TextLayout
调试信息。
public void draw(Graphics2D g2, float x, float y)
g2
-
Graphics2D
语境,使布局
x
-这
TextLayout
原点的X坐标
y
-这
TextLayout
起源的Y坐标
getBounds()
public Shape getOutline(AffineTransform tx)
Shape
表示此
TextLayout
概述。
tx
可选
AffineTransform
申请这个
TextLayout
概述。
Shape
是这个
TextLayout
轮廓。这是在标准坐标系。
public LayoutPath getLayoutPath()
public void hitToPoint(TextHitInfo hit, Point2D point)
hit
-检查打。这必须是一个有效的打击、。
point
-返回点。点在标准坐标系中。
IllegalArgumentException
如果击中无效、。
NullPointerException
如果击中或是空的。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.