- java.lang.Object
-
- java.awt.font.GraphicAttribute
-
- 已知直接子类:
-
ImageGraphicAttribute,ShapeGraphicAttribute
public abstract class GraphicAttribute extends Object
该类与CHAR_REPLACEMENT属性一起使用。GraphicAttribute类代表嵌入文本的图形。 客户端子类实现自己的char替换图形。 希望在文本中嵌入形状和图像的客户不需要对这个类进行子类化。 相反,客户端可以使用ShapeGraphicAttribute和ImageGraphicAttribute类。子类必须确保它们的对象在构造后是不可变的。 在
GraphicAttribute中使用的突变GraphicAttribute会导致来自TextLayout未定义行为。
-
-
Field Summary
Fields Modifier and Type Field 描述 static intBOTTOM_ALIGNMENT将图形底部对齐到底部。static intCENTER_BASELINE将图形的起点与线的中心基线对齐。static intHANGING_BASELINE将图形的起点与线的垂直基线对齐。static intROMAN_BASELINE将图形的起点与罗马线的基线对齐。static intTOP_ALIGNMENT将图形顶部与顶部对齐。
-
构造方法摘要
构造方法 Modifier Constructor 描述 protectedGraphicAttribute(int alignment)构造一个GraphicAttribute。
-
方法摘要
所有方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 abstract voiddraw(Graphics2D graphics, float x, float y)在指定的位置渲染此GraphicAttribute。abstract floatgetAdvance()返回这个GraphicAttribute。intgetAlignment()返回这个GraphicAttribute的对齐方式。abstract floatgetAscent()返回此GraphicAttribute的上升。Rectangle2DgetBounds()返回一个Rectangle2D,它包含相对于渲染位置由此GraphicAttribute绘制的所有位。abstract floatgetDescent()返回此GraphicAttribute的下降。GlyphJustificationInfogetJustificationInfo()返回此GraphicAttribute的对齐信息。ShapegetOutline(AffineTransform tx)返回一个Shape,表示该区域GraphicAttribute呈现。
-
-
-
字段详细信息
-
TOP_ALIGNMENT
public static final int TOP_ALIGNMENT
将图形顶部与顶部对齐。- 另请参见:
- Constant Field Values
-
BOTTOM_ALIGNMENT
public static final int BOTTOM_ALIGNMENT
将图形底部对齐到底部。- 另请参见:
- Constant Field Values
-
ROMAN_BASELINE
public static final int ROMAN_BASELINE
将图形的起点与罗马线的基线对齐。- 另请参见:
- Constant Field Values
-
CENTER_BASELINE
public static final int CENTER_BASELINE
将图形的起点与线的中心基线对齐。- 另请参见:
- Constant Field Values
-
HANGING_BASELINE
public static final int HANGING_BASELINE
将图形的起点与线的垂直基线对齐。- 另请参见:
- Constant Field Values
-
-
构造方法详细信息
-
GraphicAttribute
protected GraphicAttribute(int alignment)
构造一个GraphicAttribute。 子类使用它来定义图形的对齐方式。- 参数
-
alignment- 表示GraphicAttribute对齐字段之一的int - 异常
-
IllegalArgumentException- 如果对齐不是五个定义值之一。
-
-
方法详细信息
-
getAscent
public abstract float getAscent()
返回此GraphicAttribute的上升。 图形可以在其上方呈现。- 结果
-
这个
GraphicAttribute的上升。 - 另请参见:
-
getBounds()
-
getDescent
public abstract float getDescent()
返回此GraphicAttribute的下降。 图形可以在其下降之下呈现。- 结果
-
这个
GraphicAttribute的下降。 - 另请参见:
-
getBounds()
-
getAdvance
public abstract float getAdvance()
返回此GraphicAttribute。GraphicAttribute对象的进步是从图形渲染点开始的距离以及渲染下一个字符或图形的点。 一个图形可以超越它的进步- 结果
-
这个进步
GraphicAttribute。 - 另请参见:
-
getBounds()
-
getBounds
public Rectangle2D getBounds()
返回一个Rectangle2D,它包含了相对于渲染位置的GraphicAttribute绘制的所有位。 图形可能会超出其起源,上升,下降或提前; 但是如果是,则该方法的实现必须指示图形的呈现位置。 默认边界是矩形(0,-ascent,advance,ascent + descent)。- 结果
-
一个
Rectangle2D,它包含了这个GraphicAttribute呈现的所有位。
-
getOutline
public Shape getOutline(AffineTransform tx)
返回一个Shape,表示该区域GraphicAttribute呈现。 当请求TextLayout返回文本的大纲时使用。 (未变形)的形状不得超出由getBounds返回的矩形界限getBounds。 默认实现返回getBounds()返回的矩形,由提供的AffineTransform(如果存在)转换。- 参数
-
tx- 可选的AffineTransform以应用于此GraphicAttribute的大纲。 这可以是null。 - 结果
-
一个
Shape代表这种图形属性,适合于抚摸或填充。 - 从以下版本开始:
- 1.6
-
draw
public abstract void draw(Graphics2D graphics, float x, float y)
在指定的位置渲染此GraphicAttribute。- 参数
-
graphics- 用于呈现图形的Graphics2D -
x- 呈现图形的用户空间X坐标 -
y- 图形呈现的用户空间Y坐标
-
getAlignment
public final int getAlignment()
返回GraphicAttribute的对齐方式。 对齐可以是一个特定的基线,也可以是一行的绝对顶部或底部。- 结果
-
对齐这个
GraphicAttribute。
-
getJustificationInfo
public GlyphJustificationInfo getJustificationInfo()
返回此GraphicAttribute的对齐信息。 子类可以覆盖此方法以提供不同的对齐信息。- 结果
-
一个
GlyphJustificationInfo对象,其中包含此GraphicAttribute的对齐信息。
-
-