- java.lang.Object
-
- javax.swing.plaf.basic.BasicGraphicsUtils
-
public class BasicGraphicsUtils extends Object
便利なユーティリティクラス。
-
-
コンストラクタのサマリー
コンストラクタ コンストラクタ 説明 BasicGraphicsUtils()
-
メソッドのサマリー
すべてのメソッド 静的メソッド 具象メソッド 修飾子と型 メソッド 説明 static voiddrawBezel(Graphics g, int x, int y, int w, int h, boolean isPressed, boolean isDefault, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)ベゼルを描画します。static voiddrawDashedRect(Graphics g, int x, int y, int width, int height)破線付きの長方形を描画します。static voiddrawEtchedRect(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)エッチングされた長方形を描画します。static voiddrawGroove(Graphics g, int x, int y, int w, int h, Color shadow, Color highlight)溝を描きます。static voiddrawLoweredBezel(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)下のベゼルを描画します。static voiddrawString(Graphics g, String text, int underlinedChar, int x, int y)g.drawStringと同じように、位置(x,y)にグラフィックスgを使用して文字列を描画します。static voiddrawString(JComponent c, Graphics2D g, String string, float x, float y)指定されたコンポーネントのテキスト・プロパティおよびアンチエイリアシング・ヒントを使用して、指定された場所に指定された文字列を描画します。static voiddrawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y)g.drawStringと同じように、位置(x,y)にグラフィックスgを使用して文字列を描画します。static voiddrawStringUnderlineCharAt(JComponent c, Graphics2D g, String string, int underlinedIndex, float x, float y)指定された文字列を指定された文字の下線で描画します。static StringgetClippedString(JComponent c, FontMetrics fm, String string, int availTextWidth)渡された文字列を、指定された領域にクリップします。static InsetsgetEtchedInsets()drawEtchedRect()によって描画されるボーダーで占有される領域の量を返します。static InsetsgetGrooveInsets()drawGroove()によって描画されるボーダーで占有される領域の量を返します。static DimensiongetPreferredButtonSize(AbstractButton b, int textIconGap)ボタンの優先サイズを返します。static floatgetStringWidth(JComponent c, FontMetrics fm, String string)テキスト・プロパティおよび指定されたコンポーネントからのアンチエイリアシング・ヒントを使用して、渡された文字列の幅を返します。
-
-
-
メソッドの詳細
-
drawEtchedRect
public static void drawEtchedRect(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
エッチングされた長方形を描画します。- パラメータ:
g-Graphicsのインスタンスx- X座標y- Y座標w- 幅h- 高さshadow- シャドウの色darkShadow- ダーク・シャドウの色highlight- 色強調表示lightHighlight- ライトの強調表示の色
-
getEtchedInsets
public static Insets getEtchedInsets()
drawEtchedRect()によって描画されるボーダーで占有される領域の量を返します。- 戻り値:
- エッチングされた矩形のイン・セット
-
drawGroove
public static void drawGroove(Graphics g, int x, int y, int w, int h, Color shadow, Color highlight)
溝を描きます。- パラメータ:
g-Graphicsのインスタンスx- X座標y- Y座標w- 幅h- 高さshadow- シャドウの色highlight- 色強調表示
-
getGrooveInsets
public static Insets getGrooveInsets()
drawGroove()によって描画されるボーダーで占有される領域の量を返します。- 戻り値:
- 溝ボーダーのイン・セット
-
drawBezel
public static void drawBezel(Graphics g, int x, int y, int w, int h, boolean isPressed, boolean isDefault, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
ベゼルを描画します。- パラメータ:
g-Graphicsのインスタンスx- X座標y- Y座標w- 幅h- 高さisPressed- コンポーネントが押されましたisDefault- デフォルトの描画shadow- シャドウの色darkShadow- ダーク・シャドウの色highlight- 色強調表示lightHighlight- ライトの強調表示の色
-
drawLoweredBezel
public static void drawLoweredBezel(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
下のベゼルを描画します。- パラメータ:
g-Graphicsのインスタンスx- X座標y- Y座標w- 幅h- 高さshadow- シャドウの色darkShadow- ダーク・シャドウの色highlight- 色強調表示lightHighlight- ライトの強調表示の色
-
drawString
public static void drawString(Graphics g, String text, int underlinedChar, int x, int y)
g.drawStringと同じように、位置(x,y)にグラフィックスgを使用して文字列を描画します。 テキスト内の最初のunderlineCharに下線が引かれます。 照合アルゴリズムでは、大文字と小文字を区別しません。- パラメータ:
g-Graphicsのインスタンスtext- テキストunderlinedChar- 下線付き文字x- X座標y- Y座標
-
drawStringUnderlineCharAt
public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y)
g.drawStringと同じように、位置(x,y)にグラフィックスgを使用して文字列を描画します。 テキスト内のインデックスがunderlinedIndexの文字に下線が引かれます。indexがtextの境界を越えた場合(0未満の場合も含む)、どこにも下線は引かれません。- パラメータ:
g- 描画に使用するグラフィックスtext- 描画する文字列underlinedIndex- テキスト中の下線を引く文字のインデックスx- 描画するx座標y- 描画するy座標- 導入されたバージョン:
- 1.4
-
drawDashedRect
public static void drawDashedRect(Graphics g, int x, int y, int width, int height)
破線付きの長方形を描画します。- パラメータ:
g-Graphicsのインスタンスx- X座標y- Y座標width- 長方形の幅height- 長方形の高さ
-
getPreferredButtonSize
public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap)
ボタンの優先サイズを返します。- パラメータ:
b-AbstractButtonのインスタンスtextIconGap- テキストとアイコンの間のギャップ- 戻り値:
- ボタンの優先サイズ
-
drawString
public static void drawString(JComponent c, Graphics2D g, String string, float x, float y)
指定されたコンポーネントのテキスト・プロパティおよびアンチエイリアシング・ヒントを使用して、指定された場所に指定された文字列を描画します。 null文字列には何も描画されません。- パラメータ:
c- 文字列を表示するコンポーネント。nullの場合があるg- グラフィック・コンテキスト。nullにできませんstring- 表示する文字列。nullにできますx- テキストを描画するx座標y- テキストを描画するy座標- 例外:
NullPointerException- 指定されたgがnullである場合- 導入されたバージョン:
- 9
-
drawStringUnderlineCharAt
public static void drawStringUnderlineCharAt(JComponent c, Graphics2D g, String string, int underlinedIndex, float x, float y)
指定された文字列を指定された文字の下線で描画します。 指定されたコンポーネントは、テキスト・プロパティおよびアンチエイリアシング・ヒントの問合せに使用されます。underlinedIndexパラメータは、指定された文字列内のchar値(Unicodeコード単位)を指します。 下線付き索引で指定されたchar値が上位サロゲート範囲にあり、次の索引のchar値が下位サロゲート範囲にある場合は、このサロゲート・ペアに対応する補助文字に下線が付けられます。索引が負または文字列の長さ
(index < 0 || index >= string.length())より大きい場合、または指定された索引で指定されたchar値が下位サロゲート範囲内にある場合は、文字に下線が付けられません。- パラメータ:
c- 文字列を表示するコンポーネント。nullの場合があるg- グラフィック・コンテキスト。nullにできませんstring- 表示する文字列。nullにできますunderlinedIndex- 下線を引く文字列内のchar値(Unicodeコード単位)のインデックスx- テキストを描画するx座標y- テキストを描画するy座標- 例外:
NullPointerException- 指定されたgがnullである場合- 導入されたバージョン:
- 9
- 関連項目:
getStringWidth(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String)
-
getClippedString
public static String getClippedString(JComponent c, FontMetrics fm, String string, int availTextWidth)
渡された文字列を、指定された領域にクリップします。 指定されたコンポーネントは、テキスト・プロパティおよびアンチエイリアシング・ヒントの問合せに使用されます。 指定されたスペースが文字列の幅より大きい場合、変更されていない文字列が返されます。- パラメータ:
c- コンポーネント。nullでもかまいませんfm- 文字列幅の測定に使用されるFontMetricsは、正しいフォントおよびグラフィックから取得する必要があります。 nullは不可。string- クリップする文字列。nullにできますavailTextWidth- 文字列が描画できる領域の量- 戻り値:
- 指定されたスペースに収まるクリップされた文字列。指定された文字列引数が
nullまたは空の場合は空の文字列 - 例外:
NullPointerException- 指定されたfmがnullの場合- 導入されたバージョン:
- 9
- 関連項目:
getStringWidth(javax.swing.JComponent, java.awt.FontMetrics, java.lang.String)
-
getStringWidth
public static float getStringWidth(JComponent c, FontMetrics fm, String string)
テキスト・プロパティおよび指定されたコンポーネントからのアンチエイリアシング・ヒントを使用して、渡された文字列の幅を返します。 渡された文字列がnullの場合、ゼロを返します。- パラメータ:
c- コンポーネント。nullでもかまいませんfm- 先行文字列の幅を測定するために使用されるFontMetricsは、正しいフォントおよびグラフィックから取得する必要があります。 nullは不可。string- 先頭の幅を取得する文字列。nullの場合がある- 戻り値:
- 指定された文字列の拡張幅。
null文字列の場合はゼロが戻されます。 - 例外:
NullPointerException- 指定されたfmがnullの場合- 導入されたバージョン:
- 9
-
-