JavaTM 2 Platform
Standard Ed. 5.0

java.awt.font
类 ShapeGraphicAttribute

java.lang.Object
  继承者 java.awt.font.GraphicAttribute
      继承者 java.awt.font.ShapeGraphicAttribute

public final class ShapeGraphicAttribute
extends GraphicAttribute

ShapeGraphicAttribute 类是在 TextLayout 中绘制形状的 GraphicAttribute 的实现。

另请参见:
GraphicAttribute

字段摘要
static boolean FILL
          指示应填充该形状的键。
static boolean STROKE
          指示该形状应使用 1 像素宽的笔画进行勾画的键。
 
从类 java.awt.font.GraphicAttribute 继承的字段
BOTTOM_ALIGNMENT, CENTER_BASELINE, HANGING_BASELINE, ROMAN_BASELINE, TOP_ALIGNMENT
 
构造方法摘要
ShapeGraphicAttribute(Shape shape, int alignment, boolean stroke)
          为指定的 Shape 构造 ShapeGraphicAttribute
 
方法摘要
 void draw(Graphics2D graphics, float x, float y)
          在给定的位置绘制该图形。
 boolean equals(Object rhs)
          将此 ShapeGraphicAttribute 与指定的 Object 进行比较。
 boolean equals(ShapeGraphicAttribute rhs)
          将此 ShapeGraphicAttribute 与指定的 ShapeGraphicAttribute 进行比较。
 float getAdvance()
          返回此 ShapeGraphicAttribute 的 advance。
 float getAscent()
          返回此 ShapeGraphicAttribute 的 ascent。
 Rectangle2D getBounds()
          返回一个 Rectangle2D,它包围了由此 ShapeGraphicAttribute 相对于呈现位置所绘制的所有位。
 float getDescent()
          返回此 ShapeGraphicAttribute 的 descent。
 int hashCode()
          返回此 ShapeGraphicAttribute 的哈希码。
 
从类 java.awt.font.GraphicAttribute 继承的方法
getAlignment, getJustificationInfo
 
从类 java.lang.Object 继承的方法
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

STROKE

public static final boolean STROKE
指示该形状应使用 1 像素宽的笔画进行勾画的键。

另请参见:
常量字段值

FILL

public static final boolean FILL
指示应填充该形状的键。

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

ShapeGraphicAttribute

public ShapeGraphicAttribute(Shape shape,
                             int alignment,
                             boolean stroke)
为指定的 Shape 构造 ShapeGraphicAttribute

参数:
shape - 要呈现的 Shape。呈现此 Shape,其原点在宿主 TextLayout 中的此 ShapeGraphicAttribute 的原点位置。此对象维护对 shape 的引用。
alignment - 此 ShapeGraphicAttribute 的对齐方式之一。
stroke - 如果要对 Shape 描边,则为 true;如果要填充 Shape,则为 false
方法详细信息

getAscent

public float getAscent()
返回此 ShapeGraphicAttribute 的 ascent。ShapeGraphicAttribute 的 ascent 是从其 Shape 的原点到其 Shape 边界顶端的绝对距离。

指定者:
GraphicAttribute 中的 getAscent
返回:
ShapeGraphicAttribute 的 ascent。
另请参见:
GraphicAttribute.getBounds()

getDescent

public float getDescent()
返回此 ShapeGraphicAttribute 的 descent。ShapeGraphicAttribute 的 descent 是从其 Shape 的原点到其 Shape 边界底部的距离。

指定者:
GraphicAttribute 中的 getDescent
返回:
ShapeGraphicAttribute 的 descent。
另请参见:
GraphicAttribute.getBounds()

getAdvance

public float getAdvance()
返回此 ShapeGraphicAttribute 的 advance。ShapeGraphicAttribute 的 advance 是从其 Shape 的原点到其 Shape 边界右侧的距离。

指定者:
GraphicAttribute 中的 getAdvance
返回:
ShapeGraphicAttribute 的 advance。
另请参见:
GraphicAttribute.getBounds()

draw

public void draw(Graphics2D graphics,
                 float x,
                 float y)
在给定的位置绘制该图形。绘制原点在 (x,y) 处的 Shape

指定者:
GraphicAttribute 中的 draw
参数:
graphics - 将该图形绘制到的 Graphics2D
x, y - 绘制该图形的用户空间坐标

getBounds

public Rectangle2D getBounds()
返回一个 Rectangle2D,它包围了由此 ShapeGraphicAttribute 相对于呈现位置所绘制的所有位。图形可以呈现在其原点、ascent、descent 和 advance 之外;但是,如果这样的话,此方法的实现应指示呈现该图形的位置。

覆盖:
GraphicAttribute 中的 getBounds
返回:
包围由此 ShapeGraphicAttribute 呈现的所有位的 Rectangle2D

hashCode

public int hashCode()
返回此 ShapeGraphicAttribute 的哈希码。

覆盖:
Object 中的 hashCode
返回:
ShapeGraphicAttribute 的哈希码值。
另请参见:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object rhs)
将此 ShapeGraphicAttribute 与指定的 Object 进行比较。

覆盖:
Object 中的 equals
参数:
rhs - 比较相等性的 Object
返回:
如果此 ShapeGraphicAttribute 等于 rhs,则返回 true;否则返回 false
另请参见:
Object.hashCode(), Hashtable

equals

public boolean equals(ShapeGraphicAttribute rhs)
将此 ShapeGraphicAttribute 与指定的 ShapeGraphicAttribute 进行比较。

参数:
rhs - 要比较相等性的 ShapeGraphicAttribute
返回:
如果此 ShapeGraphicAttribute 等于 rhs,则返回 true;否则返回 false

JavaTM 2 Platform
Standard Ed. 5.0

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策