ts.graph
クラス GraphImage

java.lang.Object
  上位を拡張 ts.graph.GraphImage

public abstract class GraphImage
extends java.lang.Object

グラフ画像作成クラス。
グラフを描画し、それをファイルやストリームに出力するための抽象クラスである。

バージョン:
$Id: GraphImage.java,v 1.1 2010-10-16 13:47:00 tayu Exp $
作成者:
佐藤隆之.

フィールドの概要
protected static int B
          下のインデックスを示す定数。
protected static int H
          高さのインデックスを示す定数。
protected static int L
          左のインデックスを示す定数。
protected static int R
          右のインデックスを示す定数。
protected static int T
          上のインデックスを示す定数。
static java.lang.String TYPE_JPEG
          JPEG形式を示す画像タイプ値。
static java.lang.String TYPE_PNG
          PNG形式を示す画像タイプ値。
protected static int W
          幅のインデックスを示す定数。
 
コンストラクタの概要
GraphImage()
          デフォルト・コンストラクタ。
 
メソッドの概要
 java.io.File createImageFile(java.lang.String type, java.io.File file)
          グラフを描画した画像ファイルを作成する。
 java.io.File createImageFile(java.lang.String type, java.lang.String path)
          グラフを描画した画像ファイルを作成する。
protected  void drawArc(float x, float y, float rx, float ry, float startAngle, float endAngle)
          弧を描画する。
protected  void drawBackGround()
          背景を描画する。
protected  void drawBorder(java.awt.Rectangle rc)
          描画領域の境界線を描画する。
protected  void drawCircle(float x, float y, float r)
          円を描画する。
protected  void drawEllipse(float x, float y, float rx, float ry)
          楕円を描画する。
protected abstract  void drawGraph(java.awt.Rectangle drawnBounds)
          グラフを描画する。
protected  void drawLine(float x0, float y0, float x1, float y1)
          直線を描画する。
protected  void drawPolygon(float[] x, float[] y)
          多角形を描画する。
protected  void drawPolyLine(float[] x, float[] y)
          折れ線を描画する。
protected  void drawRect(float x0, float y0, float x1, float y1)
          四角を描画する。
protected  void drawText(java.lang.String text, float x, float y)
          文字列を描画する。
protected  void drawText(java.lang.String text, float x, float y, float deg)
          文字列を角度を付けて描画する。
protected  void fillArc(float x, float y, float rx, float ry, float startAngle, float endAngle)
          塗りつぶされた弧を描画する。
protected  void fillCircle(float x, float y, float r)
          塗りつぶされた円を描画する。
protected  void fillEllipse(float x, float y, float rx, float ry)
          塗りつぶされた楕円を描画する。
protected  void fillPolygon(float[] x, float[] y)
          塗りつぶされた多角形を描画する。
protected  void fillRect(float x0, float y0, float x1, float y1)
          塗りつぶされた四角を描画する。
 java.awt.Rectangle getDrawnBounds()
          グラフの描画領域を求める。
 int getHeight()
          画像の高さを取得する。
 int[] getMargin()
          グラフ描画領域に対するマージンを格納した配列を取得する。
protected  float[] getTextDrawnBounds(java.lang.String text, float x, float y)
          文字列を描画する時の領域を取得する。
protected  float[] getTextDrawnBounds(java.lang.String text, float x, float y, float deg)
          文字列を描画する時の領域を取得する。
protected  float[] getTextSize(java.lang.String text)
          文字列のサイズを取得する。
 int getWidth()
          画像の幅を取得する。
protected  java.awt.Graphics2D graphics()
          描画に使用しているグラフィックス・オブジェクトを取得する。
 void outputImage(java.lang.String type, java.io.OutputStream ostream)
          グラフを描画して出力ストリームに出力する。
protected  void setAntiAliasing(boolean on)
          図形のアンチエイリアシングの有効・無効を設定する。
 void setBgColor(java.awt.Color color)
          背景色を設定する。
 void setBorderStyle(LineStyle style)
          境界線のスタイルを設定する。
protected  FillStyle setFillStyle(FillStyle fillStyle)
          塗りつぶしのスタイルを設定する。
protected  LineStyle setLineStyle(LineStyle lineStyle)
          線のスタイルを設定する。
 void setMargin(int left, int top, int right, int bottom)
          グラフ描画領域に対するマージンを設定する。
protected  void setOrigin(int x, int y)
          画像に対する描画領域の原点に設定する。
protected  void setScale(double sx, double sy)
          画像に対する描画領域の倍率を設定する。
 void setSize(int w, int h)
          画像のサイズを設定する。
protected  void setTextAntiAliasing(boolean on)
          テキストのアンチエイリアシングの有効・無効を設定する。
protected  TextStyle setTextStyle(TextStyle textStyle)
          テキストのスタイルを設定する。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

TYPE_PNG

public static final java.lang.String TYPE_PNG
PNG形式を示す画像タイプ値。

関連項目:
定数フィールド値

TYPE_JPEG

public static final java.lang.String TYPE_JPEG
JPEG形式を示す画像タイプ値。

関連項目:
定数フィールド値

W

protected static final int W
幅のインデックスを示す定数。

関連項目:
定数フィールド値

H

protected static final int H
高さのインデックスを示す定数。

関連項目:
定数フィールド値

L

protected static final int L
左のインデックスを示す定数。

関連項目:
定数フィールド値

T

protected static final int T
上のインデックスを示す定数。

関連項目:
定数フィールド値

R

protected static final int R
右のインデックスを示す定数。

関連項目:
定数フィールド値

B

protected static final int B
下のインデックスを示す定数。

関連項目:
定数フィールド値
コンストラクタの詳細

GraphImage

public GraphImage()
デフォルト・コンストラクタ。

メソッドの詳細

setSize

public void setSize(int w,
                    int h)
画像のサイズを設定する。
引数に負の値を指定した場合は、代わりに0を設定する。

パラメータ:
w - 画像の幅。
h - 画像の高さ。

getWidth

public int getWidth()
画像の幅を取得する。

戻り値:
画像の幅。

getHeight

public int getHeight()
画像の高さを取得する。

戻り値:
画像の高さ。

setMargin

public void setMargin(int left,
                      int top,
                      int right,
                      int bottom)
グラフ描画領域に対するマージンを設定する。
引数に負の値を指定した場合は、代わりに0を設定する。

パラメータ:
left - 左側のマージン。
top - 上側のマージン。
right - 右側のマージン。
bottom - 下側のマージン。

getMargin

public int[] getMargin()
グラフ描画領域に対するマージンを格納した配列を取得する。

戻り値:
マージンを格納する配列。第1要素は左端のx座標、第2要素は 上端のy座標、第3要素は右端のx座標、第4要素は下端のy座標で ある。

setBgColor

public void setBgColor(java.awt.Color color)
背景色を設定する。
引数がヌルの場合は無視する。

パラメータ:
color - 背景色。

setBorderStyle

public void setBorderStyle(LineStyle style)
境界線のスタイルを設定する。
引数にヌルを指定した場合は、境界線を描画しない。

パラメータ:
style - 境界線のスタイル。

getDrawnBounds

public java.awt.Rectangle getDrawnBounds()
グラフの描画領域を求める。

戻り値:
グラフの描画領域を示すRectangle オブジェクト。

createImageFile

public java.io.File createImageFile(java.lang.String type,
                                    java.lang.String path)
                             throws java.io.IOException
グラフを描画した画像ファイルを作成する。

パラメータ:
type - 画像タイプ。
path - ファイル・パス。
戻り値:
画像ファイル。
例外:
java.io.IOException - ファイルの出力中に例外が発生した場合。

createImageFile

public java.io.File createImageFile(java.lang.String type,
                                    java.io.File file)
                             throws java.io.IOException
グラフを描画した画像ファイルを作成する。

パラメータ:
type - 画像タイプ。
file - 画像ファイルのFileオブジェクト。
戻り値:
画像ファイル。
例外:
java.io.IOException - ファイルの出力中に例外が発生した場合。

outputImage

public void outputImage(java.lang.String type,
                        java.io.OutputStream ostream)
                 throws java.io.IOException
グラフを描画して出力ストリームに出力する。

パラメータ:
type - 画像タイプ。
ostream - 出力ストリーム。
例外:
java.io.IOException - ストリームへの出力中に例外が発生した場合。

drawGraph

protected abstract void drawGraph(java.awt.Rectangle drawnBounds)
グラフを描画する。

パラメータ:
drawnBounds - 描画領域。

graphics

protected java.awt.Graphics2D graphics()
描画に使用しているグラフィックス・オブジェクトを取得する。

戻り値:
描画に使用しているグラフィックス・オブジェクト。

setAntiAliasing

protected void setAntiAliasing(boolean on)
図形のアンチエイリアシングの有効・無効を設定する。

パラメータ:
on - アンチエイリアシングを有効にする場合はtrueを指定する。

setTextAntiAliasing

protected void setTextAntiAliasing(boolean on)
テキストのアンチエイリアシングの有効・無効を設定する。

パラメータ:
on - アンチエイリアシングを有効にする場合はtrueを指定する。

setLineStyle

protected LineStyle setLineStyle(LineStyle lineStyle)
線のスタイルを設定する。

パラメータ:
lineStyle - 線のスタイル。
戻り値:
それまで設定されていた線のスタイル。

setFillStyle

protected FillStyle setFillStyle(FillStyle fillStyle)
塗りつぶしのスタイルを設定する。

パラメータ:
fillStyle - 塗りつぶしのスタイル。
戻り値:
それまで設定されていた塗りつぶしスタイル。

setTextStyle

protected TextStyle setTextStyle(TextStyle textStyle)
テキストのスタイルを設定する。

パラメータ:
textStyle - テキストのスタイルを設定する。
戻り値:
それまで設定されていたテキストのスタイル。

setOrigin

protected void setOrigin(int x,
                         int y)
画像に対する描画領域の原点に設定する。
原点の座標は、常に画像の左上からの位置を指定する。 現在の原点からの相対位置ではないことに注意する。

パラメータ:
x - 画像上の水平方向の座標。
y - 画像上の垂直方向の座標。

setScale

protected void setScale(double sx,
                        double sy)
画像に対する描画領域の倍率を設定する。
倍率は、画像全体のサイズからマージンを除いた分に対する値である。

パラメータ:
sx - 画像に対する水平方向の倍率。
sy - 画像に対する垂直方向の倍率。

drawBackGround

protected void drawBackGround()
背景を描画する。


drawBorder

protected void drawBorder(java.awt.Rectangle rc)
描画領域の境界線を描画する。

パラメータ:
rc - 描画領域。

drawLine

protected void drawLine(float x0,
                        float y0,
                        float x1,
                        float y1)
直線を描画する。

パラメータ:
x0 - 直線の始点のx座標。
y0 - 直線の始点のy座標。
x1 - 直線の終点のx座標。
y1 - 直線の終点のy座標。

drawRect

protected void drawRect(float x0,
                        float y0,
                        float x1,
                        float y1)
四角を描画する。

パラメータ:
x0 - 四角の左端のx座標。
y0 - 四角の上端のy座標。
x1 - 四角の右端のx座標。
y1 - 四角の下端のy座標。

fillRect

protected void fillRect(float x0,
                        float y0,
                        float x1,
                        float y1)
塗りつぶされた四角を描画する。

パラメータ:
x0 - 四角の左端のx座標。
y0 - 四角の上端のy座標。
x1 - 四角の右端のx座標。
y1 - 四角の下端のy座標。

drawPolyLine

protected void drawPolyLine(float[] x,
                            float[] y)
折れ線を描画する。

パラメータ:
x - 点のx座標の配列。
y - 点のy座標の配列。
例外:
java.lang.IllegalArgumentException - x座標の配列とy座標の配列のサイズが異なる 場合。

drawPolygon

protected void drawPolygon(float[] x,
                           float[] y)
多角形を描画する。

パラメータ:
x - 頂点のx座標の配列。
y - 頂点のy座標の配列。
例外:
java.lang.IllegalArgumentException - x座標の配列とy座標の配列のサイズが異なる 場合。

fillPolygon

protected void fillPolygon(float[] x,
                           float[] y)
塗りつぶされた多角形を描画する。

パラメータ:
x - 頂点のx座標の配列。
y - 頂点のy座標の配列。
例外:
java.lang.IllegalArgumentException - x座標の配列とy座標の配列のサイズが異なる 場合。

drawCircle

protected void drawCircle(float x,
                          float y,
                          float r)
円を描画する。

パラメータ:
x - 中心のx座標。
y - 中心のy座標。
r - 半径。

fillCircle

protected void fillCircle(float x,
                          float y,
                          float r)
塗りつぶされた円を描画する。

パラメータ:
x - 中心のx座標。
y - 中心のy座標。
r - 半径。

drawEllipse

protected void drawEllipse(float x,
                           float y,
                           float rx,
                           float ry)
楕円を描画する。

パラメータ:
x - 中心のx座標。
y - 中心のy座標。
rx - x方向の半径。
ry - y方向の半径。

fillEllipse

protected void fillEllipse(float x,
                           float y,
                           float rx,
                           float ry)
塗りつぶされた楕円を描画する。

パラメータ:
x - 中心のx座標。
y - 中心のy座標。
rx - x方向の半径。
ry - y方向の半径。

drawArc

protected void drawArc(float x,
                       float y,
                       float rx,
                       float ry,
                       float startAngle,
                       float endAngle)
弧を描画する。

パラメータ:
x - 中心のx座標。
y - 中心のy座標。
rx - x方向の半径。
ry - y方向の半径。
startAngle - 開始角度 [deg]。
endAngle - 開始角度 [deg]。

fillArc

protected void fillArc(float x,
                       float y,
                       float rx,
                       float ry,
                       float startAngle,
                       float endAngle)
塗りつぶされた弧を描画する。

パラメータ:
x - 中心のx座標。
y - 中心のy座標。
rx - x方向の半径。
ry - y方向の半径。
startAngle - 開始角度 [deg]。
endAngle - 開始角度 [deg]。

drawText

protected void drawText(java.lang.String text,
                        float x,
                        float y)
文字列を描画する。
なお、setScale(float,float) メソッドで倍率を設定した場合、文字列の表示位置はそれに合わせて変化する が、フォント・サイズは変化しない。

パラメータ:
text - 描画する文字列。
x - 文字列の左上のx座標。
y - 文字列の左上のy座標。

drawText

protected void drawText(java.lang.String text,
                        float x,
                        float y,
                        float deg)
文字列を角度を付けて描画する。

パラメータ:
text - 描画する文字列。
x - 文字列の左上のx座標。
y - 文字列の左上のy座標。
deg - 文字列を傾ける角度 [deg]。

getTextSize

protected float[] getTextSize(java.lang.String text)
文字列のサイズを取得する。
このメソッドにより得られるサイズは、角度や倍率に依らない値である。

パラメータ:
text - 文字列。
戻り値:
文字列のサイズを格納する配列。第1要素は幅、第2要素は高さである。

getTextDrawnBounds

protected float[] getTextDrawnBounds(java.lang.String text,
                                     float x,
                                     float y)
文字列を描画する時の領域を取得する。
文字列の位置や倍率を考慮した値を取得する。

パラメータ:
text - 文字列。
x - 文字列の描画位置のx座標。
y - 文字列の描画位置のy座標。
戻り値:
描画領域の座標を格納する配列。第1要素は左端のx座標、第2要素は 上端のy座標、第3要素は右端のx座標、第4要素は下端のy座標で ある。

getTextDrawnBounds

protected float[] getTextDrawnBounds(java.lang.String text,
                                     float x,
                                     float y,
                                     float deg)
文字列を描画する時の領域を取得する。
文字列の位置や倍率、角度を考慮した値を取得する。

パラメータ:
text - 文字列。
x - 文字列の描画位置のx座標。
y - 文字列の描画位置のy座標。
deg - 文字列を傾ける角度 [deg]。
戻り値:
描画領域の座標を格納する配列。第1要素は左端のx座標、第2要素は 上端のy座標、第3要素は右端のx座標、第4要素は下端のy座標で ある。


Copyright (C) SATOH Takayuki All Rights Reserved.