public abstract class GraphicAttribute extends Object
GraphicAttribute
クラスは、テキストに埋め込まれたグラフィックを表します。 クライアントはこのクラスをサブクラス化して、charと置き換えるグラフィックを実装します。 テキストに図形やイメージを埋め込む場合は、このクラスをサブクラス化する必要はありません。 代わりに、ShapeGraphicAttribute
クラスやImageGraphicAttribute
クラスを使用できます。
サブクラスでは、いったん構築したオブジェクトが不変であるようにする必要があります。 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 の有効幅を返します。 |
int |
getAlignment() |
GraphicAttribute の配置方法を返します。 |
abstract float |
getAscent() |
この
GraphicAttribute のアセントを返します。 |
Rectangle2D |
getBounds() |
この
GraphicAttribute によってレンダリングされる全ビットを囲む、Rectangle2D を返します。これは、レンダリング位置を基準にして示されます。 |
abstract float |
getDescent() |
この
GraphicAttribute のディセントを返します。 |
GlyphJustificationInfo |
getJustificationInfo() |
この
GraphicAttribute の位置揃えプロパティを返します。 |
Shape |
getOutline(AffineTransform tx) |
この
GraphicAttribute によってレンダリングされる領域を表すShape を返します。 |
public static final int TOP_ALIGNMENT
public static final int BOTTOM_ALIGNMENT
public static final int ROMAN_BASELINE
public static final int CENTER_BASELINE
public static final int HANGING_BASELINE
protected GraphicAttribute(int alignment)
GraphicAttribute
を構築します。 サブクラスではこれを使用してグラフィックの配置方法を定義します。 alignment
- GraphicAttribute
の位置合わせフィールドの1つを表すint値IllegalArgumentException
- alignmentが、定義されている5つの値のどれでもない場合。public abstract float getAscent()
GraphicAttribute
のアセントを返します。 グラフィックはアセントの上にレンダリングされます。 GraphicAttribute
のアセント。getBounds()
public abstract float getDescent()
GraphicAttribute
のディセントを返します。 グラフィックはディセントの下にレンダリングされます。 GraphicAttribute
のディセント。getBounds()
public abstract float getAdvance()
GraphicAttribute
の有効幅を返します。 GraphicAttribute
オブジェクトの有効幅とは、グラフィックがレンダリングされる地点から次の文字またはグラフィックがレンダリングされる地点までの距離です。 グラフィックは、有効幅を超えてレンダリングすることもできます。 GraphicAttribute
の有効幅。getBounds()
public Rectangle2D getBounds()
GraphicAttribute
によってレンダリングされる全ビットを囲む、Rectangle2D
を返します。これは、レンダリング位置を基準にして示されます。 グラフィックは、原点、アセント、ディセント、有効幅を超えてレンダリングできますが、その場合はグラフィックをレンダリングする位置をこのメソッドの実装で示す必要があります。 デフォルトの境界は矩形(0、- アセント、有効幅、アセント+ディセント)です。 GraphicAttribute
によってレンダリングされる全ビットを囲むRectangle2D
。public Shape getOutline(AffineTransform tx)
GraphicAttribute
によってレンダリングされる領域を表すShape
を返します。 これはTextLayout
がテキストの輪郭を返すように要求されたときに使用されます。 (変換されていない)形状は、getBounds
によって返される矩形境界の内側に収まっている必要があります。 デフォルトの実装は、getBounds()
によって返される矩形を、指定されたAffineTransform
で変換したものを返します。 tx
- このGraphicAttribute
の輪郭に適用するオプションのAffineTransform
。 nullを指定できる。 Shape
。public abstract void draw(Graphics2D graphics, float x, float y)
GraphicAttribute
を指定された位置にレンダリングします。graphics
- グラフィックのレンダリング先のGraphics2D
x
- グラフィックがレンダリングされるユーザー空間X座標y
- グラフィックがレンダリングされるユーザー空間Y座標public final int getAlignment()
GraphicAttribute
の配置方法を返します。 特定のベースラインにそろえる配置方法や、行の上端または下端にそろえる配置方法があります。 GraphicAttribute
の配置方法。public GlyphJustificationInfo getJustificationInfo()
GraphicAttribute
の位置揃えプロパティを返します。 サブクラスでこのメソッドをオーバーライドし、別の位置揃えプロパティを指定することもできます。 GraphicAttribute
の位置揃え情報を含むGlyphJustificationInfo
オブジェクト。 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。