JavaTM 2 Platform
Standard Ed. 6

java.awt.font
类 GraphicAttribute

java.lang.Object
  继承者 java.awt.font.GraphicAttribute
直接已知子类:
ImageGraphicAttribute, ShapeGraphicAttribute

public abstract class GraphicAttribute
extends Object

此类与 CHAR_REPLACEMENT 属性一起使用。

GraphicAttribute 类表示文本中内嵌的图形。客户端创建此类的子类,以实现其自身的 char 替换图形。要在文本中嵌入形状和图像的客户端不必创建此类的子类。相反,客户端可以使用 ShapeGraphicAttributeImageGraphicAttribute 类。

子类必须确保对象一经构造就不可修改。该变 TextLayout 中使用的 GraphicAttribute 会导致 TextLayout 的不确定行为。


字段摘要
static int BOTTOM_ALIGNMENT
          将图形底部与行的底部对齐。
static int CENTER_BASELINE
          将图形的原点与行的中心基线对齐。
static int HANGING_BASELINE
          将图形的原点与行的悬挂基线对齐。
static int ROMAN_BASELINE
          将图形的原点与行的罗马字体基线对齐。
static int TOP_ALIGNMENT
          将图形顶端与行的顶端对齐。
 
构造方法摘要
protected GraphicAttribute(int alignment)
          构造一个 GraphicAttribute
 
方法摘要
abstract  void draw(Graphics2D graphics, float x, float y)
          在指定的位置呈现此 GraphicAttribute
abstract  float getAdvance()
          返回此 GraphicAttribute 的 advance。
 int getAlignment()
          返回此 GraphicAttribute 的对齐方式。
abstract  float getAscent()
          返回此 GraphicAttribute 的 ascent。
 Rectangle2D getBounds()
          返回包括所有位的 Rectangle2D,这些位由与呈现位置相关的 GraphicAttribute 绘制。
abstract  float getDescent()
          返回此 GraphicAttribute 的 descent。
 GlyphJustificationInfo getJustificationInfo()
          返回此 GraphicAttribute 的调整信息。
 Shape getOutline(AffineTransform tx)
          返回表示此 GraphicAttribute 呈现区域的 Shape
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

TOP_ALIGNMENT

public static final int TOP_ALIGNMENT
将图形顶端与行的顶端对齐。

另请参见:
常量字段值

BOTTOM_ALIGNMENT

public static final int BOTTOM_ALIGNMENT
将图形底部与行的底部对齐。

另请参见:
常量字段值

ROMAN_BASELINE

public static final int ROMAN_BASELINE
将图形的原点与行的罗马字体基线对齐。

另请参见:
常量字段值

CENTER_BASELINE

public static final int CENTER_BASELINE
将图形的原点与行的中心基线对齐。

另请参见:
常量字段值

HANGING_BASELINE

public static final int HANGING_BASELINE
将图形的原点与行的悬挂基线对齐。

另请参见:
常量字段值
构造方法详细信息

GraphicAttribute

protected GraphicAttribute(int alignment)
构造一个 GraphicAttribute。子类使用此构造方法来定义图形的对齐方式。

参数:
alignment - 表示某个 GraphicAttribute 对齐字段的 int 值。
方法详细信息

getAscent

public abstract float getAscent()
返回此 GraphicAttribute 的 ascent。图形可以在其 ascent 之上呈现。

返回:
GraphicAttribute 的 ascent。
另请参见:
getBounds()

getDescent

public abstract float getDescent()
返回此 GraphicAttribute 的 descent。图形可以在其 descent 之下呈现。

返回:
GraphicAttribute 的 descent。
另请参见:
getBounds()

getAdvance

public abstract float getAdvance()
返回此 GraphicAttribute 的 advance。GraphicAttribute 对象的 advance 是呈现该图形的点与呈现下一个字符或图形的点之间的距离。图形可以呈现在其 advance 之外。

返回:
GraphicAttribute 的 advance。
另请参见:
getBounds()

getBounds

public Rectangle2D getBounds()
返回包括所有位的 Rectangle2D,这些位由与呈现位置相关的 GraphicAttribute 绘制。图形可以在其原点、ascent、descent 和 advance 之外呈现;但是如果这样的话,此方法的实现必须指示呈现该图形的位置。默认的边界是矩形 (0, -ascent, advance, ascent+descent)。

返回:
包括由此 GraphicAttribute 呈现的所有位的 Rectangle2D

getOutline

public Shape getOutline(AffineTransform tx)
返回表示此 GraphicAttribute 呈现区域的 Shape。当请求 TextLayout 返回文本轮廓时,将使用此方法。(未变换的)Shape 不得超出 getBounds 返回的矩形边界。 默认实现将返回由 getBounds() 返回,并通过提供的 AffineTransform(如果有)变换得到的矩形。

参数:
tx - 要应用到此 GraphicAttribute 轮廓的可选 AffineTransform。此参数可以为 null。
返回:
.表示此图形属性的 Shape,适用于勾画或填充。
从以下版本开始:
1.6

draw

public abstract void draw(Graphics2D graphics,
                          float x,
                          float y)
在指定的位置呈现此 GraphicAttribute

参数:
graphics - 将该图形呈现到的 Graphics2D
x, y - 呈现该图形的用户空间坐标

getAlignment

public final int getAlignment()
返回此 GraphicAttribute 的对齐方式。可与特定的基线对齐,或与行的绝对顶端或底端对齐。

返回:
GraphicAttribute 的对齐方式。

getJustificationInfo

public GlyphJustificationInfo getJustificationInfo()
返回此 GraphicAttribute 的调整信息。子类可以重写此方法,以提供不同的调整信息。

返回:
包含此 GraphicAttribute 调整信息的 GlyphJustificationInfo 对象。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only