com.mokit.util
クラス Graphic

java.lang.Object
  上位を拡張 com.mokit.util.Graphic

public class Graphic
extends java.lang.Object

グラフィック、フォントに関連する機能を提供します。

作成者:
Takuto Nishioka

フィールドの概要
static int FONT_LARGE
          ラージサイズフォント
static int FONT_MEDIUM
          ミディアムサイズフォント
static int FONT_SMALL
          スモールサイズフォント
static int FONT_TINY
          タイニーサイズフォント
 
メソッドの概要
static void clearAll()
          画面を背景色で塗りつぶします。
static void clearRect(int x1, int y1, int width, int height)
          矩形領域を背景色で塗りつぶします。
static void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          弧を描画します。
static void drawImage(com.nttdocomo.ui.Image img, int x, int y)
          イメージを描画します。
static void drawLine(int x1, int y1, int x2, int y2)
          直線を描画します。
static void drawRect(int x1, int y1, int xl2, int yl2)
          矩形を描画します。
static void drawScaledImage(com.nttdocomo.ui.Image img, int dx, int dy, int ldx, int ldy, int sx, int sy, int lsx, int lsy)
          イメージを拡大・縮小して描画します。
static void drawString(java.lang.String str, int x, int y)
          文字列を描画します。
static void drawTagString(java.lang.String str, int cvsStX, int cvsStY, int cvsEnX, int lineHeight)
          定義されたタグを利用して文字列を装飾描画します。
static void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          弧を塗りつぶします。
static void fillRect(int x1, int y1, int xl2, int yl2)
          矩形領域を塗りつぶします。
static int[] getFontSize(java.lang.String str)
          指定した文字列の幅と高さを取得します。
static int getFontType()
          現在アクティブなフォントタイプを取得します。
static int getHeight()
          画面の高さを取得します。
static com.nttdocomo.ui.Image getImage(byte[] img)
          イメージオブジェクトを取得します。
static com.nttdocomo.ui.Image getImage(java.lang.String url)
          リソースからイメージオブジェクトを取得します。
static int[] getLastColor()
          現在有効なカラーを取得します。
static int getWidth()
          画面の幅を取得します。
static void lock()
          描画デバイスに対して、ダブルバッファリングの開始を宣言します。
static void setColorRGB(int c1, int c2, int c3)
          カラーをセットします。
static void setColorRGB(int c1, int c2, int c3, int c4)
          カラーをセットします。
static void setFont(int fontType)
          フォントをセットします。
static void setGraphics(com.nttdocomo.ui.Graphics g2)
          Graphicsインスタンスをセットします。
static com.nttdocomo.ui.Image setTransparent(com.nttdocomo.ui.Image image, int r, int g, int b)
          イメージに透過色を設定します。
static void unlock(boolean b)
          描画デバイスに対して、ダブルバッファリングの終了を宣言します。
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

FONT_TINY

public static int FONT_TINY
タイニーサイズフォント


FONT_SMALL

public static int FONT_SMALL
スモールサイズフォント


FONT_MEDIUM

public static int FONT_MEDIUM
ミディアムサイズフォント


FONT_LARGE

public static int FONT_LARGE
ラージサイズフォント

メソッドの詳細

getWidth

public static int getWidth()
画面の幅を取得します。

戻り値:
画面の幅を返します。

getHeight

public static int getHeight()
画面の高さを取得します。

戻り値:
画面の高さを返します。

setGraphics

public static void setGraphics(com.nttdocomo.ui.Graphics g2)
Graphicsインスタンスをセットします。

パラメータ:
g2 - Graphicsインスタンス

lock

public static void lock()
描画デバイスに対して、ダブルバッファリングの開始を宣言します。


unlock

public static void unlock(boolean b)
描画デバイスに対して、ダブルバッファリングの終了を宣言します。

パラメータ:
b - 強制的にフラッシュするかどうか

clearRect

public static void clearRect(int x1,
                             int y1,
                             int width,
                             int height)
矩形領域を背景色で塗りつぶします。

パラメータ:
x1 - 矩形の左上のX座標
y1 - 矩形の左上のY座標
width - 矩形の幅
height - 矩形の高さ

clearAll

public static void clearAll()
画面を背景色で塗りつぶします。


drawString

public static void drawString(java.lang.String str,
                              int x,
                              int y)
文字列を描画します。

パラメータ:
str - 描画する文字列
x - X座標
y - Y座標

fillRect

public static void fillRect(int x1,
                            int y1,
                            int xl2,
                            int yl2)
矩形領域を塗りつぶします。

パラメータ:
x1 - 矩形の左上のX座標
y1 - 矩形の左上のY座標
xl2 - 矩形の幅
yl2 - 矩形の高さ

drawRect

public static void drawRect(int x1,
                            int y1,
                            int xl2,
                            int yl2)
矩形を描画します。

パラメータ:
x1 - 矩形の左上のX座標
y1 - 矩形の左上のY座標
xl2 - 矩形の幅
yl2 - 矩形の高さ

drawLine

public static void drawLine(int x1,
                            int y1,
                            int x2,
                            int y2)
直線を描画します。

パラメータ:
x1 - 直線の描画開始点のX座標
y1 - 直線の描画開始点のY座標
x2 - 直線の描画終了点のX座標
y2 - 直線の描画終了点のY座標

drawImage

public static void drawImage(com.nttdocomo.ui.Image img,
                             int x,
                             int y)
イメージを描画します。

パラメータ:
img - 描画するイメージオブジェクト
x - X座標
y - Y座標

drawScaledImage

public static void drawScaledImage(com.nttdocomo.ui.Image img,
                                   int dx,
                                   int dy,
                                   int ldx,
                                   int ldy,
                                   int sx,
                                   int sy,
                                   int lsx,
                                   int lsy)
イメージを拡大・縮小して描画します。

パラメータ:
img - 描画するイメージオブジェクト
dx - 描画先の矩形の左上の X 座標
dy - 描画先の矩形の左上の Y 座標
ldx - 描画先の矩形の幅
ldy - 描画先の矩形の高
sx - 描画元の矩形の左上の X 座標
sy - 描画元の矩形の左上の Y 座標
lsx - 描画元の矩形の幅
lsy - 描画元の矩形の高さ

drawArc

public static void drawArc(int x,
                           int y,
                           int width,
                           int height,
                           int startAngle,
                           int arcAngle)
弧を描画します。

パラメータ:
x - 弧の左上のX座標
y - 弧の左上のY座標
width - 弧の幅
height - 弧の高さ
startAngle - 弧の始点の角度
arcAngle - 弧の始点からの角度

fillArc

public static void fillArc(int x,
                           int y,
                           int width,
                           int height,
                           int startAngle,
                           int arcAngle)
弧を塗りつぶします。

パラメータ:
x - 弧の左上のX座標
y - 弧の左上のY座標
width - 弧の幅
height - 弧の高さ
startAngle - 弧の始点の角度
arcAngle - 弧の始点からの角度

getLastColor

public static int[] getLastColor()
現在有効なカラーを取得します。

戻り値:
RGBの数値配列を返します。

setColorRGB

public static void setColorRGB(int c1,
                               int c2,
                               int c3)
カラーをセットします。

パラメータ:
c1 - R
c2 - G
c3 - B

setColorRGB

public static void setColorRGB(int c1,
                               int c2,
                               int c3,
                               int c4)
カラーをセットします。

パラメータ:
c1 - R
c2 - G
c3 - B
c4 - アルファ値

setFont

public static void setFont(int fontType)
フォントをセットします。

パラメータ:
fontType - フォントタイプ

getFontSize

public static int[] getFontSize(java.lang.String str)
指定した文字列の幅と高さを取得します。

パラメータ:
str - 対象文字列
戻り値:
フォントサイズの数値配列。[0]幅, [1]高さ

getFontType

public static int getFontType()
現在アクティブなフォントタイプを取得します。

戻り値:
フォントタイプ

getImage

public static com.nttdocomo.ui.Image getImage(java.lang.String url)
リソースからイメージオブジェクトを取得します。

パラメータ:
url - 取得先パス
戻り値:
イメージオブジェクト

getImage

public static com.nttdocomo.ui.Image getImage(byte[] img)
イメージオブジェクトを取得します。

パラメータ:
img - バイト配列
戻り値:
イメージオブジェクト

setTransparent

public static com.nttdocomo.ui.Image setTransparent(com.nttdocomo.ui.Image image,
                                                    int r,
                                                    int g,
                                                    int b)
イメージに透過色を設定します。

パラメータ:
image - イメージオブジェクト
r - R
g - G
b - B
戻り値:
透過色が設定されたイメージオブジェクト

drawTagString

public static void drawTagString(java.lang.String str,
                                 int cvsStX,
                                 int cvsStY,
                                 int cvsEnX,
                                 int lineHeight)
定義されたタグを利用して文字列を装飾描画します。

【利用可能タグ】 文字サイズ設定 ... (tiny, small, medium, large を指定可能) 文字色設定 ... 太字 ... アンダーライン ... 改行

パラメータ:
str - タグを含んだ文字列
cvsStX - 描画開始位置X
cvsStY - 描画開始位置Y
cvsEnX - 描画終了位置X
lineHeight - 行間