Kagetaka

net.hizlab.kagetaka.rendering.block
クラス Block

java.lang.Object
  拡張net.hizlab.kagetaka.rendering.block.Block
直系の既知のサブクラス:
BasicBlock, HrBlock, MarkedBlock

public abstract class Block
extends Object

ブロック要素を表します。

バージョン:
$Revision: 1.9 $

フィールドの概要
protected  Insets border
          ボーダー幅
 int bottom
          親ブロックに対してのブロックの下側の位置
protected  ContainerBlock container
          コンテナブロック
protected  int contentHeight
          子要素の高さ
protected  Vector contents
          子のブロックリスト
protected  Block defaultBlock
          デフォルトの追加先ブロック
 int drawBottom
          描画に必要なブロックの下側の位置
protected  Drawkit drawkit
          ドローキット
 int drawLeft
          描画に必要なブロックの左側の位置
 int drawRight
          描画に必要なブロックの右側の位置
 int drawTop
          描画に必要なブロックの上側の位置
protected  Insets frame
          枠の大きさ
protected  int frameHeight
          フレームの高さ(frame.top + frame.bottom
protected  int frameWidth
          フレームの幅(frame.left + frame.right
protected  int height
          ブロック内容物の高さ
protected  boolean isAdoptee
          親が匿名ブロックかどうか
protected  boolean isEmpty
          空のブロックかどうか
 int left
          親ブロックに対してのブロックの左側の位置
 Insets margin
          マージン幅
static int MARGIN_BOTTOM
          下マージン
static int MARGIN_LEFT
          左マージン
static int MARGIN_RIGHT
          右マージン
static int MARGIN_TOP
          上マージン
static int MARKER_AFTER
          after 用マーカー
static int MARKER_BEFORE
          before 用マーカー
 int maxHeight
          ブロック全体の最大の高さ
 int minHeight
          ブロック全体の最小の高さ
protected  Insets padding
          パディング幅
protected  Block parent
          親ブロック
protected  int preferredHeight
          ブロック内容物の推奨の高さ
protected  int preferredWidth
          ブロック内容物の推奨の幅
 int right
          親ブロックに対してのブロックの右側の位置
protected static int SIZE_AUTO
          サイズ自動
protected static int SIZE_NONE
          サイズ無視
protected static int SIZE_PERCENT
          サイズパーセント指定
 Status status
          ステータス
 int top
          親ブロックに対してのブロックの上側の位置
protected  int width
          ブロック内容物の幅
 
コンストラクタの概要
protected Block(Drawkit drawkit, Status status, ContainerBlock container, Block parent)
          ブロックを作成します。
 
メソッドの概要
abstract  void analyze(int minParentHeight, int maxParentHeight)
          自分のサイズの最小と最大の高さを算出します。
 void appendBlock(Block block)
          インラインブロックを追加します。
 void appendFloat(FloatBlock block)
          フロートブロックを追加します。
 void appendForm(FormItem item)
          フォームアイテムを追加します。
 void appendImage(String src, String alt, Value width, Value height, int border, int floatType)
          画像を追加します。
 void appendNewLine()
          確定済み行を描画します。
 void appendString(String text)
          文字列を描画します。
protected  void calculateFrame(int parentHeight)
          ボーダー以外のフレーム関係のサイズを算出します。
protected  void calculatePreferred()
          ブロック内容物の推奨サイズを算出します。
 Block commitBlock()
          ブロックをコミットし、その親のブロックを返します。
protected  Block commitChild()
          最後の子のブロックがコミットしたときに呼び出され、 子のブロックに対する親(大抵は自分自身)を返す必要があります。
protected  void commitDefaultBlock()
          デフォルトの追加先ブロック defaultBlock をコミットします。
 void commitRow()
          テーブルの行を終了します。
 Block createBlock(Status status, Status markerStatus)
          ブロックを作成し、作成したブロックを返します。
protected  Block createBlockInternal(Status status, Status markerStatus)
          ブロックを作成し、作成したブロックを返します。
protected  void draw(Canvas canvas, int x, int y)
          ブロックを描画します。
protected  void drawBackground(Canvas canvas, int x, int y)
          背景画像・背景色を描画します。
protected  void drawBorder(Canvas canvas, int x, int y)
          ボーダーを描画します。
protected  void drawContent(Canvas canvas, int x, int y)
          内容物を描画します。
protected  void ensureDefaultBlock()
          デフォルトの追加先ブロック defaultBlock が存在するかを チェックします。
protected  Line getFirstLine()
          最初の行を返します。
protected  int getFrameHeight(int parentHeight)
          フレーム(マージン + ボーダー + パディング)の高さを返します。
 int getMargin(int parentHeight, int sense)
          validate(int, int, int, int, int, int) する前に、 マージンの幅を知りたい場合に、マージン幅を返します。
protected  int getMarginOffset(int left, int right)
          マージン同士の打ち消しをして差分を返します。
 Dimension getPreferredSize()
          推奨サイズを返します。
protected  void invalidate()
          現在の計算を無効にして、再計算対象にします。
protected  void layoutBlock(int newHeight, int containerX, int containerY)
          指定された高さになるように、自分のブロック、及び下位のブロックを 調節します。
 void setRuby(int mode)
          ルビのモードを変更します。
 void statusChanged(Status status)
          ステータスが変更された場合。
 String toString()
          文字列表現を返します。
 void validate(int parentHeight, int prevLeftMargin, int x, int y, int containerX, int containerY)
          再整形を行います。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

border

protected Insets border
ボーダー幅


bottom

public int bottom
親ブロックに対してのブロックの下側の位置


container

protected ContainerBlock container
コンテナブロック


contentHeight

protected int contentHeight
子要素の高さ


contents

protected Vector contents
子のブロックリスト


defaultBlock

protected Block defaultBlock
デフォルトの追加先ブロック


drawBottom

public int drawBottom
描画に必要なブロックの下側の位置


drawkit

protected Drawkit drawkit
ドローキット


drawLeft

public int drawLeft
描画に必要なブロックの左側の位置


drawRight

public int drawRight
描画に必要なブロックの右側の位置


drawTop

public int drawTop
描画に必要なブロックの上側の位置


frame

protected Insets frame
枠の大きさ


frameHeight

protected int frameHeight
フレームの高さ(frame.top + frame.bottom


frameWidth

protected int frameWidth
フレームの幅(frame.left + frame.right


height

protected int height
ブロック内容物の高さ


isAdoptee

protected boolean isAdoptee
親が匿名ブロックかどうか


isEmpty

protected boolean isEmpty
空のブロックかどうか


left

public int left
親ブロックに対してのブロックの左側の位置


margin

public Insets margin
マージン幅


MARGIN_BOTTOM

public static final int MARGIN_BOTTOM
下マージン

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

MARGIN_LEFT

public static final int MARGIN_LEFT
左マージン

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

MARGIN_RIGHT

public static final int MARGIN_RIGHT
右マージン

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

MARGIN_TOP

public static final int MARGIN_TOP
上マージン

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

MARKER_AFTER

public static final int MARKER_AFTER
after 用マーカー

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

MARKER_BEFORE

public static final int MARKER_BEFORE
before 用マーカー

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

maxHeight

public int maxHeight
ブロック全体の最大の高さ


minHeight

public int minHeight
ブロック全体の最小の高さ


padding

protected Insets padding
パディング幅


parent

protected Block parent
親ブロック


preferredHeight

protected int preferredHeight
ブロック内容物の推奨の高さ


preferredWidth

protected int preferredWidth
ブロック内容物の推奨の幅


right

public int right
親ブロックに対してのブロックの右側の位置


SIZE_AUTO

protected static final int SIZE_AUTO
サイズ自動

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

SIZE_NONE

protected static final int SIZE_NONE
サイズ無視

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

SIZE_PERCENT

protected static final int SIZE_PERCENT
サイズパーセント指定

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

status

public Status status
ステータス


top

public int top
親ブロックに対してのブロックの上側の位置


width

protected int width
ブロック内容物の幅

コンストラクタの詳細

Block

protected Block(Drawkit drawkit,
                Status status,
                ContainerBlock container,
                Block parent)
ブロックを作成します。

パラメータ:
drawkit - ドローキット
status - ステータス
container - コンテナブロック
parent - 親ブロック
メソッドの詳細

analyze

public abstract void analyze(int minParentHeight,
                             int maxParentHeight)
自分のサイズの最小と最大の高さを算出します。 算出した結果は、 minHeightmaxHeight に設定します。

パラメータ:
minParentHeight - 親フレームの最小高 (親包含ブロックの最小の height
maxParentHeight - 親フレームの最大高 (親包含ブロックの最大の height

appendBlock

public void appendBlock(Block block)
インラインブロックを追加します。

パラメータ:
block - インラインブロック

appendFloat

public void appendFloat(FloatBlock block)
フロートブロックを追加します。

パラメータ:
block - フロートブロック

appendForm

public void appendForm(FormItem item)
フォームアイテムを追加します。

パラメータ:
item - アイテム

appendImage

public void appendImage(String src,
                        String alt,
                        Value width,
                        Value height,
                        int border,
                        int floatType)
画像を追加します。

パラメータ:
src - ソース
alt - 代替文字列
width - 幅
height - 高さ
border - ボーダー
floatType - フロートタイプ

appendNewLine

public void appendNewLine()
確定済み行を描画します。


appendString

public void appendString(String text)
文字列を描画します。

パラメータ:
text - 文字列

calculateFrame

protected void calculateFrame(int parentHeight)
ボーダー以外のフレーム関係のサイズを算出します。 算出した結果は、 marginpaddingframeframeWidthframeHeight に設定します。

パラメータ:
parentHeight - 親ブロックの内容物の高さ

calculatePreferred

protected void calculatePreferred()
ブロック内容物の推奨サイズを算出します。 算出した結果は、 preferredWidthpreferredHeight に設定します。


commitBlock

public Block commitBlock()
ブロックをコミットし、その親のブロックを返します。

戻り値:
親ブロック

commitChild

protected Block commitChild()
最後の子のブロックがコミットしたときに呼び出され、 子のブロックに対する親(大抵は自分自身)を返す必要があります。

戻り値:
最後の子のブロックの親

commitDefaultBlock

protected void commitDefaultBlock()
デフォルトの追加先ブロック defaultBlock をコミットします。


commitRow

public void commitRow()
テーブルの行を終了します。


createBlock

public Block createBlock(Status status,
                         Status markerStatus)
ブロックを作成し、作成したブロックを返します。

パラメータ:
status - ステータス
markerStatus - マーカーステータス。 マーカーが無い場合は null
戻り値:
作成したブロック

createBlockInternal

protected final Block createBlockInternal(Status status,
                                          Status markerStatus)
ブロックを作成し、作成したブロックを返します。

パラメータ:
status - ステータス
markerStatus - マーカーステータス。 マーカーが無い場合は null
戻り値:
作成したブロック

draw

protected void draw(Canvas canvas,
                    int x,
                    int y)
ブロックを描画します。

パラメータ:
canvas - 描画するキャンバス
x - 親ブロック内容物の、キャンバス左上からの X 軸
y - 親ブロック内容物の、キャンバス左上からの Y 軸

drawBackground

protected void drawBackground(Canvas canvas,
                              int x,
                              int y)
背景画像・背景色を描画します。

パラメータ:
canvas - キャンバス
x - 自ブロックの、キャンバス左上からの X 軸
y - 自ブロックの、キャンバス左上からの Y 軸

drawBorder

protected void drawBorder(Canvas canvas,
                          int x,
                          int y)
ボーダーを描画します。

パラメータ:
canvas - キャンバス
x - 自ブロックの、キャンバス左上からの X 軸
y - 自ブロックの、キャンバス左上からの Y 軸

drawContent

protected void drawContent(Canvas canvas,
                           int x,
                           int y)
内容物を描画します。

パラメータ:
canvas - キャンバス
x - 自ブロック内容物の、キャンバス左上からの X 軸
y - 自ブロック内容物の、キャンバス左上からの Y 軸

ensureDefaultBlock

protected void ensureDefaultBlock()
デフォルトの追加先ブロック defaultBlock が存在するかを チェックします。無い場合は作成する必要があります。


getFirstLine

protected Line getFirstLine()
最初の行を返します。

このメソッドは validate 後に使用できます。

戻り値:
最初の行

getFrameHeight

protected int getFrameHeight(int parentHeight)
フレーム(マージン + ボーダー + パディング)の高さを返します。

このメソッドはいつでも使用できます。

パラメータ:
parentHeight - 親ブロックの内容物の高さ
戻り値:
フレームの高さ

getMargin

public int getMargin(int parentHeight,
                     int sense)
validate(int, int, int, int, int, int) する前に、 マージンの幅を知りたい場合に、マージン幅を返します。

このメソッドはいつでも使用できます。

パラメータ:
parentHeight - 親ブロックの内容物の高さ
sense - 向き
戻り値:
マージンの幅

getMarginOffset

protected final int getMarginOffset(int left,
                                    int right)
マージン同士の打ち消しをして差分を返します。

パラメータ:
left - 右のブロックの左マージン
right - 左のブロックの右マージン
戻り値:
マージンを打ち消すための差分

getPreferredSize

public final Dimension getPreferredSize()
推奨サイズを返します。

このメソッドはいつでも使用できます。

戻り値:
推奨サイズ

invalidate

protected void invalidate()
現在の計算を無効にして、再計算対象にします。


layoutBlock

protected void layoutBlock(int newHeight,
                           int containerX,
                           int containerY)
指定された高さになるように、自分のブロック、及び下位のブロックを 調節します。調節した結果は、 widthbottomleftdrawTopdrawRightdrawBottomdrawLeft に設定し内容物の高さは newHeight 以上になってはいけません。 このメソッドはブロックの大きさが変わるたびに呼び出されます。

パラメータ:
newHeight - 既に計算済みの内容物の高さ
containerX - コンテナブロックから自ブロック右上に対する X
containerY - コンテナブロックから自ブロック右上に対する Y

setRuby

public void setRuby(int mode)
ルビのモードを変更します。

パラメータ:
mode - ルビのモード

statusChanged

public void statusChanged(Status status)
ステータスが変更された場合。

パラメータ:
status - 新しいステータス

toString

public String toString()
文字列表現を返します。

戻り値:
文字列表現

validate

public void validate(int parentHeight,
                     int prevLeftMargin,
                     int x,
                     int y,
                     int containerX,
                     int containerY)
再整形を行います。 このメソッドで、heighttoprightcontentHeight フィールドと calculateFrame(int)layoutBlock(int, int, int) メソッドが設定するフィールドを、設定する必要があります。

パラメータ:
parentHeight - フレーム等を含めた新しい高さ (親包含ブロックの height)。 この高さ以内になるべく全てが収まるように再整形を行う
prevLeftMargin - 前のブロックの左マージン
x - 親包含ブロックから自ブロック右上に対する X
y - 親包含ブロックから自ブロック右上に対する Y
containerX - コンテナブロックから親ブロック右上に対する X
containerY - コンテナブロックから親ブロック右上に対する Y

Kagetaka

Copyright (c) 2002-2004 The Kagetaka Project 'November 20, 2004'