モジュール java.desktop
パッケージ javax.swing.plaf.basic

クラスBasicGraphicsUtils

java.lang.Object
javax.swing.plaf.basic.BasicGraphicsUtils

public class BasicGraphicsUtils extends Object
便利なユーティリティ・クラス。
  • コンストラクタのサマリー

    コンストラクタ
    コンストラクタ
    説明
    BasicGraphicsUtilsを構築します。
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    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)
    ベゼルを描きます。
    static void
    drawDashedRect(Graphics g, int x, int y, int width, int height)
    破線の矩形を描画します。
    static void
    drawEtchedRect(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
    エッチングされた矩形を描画します。
    static void
    drawGroove(Graphics g, int x, int y, int w, int h, Color shadow, Color highlight)
    溝を描きます。
    static void
    drawLoweredBezel(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
    低いベゼルを描画します。
    static void
    drawString(Graphics g, String text, int underlinedChar, int x, int y)
    g.drawStringと同じように、位置(x,y)にグラフィックスgを使用して文字列を描画します。
    static void
    drawString(JComponent c, Graphics2D g, String string, float x, float y)
    指定されたコンポーネントのテキスト・プロパティおよびアンチ別名ヒントを使用して、指定されたロケーションに指定された文字列を描画します。
    static void
    drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y)
    g.drawStringと同じように、位置(x, y)にグラフィックスgを使用して文字列を描画します。
    static void
    drawStringUnderlineCharAt(JComponent c, Graphics2D g, String string, int underlinedIndex, float x, float y)
    指定された文字の下に指定されたロケーションにある指定された文字列を描画します。
    static String
    getClippedString(JComponent c, FontMetrics fm, String string, int availTextWidth)
    渡された文字列を、指定されたスペースにクリップします。
    static Insets
    drawEtchedRect()によって描画されるボーダーで占有される領域の量を返します。
    static Insets
    drawGroove()によって描画されるボーダーで占有される領域の量を返します。
    static Dimension
    ボタンの優先サイズを返します。
    static float
    指定されたコンポーネントのテキスト・プロパティおよびアンチ別名ヒントを使用して、渡された文字列の幅を返します。

    クラスjava.lang.Objectで宣言されたメソッド

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • コンストラクタの詳細

    • BasicGraphicsUtils

      public BasicGraphicsUtils()
      BasicGraphicsUtilsを構築します。
  • メソッドの詳細

    • 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の文字に下線が引かれます。 indextextの境界を越えた場合(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 - 指定されたgnullである場合
      導入されたバージョン:
      9
    • drawStringUnderlineCharAt

      public static void drawStringUnderlineCharAt(JComponent c, Graphics2D g, String string, int underlinedIndex, float x, float y)
      指定された文字の下に指定されたロケーションにある指定された文字列を描画します。 指定されたコンポーネントは、テキスト・プロパティおよびアンチ別名ヒントの問合せに使用されます。

      underlinedIndexパラメータは、指定された文字列の文字値(ユニコード・コード・ユニット)を指します。 下線付き索引で指定されたchar値が上位サロゲート範囲にあり、次の索引のchar値が下位サロゲート範囲にある場合、このサロゲート・ペアに対応する補足文字に下線が引かれます。

      索引が負であるか、文字列長(index < 0 || index >= string.length())より大きい場合、または指定された索引で指定されたchar値が下位サロゲート範囲内にある場合、文字に下線は付きません。

      パラメータ:
      c - 文字列を表示するコンポーネントはnullです
      g - グラフィック・コンテキストはnullにできません
      string - 表示する文字列。nullの場合もあります
      underlinedIndex - 下線にする文字列内のchar値(ユニコード・コード・ユニット)の索引
      x - テキストを描画するためのx座標
      y - テキストを描画するy座標
      例外:
      NullPointerException - 指定されたgnullである場合
      導入されたバージョン:
      9
      関連項目:
    • getClippedString

      public static String getClippedString(JComponent c, FontMetrics fm, String string, int availTextWidth)
      渡された文字列を、指定されたスペースにクリップします。 指定されたコンポーネントは、テキスト・プロパティおよびアンチ別名ヒントの問合せに使用されます。 指定されたスペースが文字列の幅より大きい場合は、変更されていない文字列が返されます。
      パラメータ:
      c - コンポーネントはnullである可能性があります
      fm - 文字列幅の測定に使用されるFontMetricsは、正しいフォントおよびグラフィックから取得する必要があります。 nullは不可。
      string - クリップする文字列はnullです
      availTextWidth - 文字列を描画できる領域の量
      戻り値:
      指定されたスペースに収まるクリッピングされた文字列。指定された文字列引数がnullまたは空の場合は空の文字列
      例外:
      NullPointerException - 指定されたfmnull
      導入されたバージョン:
      9
      関連項目:
    • getStringWidth

      public static float getStringWidth(JComponent c, FontMetrics fm, String string)
      指定されたコンポーネントのテキスト・プロパティおよびアンチ別名ヒントを使用して、渡された文字列の幅を返します。 渡された文字列がnullの場合、ゼロを返します。
      パラメータ:
      c - コンポーネントはnullである可能性があります
      fm - 拡張文字列の幅を測定するために使用されるFontMetricsは、正しいフォントとグラフィックから取得する必要があります。 nullは不可。
      string - 拡張幅を取得する文字列。nullの場合もあります
      戻り値:
      指定された文字列の前方幅。null文字列にはゼロが返されます
      例外:
      NullPointerException - 指定されたfmnull
      導入されたバージョン:
      9