* @create 2007/02/27 * @version $Id: UDGD4.php,v 0.44 2007/03/27 Exp $ **/ class UTGD4 { //画像サイズとリソース /** * 画像リソース * @var resource GD */ private $image; /** * 画像枠横幅(余白含む) * @var int */ private $width; /** * 画像枠縦幅(余白含む) * @var int */ private $height; /** * 画像枠横幅(余白含まない) * @var int */ private $widthi; /** * 画像枠縦幅(余白含まない) * @var int */ private $heighti; /** * X方向の余白 * @var int */ private $marginx; /** * Y方向の余白 * @var int */ private $marginy; /** * 描画原点(X軸) * @var int */ private $originx; /** * 描画原点(Y軸) * @var int */ private $originy; /** * 一列の高さ * @var int */ private $rowheight; /** * 列数 * @var int */ private $rownum; //座標関連 /** * 倍率 * @var float */ private $magnification; /** * 計算上の最大列数 * @var int */ private $maxrow; /** * 文字描画余白 * @var int */ private $stringmargin; //染色体設定 /** * 画像のスタート座標の染色体上位置 * @var int */ private $chr_start; /** * 画像のエンド座標の染色体上位置 * @var int */ private $chr_end; /** * 表示塩基数 * @var int */ private $bases; //色設定 /** * 画像背景色 * @var string */ private $bgcolor; /** * 画像余白色 * @var string */ private $margincolor; //図形オブジェクト関連 /** * ユニークID * @var string uniqid() */ private $uid; /** * 図形オブジェクトのID * @var int */ private $oid; /** * オブジェクトの描画情報 * @var array */ private $objectdata; //オブジェクト /** * 描画列管理 * @var int */ private $linemanager; /** * バッファオブジェクト * @var object */ private $bufferobject; /** * XMLオブジェクト * @var object */ private $xmlobject; /** * ログオブジェクト * @var object */ private $logobject; /** * デバッグオブジェクト * @var object */ private $debugobject; //文字フォント /** * 文字フォントファイルパス * @var string */ private $fontfile; //セッタ /** * セッタ(height) * @access public * @param int $height 画像枠縦幅 */ public function setHeight($height){ $this->height = $height; } /** * ゲッタ(width) * @access public * @return int 画像枠横幅 */ public function getHeight(){ return $this->height; } /** * セッタ(width) * @access public * @param int $width 画像枠横幅 */ public function setWidth($width){ $this->width = $width; } /** * ゲッタ(height) * @access public * @return int 画像枠縦幅 */ public function getWidth(){ return $this->width; } /** * セッタ(bgcolor) * @access public * @param string $bgcolor 背景色 */ public function setBgcolor($bgcolor){ $this->bgcolor = $bgcolor; } /** * セッタ(margincolor) * @access public * @param string $margincolor 余白色 */ public function setMargincolor($margincolor){ $this->margincolor = $margincolor; } /** * セッタ(chr_start) * @access public * @param int $chrstart 描画染色体始端塩基番号 */ public function setChrStart($chrstart){ $this->chr_start = $chrstart; } /** * ゲッタ(chr_start) * @access public * @return int 描画染色体始端塩基番号 */ public function getChrStart(){ return $this->chr_start; } /** * セッタ(chr_end) * @access public * @param int $chrend 描画染色体終端塩基番号 */ public function setChrEnd($chrend){ $this->chr_end = $chrend; } /** * ゲッタ(chr_end) * @access public * @return int 描画染色体終端塩基番号 */ public function getChrEnd(){ return $this->chr_end; } /** * セッタ(bases) * @access public * @param int $bases 描画塩基数 */ public function setBases($bases){ $this->bases = $bases; } /** * ゲッタ(bases) * @access public * @return int 描画塩基数 */ public function getBases(){ return $this->bases; } /** * セッタ(magnification) * @access public * @param int $magnification 塩基倍率 */ public function setMagnification($magnification){ $this->magnification = $magnification; } /** * セッタ(marginx) * @access public * @param int $marginx 余白(X軸方向) */ public function setMarginx($marginx){ $this->marginx = $marginx; } /** * セッタ(marginy) * @access public * @param int $marginy 余白(Y軸方向) */ public function setMarginy($marginy){ $this->marginy = $marginy; } /** * セッタ(originx) * @access public * @param int $originx 原点(X軸方向) */ public function setOriginx($originx){ $this->originx = $originx; } /** * セッタ(originy) * @access public * @param int $originy 原点(Y軸方向) */ public function setOriginy($originy){ $this->originy = $originy; } /** * セッタ(rowheight) * @access public * @param int $rowheigt 一列の高さ */ public function setRowHeight($rowheight){ $this->rowheight = $rowheight; } /** * セッタ(rownum) * @access public * @param int $rownum 画像内の列数 */ public function setRowNum($rownum){ $this->rownum = $rownum; } /** * ゲッタ(rownum) * @access public * @return int 画像内の列数 */ public function getRowNum(){ return $this->rownum; } /** * セッタ(heigti) * @access public * @param int $heighti 描画可能画像枠縦幅 */ public function setHeightI($heighti){ $this->heighti = $heighti; } /** * ゲッタ(heigti) * @access public * @return int 描画可能画像枠縦幅 */ public function getHeightI(){ return $this->heighti; } /** * セッタ(widthi) * @access public * @param int $widthi 描画可能画像枠横幅 */ public function setWidthI($widthi){ $this->widthi = $widthi; } /** * ゲッタ(widthi) * @access public * @return int 描画可能画像枠横幅 */ public function getWidthI(){ return $this->widthi; } /** * セッタ(maxrow) * @access public * @param int $maxrow 現在の最大列番号 */ public function setMaxRow($maxrow){ $this->maxrow = $maxrow; } /** * ゲッタ(maxrow) * @access public * @return int 現在の最大列番号 */ public function getMaxRow(){ return $this->maxrow; } /** * セッタ(stringmargin) * @access public * @param int $stringmargin 文字列描画余白 */ public function setStringMargin($stringmargin){ $this->stringmargin = $stringmargin; } /** * セッタ(fontfile) * @access public * @param int $fontfile TTFファイルのパス * @return FALSE(TTFファイルが見つからない時) */ public function setFontFile($fontfile){ $realpath = realpath($fontfile); if($realpath){ $this->fontfile = $fontfile; }else{ return FALSE; } } /** * コンストラクタ * @access public */ public function __construct(){ //ID設定 $this->uid = uniqid(); $this->oid = 1; //変数初期化 $this->objectdata = array(); $this->maxrow = 0; //列管理オブジェクト作成 $this->linemanager = new LineManager(); } /** * デストラクタ * @access public */ public function __destruct(){ } //画像オプション設定(セッタ補助)関数 /** * イメージ枠のサイズを設定します。 * @access public * @param int $width 画像枠横幅 * @param int $height 画像枠縦幅 * @param int $rownum 列数 * @param int $rowheight 一列の高さ * @param int $chrstart 描画開始位置(染色体上の位置) * @param int $chrend 描画終了位置(染色体上の位置) * @param int $marginx 横の余白 * @param int $marginy 縦の余白 * @param int $magnification 倍率 */ public function setImageSize($width,$height,$rownum,$rowheight,$chrstart,$chrend,$marginx=0,$marginy=0,$magnification=0){ //引数の優先順位に従ってサイズ処理 /** * 高さ関連優先順位 * RowHeight * - 有 * RowNum * - 有 * ○HeightI = RowHeight*RowNum * Height = HeightI + 2*Marginy * - 無 * Height * - 有 * ○HeigtI = Height - 2*Marginy * RowNum = HeightI/RowHeight * - 無 * △RowNum = 1 * HeightI = RowHeight * Height = HeightI + 2*Marginy * - 無 * RowNum * - 有 * Height * - 有 * ○HeightI = Height - 2*Marginy * RowHeight = HeightI/RowNum * - 無 * ×エラー * - 無 * Height * - 有 * △RowNum = 1 * HeightI = Height - 2*Marginy * RowHeight = HeightI/RowNum * - 無 * ×エラー * (注) * Marginx/yは指定されない場合には0とする。 */ //列の高さと列数、高さの関係 if($rowheight){ if($rownum){ $heighti = $rownum*$rowheight; $height = $heighti + 2*$marginy; }else{ if($height){ $heighti = $height - 2*$marginy; $rownum = (int)$heighti/$rowheight; }else{ //RowNum=1強制設定 $rownum = 1; $heighti = $rowheight; $height = $heighti + 2*$marginy; } } }else{ if($rownum){ if($height){ $heighti = $height - $marginy; $rowheight = $heighti/$rownum; }else{ //ERROR! /** * @todo エラー処理 */ } }else{ if($height){ $rownum = 1; $heighti = $height - 2*$marginy; $rowheight = $heighti; }else{ //ERROR! /** * @todo エラー処理 */ } } } //縦方向メンバセット self::setHeight($height); self::setHeightI($heighti); self::setRowHeight($rowheight); self::setRowNum($rownum); self::setMarginy($marginy); self::setOriginy($marginy); self::setMaxRow($rownum); /** * 横幅引数優先順位 * Width * - 有 * Chr start/end * - 有 * ○WidthI = Width - 2*Marginx * ○Bases = Chr end - Chr start +1 * Magnification = Bases/WidthI * - 無 * Magnification * - 有 * ○WidthI = Width - 2*Marginx * Bases = WidthI*Magnification * - 無 * ×エラー * - 無 * Chr start/end * - 有 * Magnification * - 有 * ○Bases = Chr end - Chr start +1 * ○WidthI = Bases*Magnification * Width = Width + 2*Marginx * - 無 * ×エラー * - 無 * ×エラー */ //場増横幅と表示塩基数、倍率の関係 if($width){ if(!(is_null($chrstart)) && !(is_null($chrend))){ $bases = $chrend - $chrstart; $widthi = $width - 2*$marginx; $magnification = $bases/$widthi; }else{ if($magnification){ $widthi = $width - 2*$marginx; $bases = $widthi*$magnification; }else{ //ERROR! /** * @todo エラー処理 */ } } }else{ if(!(is_null($chrstart)) && !(is_null($chrend))){ $bases = $chrend - $chrstart; if($magnification){ $widthi = $bases*$magnification; $width = $widthi + 2*$marginx; }else{ //ERROR! /** * @todo エラー処理 */ } }else{ //ERROR! /** * @todo エラー処理 */ } } //横幅メンバセット self::setWidth($width); self::setWidthI($widthi); self::setBases($bases); self::setChrStart($chrstart); self::setChrEnd($chrend); self::setMarginx($marginx); self::setOriginx($marginx); self::setMagnification($magnification); } /** * イメージ枠のオプションを設定します。 * @access public * @param string $bgcolor 背景色 * @param string $margincolor 余白色 * @param string $stringmargin 文字列描画余白 */ public function setImageOptions($bgcolor='white',$margincolor='',$stringmargin=''){ self::setBgcolor($bgcolor); if(!($margincolor)){ $margincolor = $bgcolor; } self::setMargincolor($margincolor); if(!($stringmargin)){ $stringmargin = 0; } self::setStringMargin($stringmargin); } //ログファイル関連メソッド /** * ログオブジェクトを作成し、ログファイルをオープンします。 * @access public * @param string $logfile ログファイルパス * @param string $log_level ログレベル(INFO) */ public function openLogFile($logfile,$log_level='INFO'){ $this->logobject = new LogFile(); $this->logobject->setLogLevel($log_level); $this->logobject->openFile($logfile,'w'); } /** * ログファイルにログを書き込みます。 * @access public * @param string $string ログ文字列 */ public function writeLogFile($string){ if(isset($this->logobject)){ $this->logobject->writeFile($string); } } /** * ログファイルをクローズし、ログオブジェクトをunsetします。 * @access public */ public function closeLogFile(){ if(isset($this->logobject)){ $this->logobject->closeFile(); } unset($this->logobject); } //中間ファイル関連メソッド /** * 中間ファイルオブジェクトを作成し、中間ファイルをオープンします。 * @access public * @param string $bufferfile 中間ファイルパス * @param string $mode ファイルオープンモード */ public function openBufferFile($bufferfile,$mode='w'){ $this->bufferobject = new BufferFile(); $this->bufferobject->openFile($bufferfile,$mode); } /** * 中間ファイルオブジェクトに文字列を書き込みます。 * @access public * @param string $string 記述文字列 */ public function writeStringToBuffer($string){ $this->bufferobject->writeFile($string); } /** * 中間ファイルへカテゴリー行を挿入する。 * @access private * @param string $category カテゴリー(INFO/INDEX/GRAPH/LATER/FORCE/WITHIN/TILING) */ public function insertCategory($category){ $this->bufferobject->writeCategoy($category); } /** * 中間ファイルをクローズし、中間ファイルオブジェクトをunsetします。 * @access public */ public function closeBufferFile(){ if(isset($this->bufferobject)){ $this->bufferobject->closeFile(); } unset($this->bufferobject); } //XMLファイル関連メソッド /** * XMLファイルを設定する。 * @access private * @param int $filepath XMLファイルパス */ public function openXMLFile($filepath,$create=TRUE){ //XMLオブジェクト作成 $this->xmlobject = new XMLFile(); //XMLファイルセット・オープン $this->xmlobject->setXMLFile($filepath,$create); } /** * XMLファイルを出力する。 * @access private */ public function outputXMLFile(){ //XMLオブジェクト作成 if(isset($this->xmlobject)){ $this->xmlobject->outputXML(); } } /** * XMLファイルを標準出力に出力する。 * @access private */ public function outputXMLDataStandard(){ //XMLオブジェクト作成 if(isset($this->xmlobject)){ $this->xmlobject->outputXMLStandard(); } } /** * XMLファイルから標準出力に出力する。 * @access private */ public function outputXMLDataStandardFromFile(){ //XMLオブジェクトキャッシュ読み込み if(isset($this->xmlobject)){ $this->xmlobject->getDOMObjectFromXMLFile(); $this->xmlobject->outputXMLStandard(); } } /** * XMLファイルをキャッシュ出力する。 * @access private * @param string $cache_id キャッシュID * @param int $expire_sec キャッシュ有効時間(秒) * @param int $cleaning_times キャッシュ自動クリーニング間隔(キャッシュ作成X回に1回) */ public function cacheXMLData($cache_id,$expire_sec=3600,$cleaning_times=0){ //XMLオブジェクト作成 if(isset($this->xmlobject)){ $this->xmlobject->cacheDOMObject($cache_id,$expire_sec,$cleaning_times); } } /** * XMLキャッシュを読み込んで標準出力に出力する。 * @access private * @param string $cache_id キャッシュID * @param int $limit キャッシュ読み込み待ち最大時間(秒) * @param int $wait 再読み込み間隔(秒) */ public function outputCachedXMLData($cache_id,$limit=60,$wait=10){ //XMLオブジェクトキャッシュ読み込み if(isset($this->xmlobject)){ $this->xmlobject->readDOMObjectCache($cache_id,$limit,$wait); $this->xmlobject->outputXMLStandard(); } } /** * イメージ枠を作成します。 * @access public * @param int $width 画像枠横幅 * @param int $height 画像枠縦幅 * @param string $bgcolor 背景色 */ public function createImage($width=0, $height=0, $bgcolor=''){ if($this->maxrow > $this->rownum){ self::setRowNum($this->maxrow); // $this->setRowNum($this->maxrow); } self::setImageSize($this->width,$this->height,$this->rownum,$this->rowheight,$this->chr_start,$this->chr_end,$this->marginx,$this->marginy); //サイズ指定 if(!($height)){ $height = $this->height; } if(!($width)){ $width = $this->width; } if(!($bgcolor)){ $bgcolor = $this->bgcolor; } //背景色指定 $col_array = ColorUtil::getRGB($bgcolor); $this->image = imagecreatetruecolor($width, $height); self::writeLogFile("size of created image : $width, $height\n"); $backgroundcolor = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); // self::writeLogFile("$col_array[0],$col_array[1],$col_array[2]\n"); imagefill($this->image,0,0,$backgroundcolor); } /** * イメージリソースを返す。 * @access private * @return image イメージリソース */ public function getImageResource(){ if(isset($this->image)){ return $this->image; } } /** * イメージを出力します。 * @access public * @param string $format 画像フォーマット */ public function outputImage($format='png'){ //余白設定 if(!($this->margincolor)){ $this->margincolor = 'white'; } $col_array = ColorUtil::getRGB($this->margincolor); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); if($this->marginx){ imagefilledrectangle($this->image,0,0,$this->marginx,$this->height,$col); imagefilledrectangle($this->image,$this->width-$this->marginx,0,$this->width,$this->height,$col); } if($this->marginy){ imagefilledrectangle($this->image,0,0,$this->width,$this->marginy,$col); imagefilledrectangle($this->image,0,$this->height-$this->marginy,$this->width,$this->height,$col); } //デバッグメッセージ出力(オブジェクト) if(isset($this->debugobject)){ if($this->debugobject->isDebugMode()){ $this->image = $this->debugobject->drawDebugMessage($this->image); if(isset($this->logobject)){ $this->debugobject->outputDebugMessageToLog($this->logobject); } } } //画像フォーマット選択 switch ($format) { case jpg: header("Content-Type: image/jpg"); imagejpeg($this->image); break; case gif://imagecreatetruecolorだとGIFは使えないはずでは? header("Content-Type: image/gif"); imagegif($this->image); break; case png: default: header("Content-Type: image/png"); imagepng($this->image); break; } //画像オブジェクト解放 imagedestroy($this->image); } //中間ファイルパース /** * 中間ファイルを読み込んでパース * @access public * @param string $filepath 中間ファイルパス * @param string $tiling_mode タイリングモード * @param boolean $simulate_mode シミュレートモード * @return array 画像縦幅、画像最大列数(シミュレートモード時) */ public function parseBufferFile($filepath,$tiling_mode='TILING',$simulate_mode=FALSE){ if($tiling_mode == 'LATER'){ $start_row = $this->linemanager->getDrawedMaxRow() + 1; $checkmode = '+'; }elseif($tiling_mode == 'FORCE'){ $checkmode = '!'; }else{ $tiling_mode = 'TILING'; $checkmode = '-'; } //バッファファイルオープン $buf = new BufferFile(); $buf->openFile($filepath,'r'); //"$objectid\t$array[0]\t$array[1]\t$array[2]\t$array[3]\t$type\t$args\t$optype\t$opargs\t$comment\n" //基本カテゴリー $bufcategory = 'GRAPH'; while($str = $buf->getLine()){ //カテゴリー情報による分岐 if(eregi("^==(.+)$",$str,$cat)){ if($cat[1] == 'INDEX'){ $bufcategory = 'INDEX'; // $this->debugobject->addDebugMessage("$cat[1] is index"); continue; }elseif($cat[1] == 'LATER'){ $tiling_mode = 'LATER'; $start_row = $this->linemanager->getDrawedMaxRow() + 1; $checkmode = '+'; }elseif($cat[1] == 'TILING'){ $tiling_mode = 'TILING'; $start_row = 0; $checkmode = '-'; }elseif($cat[1] == 'FORCE'){ $tiling_mode = 'FORCE'; $checkmode = '!'; }else{ $bufcategory = 'GRAPH'; continue; } }else{ if($bufcategory != 'GRAPH'){ continue; } } //取得行分解 $array = explode("\t", $str); ////オブジェクト描画列の取得 if($this->linemanager->getRowToDraw($array[0])){ //既にオブジェクト描画列が決定している。 $rownum = $this->linemanager->getRowToDraw($array[0]); self::writeLogFile("already definded to $rownum\n"); }elseif($array[4] == '*'){ $rownum = NULL; }else{ //初めてのオブジェクト ////オブジェクト占有領域を座標変換 ////object_start $occupy_x1_converted = self::convertPositionString($array[1]); ////object_end $occupy_x2_converted = self::convertPositionString($array[2]); //オブジェクトサイズが変化する場合 ////ピクチャオブジェクト if($array[5] == 'copyPicture'){ $args = explode("|",$array[6]); //../data/kuma.PNG|1500|0||WITHIN mouseclick_event if($args[4] == 'WITHIN'){ list($sw,$sh,$type,$attr) = getimagesize($args[0]); if($sh > $this->rowheight){ $new_sw = $sw*$this->rowheight/$sh; $occupy_x2_converted = $occupy_x1_converted + $new_sw; if($array[3] > 0){ $occupy_x2_converted = $occupy_x1_converted + $new_sw; }else{ $occupy_x2_converted = $occupy_x1_converted + $new_sw; } }else{ $new_sw = $sw; } } } ////オブジェクトの占有領域座標 if($array[3] > 0){ $object_start = $occupy_x1_converted; $object_end = $occupy_x2_converted + $this->stringmargin + $array[3]; }elseif($array[3] < 0){ $object_start = $occupy_x1_converted - $this->stringmargin + $array[3]; $object_end = $occupy_x2_converted; }else{ $object_start = $occupy_x1_converted; $object_end = $occupy_x2_converted; } if($checkmode == '!'){ //直接列指定 if($array[4] < 1){ $rownum = 1; }else{ $rownum = $array[4]; } self::writeLogFile("this object($array[0]) is forced to be drawed in $rownum\n"); }else{ ////オブジェクト占有領域から描画列決定 if(!($start_row) || $start_row < $array[4]){ if($array[4] < 1){ $start_row = 1; }else{ $start_row = $array[4]; } } self::writeLogFile("this object($array[0]) will be checked from $start_row\n"); $rownum = $this->linemanager->getVacantRowNum($object_start,$object_end,$start_row,$checkmode); } self::writeLogFile("this object($array[0]) occupied from $object_start to $object_end and be drawed in $rownum\n"); ////既描画オブジェクト、オブジェクト列データに格納 $count = $this->linemanager->pushDrawedPositions($rownum,$object_start,$object_end); self::writeLogFile("max row drawed is $count\n"); $this->linemanager->pushDrawedObject($array[0],$rownum); //既存列数を超えた場合 if($this->maxrow < $rownum){ self::setMaxRow($rownum); } } //メソッド引数に列番号を追加 self::writeLogFile("this object($array[0]) should be drawed in $rownum\n"); $array[6] = "$rownum|".$array[6]; //オブジェクトデータに格納 //45c7ea06ed699_1 5000 7500 45 1 drawBox 5000|5500|15|blue mouseclick_event www.google.co.jp gene test data if($simulate_mode == FALSE){ array_push($this->objectdata, array($array[5],$array[6],$array[7],$array[8],$array[9])); } } //バッファファイルのクローズ $buf->closeFile(); //ログ≪格納オブジェクト // self::writeLogFile($this->objectdata,'print_r'); if($simulate_mode == TRUE){ return array($this->maxrow,$this->rowheight*$this->maxrow+2*$this->marginy); } } //Index描画用中間ファイルパース /** * 中間ファイルを読み込んでパース * @access public * @param string $filepath 中間ファイルパス * @param string $tiling_mode タイリングモード * @param int $minrow 描画最小列 * @param int $maxrow 描画最大列 */ public function parseBufferFileIndex($filepath,$tiling_mode='TILING',$minrow=1,$maxrow=1){ if($tiling_mode == 'LATER'){ $start_row = $this->linemanager->getDrawedMaxRow() + 1; $checkmode = '+'; }elseif($tiling_mode == 'WITHIN'){ $tiling_mode = 'WITHIN'; $checkmode = '+'; if($minrow){ $start_row = $minrow; }else{ $start_row = $this->linemanager->getDrawedMaxRow() + 1; } if($maxrow){ $end_row = $maxrow; }else{ $end_row = $this->linemanager->getDrawedMaxRow() + 1; } }elseif($tiling_mode == 'FORCE'){ $checkmode = '!'; }else{ $tiling_mode = 'TILING'; $checkmode = '-'; } //バッファファイルオープン $buf = new BufferFile(); $buf->openFile($filepath,'r'); //"$objectid\t$array[0]\t$array[1]\t$array[2]\t$array[3]\t$type\t$args\t$optype\t$opargs\t$comment\n" //基本カテゴリー $bufcategory = 'GRAPH'; while($str = $buf->getLine()){ //カテゴリー情報による分岐 if(eregi("^==(.+)$",$str,$cat)){ if($cat[1] == 'INDEX'){ $bufcategory = 'INDEX'; $this->linemanager->changeIndexMode(); continue; }elseif($cat[1] == 'LATER'){ $tiling_mode = 'LATER'; $start_row = $this->linemanager->getDrawedMaxRow() + 1; $checkmode = '+'; continue; }elseif($cat[1] == 'TILING'){ $tiling_mode = 'TILING'; $start_row = 0; $checkmode = '-'; continue; }elseif($cat[1] == 'WITHIN'){ $tiling_mode = 'WITHIN'; $checkmode = '+'; if($minrow){ $start_row = $minrow; }else{ $start_row = $this->linemanager->getDrawedMaxRow() + 1; } if($maxrow){ $end_row = $maxrow; }else{ $end_row = $this->linemanager->getDrawedMaxRow() + 1; } }else{ $bufcategory = 'GRAPH'; continue; } }else{ if($bufcategory != 'INDEX'){ continue; } } //取得行分解 $array = explode("\t", $str); ////オブジェクト描画列の取得 if($this->linemanager->getRowToDraw($array[0])){ //既にオブジェクト描画列が決定している。 $rownum = $this->linemanager->getRowToDraw($array[0]); self::writeLogFile("already definded to $rownum\n"); }elseif($array[4] == '*'){ $rownum = NULL; }else{ //初めてのオブジェクト ////オブジェクト占有領域を座標変換 ////object_start ////object_end $occupy_x1_converted = self::convertPositionString($array[1]); $occupy_x2_converted = self::convertPositionString($array[2]); ////オブジェクトの占有領域座標 if($array[3] >= 0){ $object_start = $occupy_x1_converted; $object_end = $occupy_x2_converted + $this->stringmargin + $array[3]; }elseif($array[3] < 0){ $object_start = $occupy_x1_converted - $this->stringmargin + $array[3]; $object_end = $occupy_x2_converted; }else{ $object_start = $occupy_x1_converted; $object_end = $occupy_x2_converted; } if($checkmode == '!'){ //直接列指定 if($array[4] < 1){ $rownum = 1; }else{ $rownum = $array[4]; } self::writeLogFile("this object($array[0]) is forced to be drawed in $rownum\n"); }else{ ////オブジェクト占有領域から描画列決定 if(!($start_row)){ if($array[4] < 1){ $start_row = 1; }else{ $start_row = $array[4]; } } $rownum = $this->linemanager->getVacantRowNum($object_start,$object_end,$start_row,$checkmode); } self::writeLogFile("this object($array[0]) occupied from $object_start to $object_end and be drawed in $rownum\n"); //既存列数を超えた場合 if($rownum > $end_row){ self::writeLogFile("this object($array[0]) won't be drawed because of row limit\n"); continue; } ////既描画オブジェクト、オブジェクト列データに格納 $count = $this->linemanager->pushDrawedPositions($rownum,$object_start,$object_end); self::writeLogFile("max row drawed is $count\n"); $this->linemanager->pushDrawedObject($array[0],$rownum); // if($this->maxrow < $rownum){ // self::setMaxRow($rownum); // } } //メソッド引数に列番号を追加 self::writeLogFile("this object($array[0]) should be drawed in $rownum\n"); $array[6] = "$rownum|".$array[6]; //オブジェクトデータに格納 //45c7ea06ed699_1 5000 7500 45 1 drawBox 5000|5500|15|blue mouseclick_event www.google.co.jp gene test data array_push($this->objectdata, array($array[5],$array[6],$array[7],$array[8],$array[9])); } //バッファファイルのクローズ $buf->closeFile(); //ログ≪格納オブジェクト // self::writeLogFile($this->objectdata,'print_r'); } //図形描画 /** * 中間ファイルから読み込んだデータを描画 * @access public */ public function drawImage(){ //$this->objectdata2次元配列からの描画 ////drawBox 5000|5500|15|blue|1 mouseclick_event www.google.co.jp gene test data foreach($this->objectdata as $array){ $args = explode("|", $array[1]); //描画列決定 // self::log_info("switch to $array[0]\n"); switch ($array[0]) { case drawBox: //public function drawBox($start,$end,$height,$color=black,$rownum,$op_type,$op_args){ //drawBox 5000|5500|15|blue|1 mouseclick_event www.google.co.jp gene test data // self::writeLogFile("drawBox operation\n"); self::drawBox($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$array[2],$array[3]); break; case drawBoxAlpha: //public function drawBoxAlpha($start,$end,$height,$color=black,$alpha,$rownum,$op_type,$op_args){ //drawBoxAlpha -425|-92|100%|blue|0|1 // self::writeLogFile("drawBoxAlpha operation\n"); self::drawBoxAlpha($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$array[2],$array[3]); break; case drawBoxGraph: //public function drawBox($start,$end,$height,$color=black,$alpha,$rownum,$op_type,$op_args){ //drawBoxAlpha -425|-92|100%|blue|0|1 // self::writeLogFile("drawBoxGraph operation\n"); self::drawBoxGraph($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$array[2],$array[3]); break; case drawLine: //drawLine 2000|-7.5|4500|7.5|black|1|1 // self::writeLogFile("drawLine operation\n"); self::drawLine($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6]); break; case drawLineX: //drawLineX 17188|18592|0|blue|2|1 line test data // self::writeLogFile("drawLineX operation\n"); self::drawLineX($args[0],$args[1],$args[2],$args[3],$args[4],$args[5]); break; case drawLineY: //drawLine 2000|-7.5|7.5|black|1|1 // self::writeLogFile("drawLineY operation\n"); self::drawLineY($args[0],$args[1],$args[2],$args[3],$args[4],$args[5]); break; case drawLineAlpha: //drawLine 2000|-7.5|4500|7.5|black|1|1 // self::writeLogFile("drawLine operation\n"); self::drawLineAlpha($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6]); break; case drawLineYFolded: // public function drawLineFolded($start_x,$end_x,$posy,$f_size,$f_dir=1,$color='black',$size=1,$rownum=1){ //drawLine 2000|-7.5|4500|7.5|black|1|1 // self::writeLogFile("drawLine operation\n"); self::drawLineYFolded($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7]); break; case drawLineArrow: //drawLineArrow 8984|0|9972|0|black|||1|10||1|45|1 // $this->logobject->logInfo("drawLineArrow operation\n"); // self::drawLineArrow($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7],$args[8],$args[9],$args[10],$args[11],$args[12],$args[13]); self::drawLineArrow($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7],$args[8],$args[9],$args[10],$args[11],$args[12],$args[13],$args[14]); break; case drawLineArrowMulti: //drawLineArrowMulti 11671|0|12640|0|black||1|10|10||1|45|1 // $this->logobject->logInfo("drawLineArrowMulti operation\n"); // self::drawLineArrowMulti($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7],$args[8],$args[9],$args[10],$args[11],$args[12]); self::drawLineArrowMulti($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7],$args[8],$args[9],$args[10],$args[11],$args[12],$args[13],$args[14]); break; case drawString: //drawString Gene Number0|3200|3|blue|1 // self::writeLogFile("drawString operation\n"); if(is_null($this->stringmargin)){ $stringmargin = $args[6]; }else{ $stringmargin = $this->stringmargin; } self::drawString($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$stringmargin,$args[7],$array[2],$array[3]); break; case drawStringTTF: //drawString Gene Number0|3200|3|blue|1 // self::writeLogFile("drawString operation\n"); if(is_null($this->stringmargin)){ $stringmargin = $args[6]; }else{ $stringmargin = $this->stringmargin; } self::drawStringTTF($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$stringmargin,$args[7],$array[2],$array[3]); break; case drawBoxedString: //drawBoxedString C|19500|0|500|15|CENTER|CENTER|0|3|#ffff00|1 // self::writeLogFile("drawBoxedString operation\n"); self::drawBoxedString($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7],$args[8],$args[9],$args[10],$array[2],$array[3]); break; case drawBoxSharp: //public function drawBox($start,$end,$height,$color=black,$rownum,$op_type,$op_args){ //drawBox 1000|2000|15|red|1 mouseclick_event www.google.co.jp loci test data // //drawBoxSharp($x1, $y1, $width, $height, $color='yellow',$strand=1,$angle=45) // self::writeLogFile("drawBoxSharp operation\n"); self::drawBoxSharp($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$args[6],$args[7],$array[2],$array[3]); break; case drawPolygon: //drawPolygon 0_0,0_20,1000_30,2000_40,3000_50,4000_20,5000_30,6000_40,7000_50,8000_20,9000_30,10000_40,11000_50,12000_30,13000_20,14000_50,15000_40,16000_80,17000_60,18000_50,19000_1019000_0|22|red|1 mouseclick_event www.google.co.jp contents test data // self::writeLogFile("drawPolygon operation\n"); $points = explode(",",$args[1]); $coods = array(); foreach($points as $point){ list($pos,$value) = explode("_",$point); array_push($coods,array($pos,$value)); } // self::log_info($points,'print_r'); self::drawPolygon($args[0],$coods,$args[2],$args[3],$array[2],$array[3]); break; case copyPicture: // copyPicture ../data/kuma.PNG|1000|0||WITHIN // self::writeLogFile("copyPicture operation\n"); self::copyPicture($args[0],$args[1],$args[2],$args[3],$args[4],$args[5],$array[2],$array[3]); break; default: break; } } } //複合図形描画 /** * Nameを描画 * @access public * @param array $start 描画基点 * @param int $rownum 描画列番号 * @param string $id オブジェクトID * @param string $string Gene名 * @param string $fontsize Gene名フォントサイズ * @param string $strpos Gene名描画位置 * @param string $stringcol 文字列色 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawName($start,$rownum,$id,$string,$fontsize,$strpos,$stringcol,$operation,$comment){ //Nameオブジェクト作成 $name = new Name(); //IDセット $oid = $name->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $name->setData($start,$rownum); //Stringセット $name->setString($string,$fontsize,$strpos,$stringcol,$this->fontfile); //操作XMLデータ $name->setOperations($operation,$comment); //バッファ追加 $name->writeBufferFile($this->bufferobject); } /** * Geneを描画 * @access public * @param array $exons エクソン座標データ * @param int $rownum 描画列番号 * @param int $height Gene縦幅 * @param string $id オブジェクトID * @param array $color Gene描画色 array or string * @param string $string Gene名 * @param string $fontsize Gene名フォントサイズ * @param string $strpos Gene名描画位置 * @param string $stringcol 文字列色 * @param int $connection 連結線タイプ * @param int $connectcol 連結線色 * @param int $connectsize 連結線のサイズ * @param string $frame 枠線色 * @param int $strand Sharp方向(+1/-1/0) * @param int $shape 先頭エクソンの形態(1:Box, 2:BoxSharp) * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawGene($exons,$rownum,$height,$id='',$color='blue',$string='',$fontsize=3,$strpos='RIGHT',$stringcol='black',$connection=0,$connectcol='',$connectsize=1,$frame='',$strand=0,$shape=1,$operation='',$comment=''){ // public function drawGene($exons,$rownum,$height,$id='',$color='blue',$string='',$fontsize=3,$strpos='RIGHT',$stringcol='black',$connection=0,$connectcol='',$connectsize=1,$frame='',$operation='',$comment=''){ //Geneオブジェクト作成 $gene = new Gene(); //IDセット $oid = $gene->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット // $gene->setData($exons,$rownum); $gene->setData($exons,$strand,$rownum); //連結線セット $gene->setConnection($connection,$connectcol,$connectsize); //Stringセット $gene->setString($string,$fontsize,$strpos,$stringcol,$this->fontfile); //オプションセット $gene->setOptions($height,$color,$frame,$shape); //操作XMLデータ $gene->setOperations($operation,$comment); //バッファ追加 $gene->writeBufferFile($this->bufferobject); //オブジェクト解放 $gene->__destruct(); } /** * Locusを描画 * @access public * @param array $start Locus始点 * @param int $end Locus終点 * @param int $rownum 描画列番号 * @param int $strand Locusの向き * @param int $height 縦幅 * @param string $id オブジェクトID * @param string $color Locus描画色 * @param string $type 描画形態タイプ * @param int $angle BoxSharpの角度 * @param string $string 表示文字 * @param string $strcolor 表示文字色 * @param string $strpos 表示文字位置 * @param int $fontsize 表示文字サイズ * @param string $frame 枠線色 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawLocus($start,$end,$rownum,$strand,$height,$id='',$color='yellow',$type='BoxSharp',$angle=45,$string='',$stringcol='black',$strpos='RIGHT',$fontsize=3,$frame='',$operation='',$comment=''){ //Locusオブジェクト作成 $locus = new Locus(); //IDセット $oid = $locus->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $locus->setData($start,$end,$strand,$rownum); //Stringセット $locus->setString($string,$fontsize,$strpos,$stringcol,$this->fontfile); //オプションセット $locus->setOptions($height,$color,$type,$angle,$frame); //操作XMLデータ $locus->setOperations($operation,$comment); //バッファ追加 $locus->writeBufferFile($this->bufferobject); //オブジェクト解放 $locus->__destruct(); } /** * ESTを描画 * @access public * @param array $positions 区切り点 * @param int $height 縦幅 * @param int $rownum 描画列番号 * @param int $strand ESTの向き * @param string $id オブジェクトID * @param string $color EST描画色 * @param string $connecttype 連結線タイプ * @param int $connectcol 連結線色 * @param int $connectcsize 連結線サイズ * @param int $arrowstart 連結線矢印開始点 * @param int $arrowint 連結線矢印感覚 * @param string $string 表示文字 * @param string $strcolor 表示文字色 * @param string $strpos 表示文字位置 * @param int $fontsize 表示文字サイズ * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawEST($positions,$height,$rownum,$strand=1,$id='',$color='black',$connecttype=1,$connectcol='black',$connectsize,$arrowstart=0,$arrowint=0,$string='',$strcolor='black',$strpos='RIGHT',$fontsize=2,$operation='',$comment=''){ //ESTオブジェクト作成 $est = new EST(); //IDセット $oid = $est->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $est->setData($positions,$strand,$rownum); //連結線セット $est->setConnection($connecttype,$connectcol,$connectsize,$arrowstart,$arrowint); //Stringセット $est->setString($string,$fontsize,$strpos,$strcolor,$this->fontfile); //オプションセット $est->setOptions($height,$color); //操作XMLデータ $est->setOperations($operation,$comment); //バッファ追加 $est->writeBufferFile($this->bufferobject); //オブジェクト解放 $est->__destruct(); } /** * Contents(含有量タイプ)を描画 * @access public * @param array $contents コンテンツ * @param int $start 始点(bp) * @param int $setbp 対応塩基数 * @param int $setnum 平均値用セット数 * @param int $rownum 列番号 * @param string $id オブジェクトID * @param string $color 描画色 * @param float $max_value 最大値 * @param float $min_value 最小値 * @param int $type 描画タイプ * @param string $operation 操作XMLデータ * @param string $comment コメント * @return */ public function drawContents($contents,$start,$setbp=1,$setnum=1,$rownum=1,$id='',$color='red',$max_value=100,$min_value=0,$type=1,$operation='',$comment=''){ //Contentsオブジェクト作成 $cont = new Contents(); //IDセット $oid = $cont->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $cont->setData($contents,$start,$setbp,$setnum,$rownum); //オプションセット $cont->setOptions($color,$max_value,$min_value,$type); //操作XMLデータ $cont->setOperations($operation,$comment); //バッファ追加 $cont->writeBufferFile($this->bufferobject); //オブジェクト解放 $cont->__destruct(); } /** * 1塩基(アミノ酸残基)を描画 * @access public * @param int $start 描画開始点(X座標) * @param int $rownum 描画列番号 * @param int $width 描画幅(bp) * @param int $height 描画高(pixel) * @param string $color Box描画色 * @param int $objectid オブジェクトID * @param string $string 描画文字(列) * @param string $strcolor 描画文字色 * @param int $fontsize 描画文字サイズ * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawBase($start,$rownum,$width,$height,$id='',$color='red',$string='',$strcolor='', $fontsize=3,$operation='',$comment=''){ // public function setData($start,$rownum){ // public function setID($id,$uid,$oid){ // public function setOptions($width,$height,$color){ // public function setString($string,$strcolor,$fontsize){ //Baseオブジェクト作成 $base = new Base(); //IDセット $oid = $base->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $base->setData($start,$rownum); //オプションセット $base->setOptions($width,$height,$color); //Stringセット $base->setString($string,$strcolor,$fontsize,$this->fontfile); //操作XMLデータ $base->setOperations($operation,$comment); //バッファ追加 $base->writeBufferFile($this->bufferobject); //オブジェクト解放 $base->__destruct(); } /** * 塩基(アミノ酸)配列を描画 * @access public * @param int $start 描画開始位置(染色体上塩基数) * @param int $rownum 描画列番号 * @param int $width_base 描画幅(塩基数)=1文字が何塩基を示しているか * @param int $height 描画高 * @param array $colors Box描画色対応リスト * @param string $string 描画文字列 * @param int $split_num 文字セット基本数(文字数)=何文字を1BOXとするか * @param string $id オブジェクトID * @param boolean $dispstring 文字描画フラグ(TRUE/FALSE) * @param array $strcolors 描画文字色 * @param int $fontsize 描画文字サイズ * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawSequence($start,$rownum,$width_base,$height,$colors='red',$string='',$split_num=1,$id='',$dispstring=TRUE,$strcolors='', $fontsize=3,$operation='',$comment=''){ //Sequenceオブジェクト作成 $sequence = new Sequence(); //IDセット $oid = $sequence->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $sequence->setData($string,$start,$rownum); //オプションセット $sequence->setOptions($width_base,$height,$colors,$split_num); //ストリングセット $sequence->setString($fontsize,$strcolors,$dispstring,$this->fontfile); //操作XMLデータ $sequence->setOperations($operation,$comment); //バッファ追加 $sequence->writeBufferFile($this->bufferobject); //オブジェクト解放 $sequence->__destruct(); } /** * Markerを描画 * @access public * @param int $startx 配列開始点X座標 * @param int $rownum 列番号 * @param string $string 表示文字 * @param string $stringcol 表示文字色 * @param string $id オブジェクトID * @param string $makercolor Marker色 * @param int $markerwidth Marker横幅 * @param int $markerheight Marker縦幅 * @param int $fontsize 表示フォントサイズ * @param string $stringpos 表示文字位置 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawMarker($startx,$rownum,$string='',$stringcol='black',$id='',$markercolor='black',$markerwidth=1,$markerheight=1,$fontsize=1,$strpos='RIGHT',$operation='',$comment=''){ //Markerオブジェクト作成 $marker = new Marker(); //IDセット $oid = $marker->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $marker->setData($startx,$rownum); //Stringセット $marker->setString($string,$fontsize,$strpos,$stringcol,$this->fontfile); //オプションセット $marker->setOptions($markercolor,$markerwidth,$markerheight); //操作XMLデータ $marker->setOperations($operation,$comment); //バッファ追加 $marker->writeBufferFile($this->bufferobject); //オブジェクト解放 $marker->__destruct(); } /** * Enzymeを描画 * @access public * @param int $boxstartx Box開始点X座標 * @param int $boxendx Box終了点X座標 * @param int $cutupx 切断上辺X座標 * @param int $cutdownx 切断下辺X座標 * @param string $cutcolor 切断色 * @param string $boxcolor Box色 * @param string $string 表示文字 * @param int $fontsize 表示フォントサイズ * @param string $id オブジェクトID * @param int $rownum 列番号 * @param int $boxheight Box高さ * @param int $linewidth 線幅 * @param string $strpos 表示文字位置 * @param string $stringcol 表示文字色 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawEnzyme($boxstartx,$boxendx,$cutupx,$cutdownx,$cutcolor,$boxcolor,$string='',$fontsize=3,$id='',$rownum=1,$boxheight=0,$linewidth=1,$strpos='RIGHT',$stringcol='black',$operation='',$comment=''){ //Enzymeオブジェクト作成 $enzyme = new Enzyme(); //IDセット $oid = $enzyme->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $enzyme->setData($boxstartx,$boxendx,$rownum); //Stringセット $enzyme->setString($string,$fontsize,$strpos,$stringcol,$this->fontfile); //切断部データセット $enzyme->setCuts($cutupx,$cutdownx,$cutcolor); //オプションセット $enzyme->setOptions($boxheight,$boxcolor,$linewidth); //操作XMLデータ $enzyme->setOperations($operation,$comment); //バッファ追加 $enzyme->writeBufferFile($this->bufferobject); //オブジェクト解放 $enzyme->__destruct(); } /** * Rulerを描画 * @access public * @param int $uppoint 目盛上の増分 * @param string $dispspace 表示間隔 * @param string $unitname 単位 * @param int $fontsize 表示フォントサイズ * @param string $startx Ruler開始座標 * @param string $endx Ruler終了座標 * @param int $rulerspace Ruler間隔(Type2の目盛値が非表示のものまでの長さ) * @param string $id オブジェクトID * @param int $rownum 列番号 * @param int $rulertype Rulerタイプ * @param int $linewidth Ruler線幅 * @param int $rulerheight Ruler高さ(RulerType1の場合、文字の高さ以上に設定する必要あり) * @param int $startpoint 開始点数値(初期値) * @param string $rulercolor Ruler色 * @param string $delimitercol 区切り色 * @param string $stringcol 表示文字色 * @param string $strpos 表示文字位置 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawRuler($uppoint,$dispspace,$unitname,$fontsize,$startx,$endx,$rulerspace,$id='',$rownum=1,$rulertype=1,$linewidth=1,$rulerheight=1,$startpoint=0,$rulercolor='white',$delimitercol='black',$stringcol='red',$strpos='RIGHT',$operation='',$comment=''){ //Rulerオブジェクト作成 $ruler = new Ruler(); //IDセット $oid = $ruler->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $ruler->setData($startx,$endx,$rulerspace,$uppoint,$dispspace,$rulertype,$rownum); //Stringセット $ruler->setString($unitname,$fontsize,$strpos,$stringcol,$this->fontfile); //オプションセット $ruler->setOptions($linewidth,$rulerheight,$startpoint,$rulercolor,$delimitercol); //操作XMLデータ $ruler->setOperations($operation,$comment); //バッファ追加 $ruler->writeBufferFile($this->bufferobject); //オブジェクト解放 $ruler->__destruct(); } /** * Scaleを描画 * @access public * @param string $id オブジェクトID * @param int $startx Scale開始点(X座標全体に対する%) * @param int $endx Scale終了点(X座標全体に対する%) * @param int $starty Scale開始点(Y座標全体に対する%) * @param int $endy Scale終了点(Y座標全体に対する%) * @param int $linewidth Scale線幅 * @param int $dispspace Scale間隔(X座標全体に対する%) * @param string $scalecolor Scale色 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawScale($id='',$startx=0,$endx=100,$starty=0,$endy=100,$linewidth=1,$dispspace=10,$scalecolor='lightgrey',$operation='',$comment=''){ //Scaleオブジェクト作成 $scale = new Scale(); //IDセット $oid = $scale->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $scale->setData($startx,$endx,$starty,$endy); //オプションセット $scale->setOptions($linewidth,$dispspace,$scalecolor); //操作XMLデータ $scale->setOperations($operation,$comment); //バッファ追加 $scale->writeBufferFile($this->bufferobject); //オブジェクト解放 $scale->__destruct(); } /** * Chromosomeを描画 * @access public * @param int $chrostartx Chromosome描画開始点 * @param int $chroendx Chromosome描画終了点 * @param int $dispstartx 表示領域始点 * @param int $dispendx 表示領域終了点 * @param string $stringleft 左キャプション * @param string $stringright 右キャプション * @param string $id オブジェクトID * @param int $rownum 列番号 * @param string $chrotype Chromosome描画タイプ * @param int $chroheight Chromosome縦幅 * @param int $fontsize キャプションフォントサイズ * @param int $strposleft 左キャプション位置 * @param int $strposright 右キャプション位置 * @param int $uppoint 目盛上の増分(GBROWSE用) * @param int $delimspace 表示間隔(GBROWSE用) * @param string $unitname 単位(GBROWSE用) * @param string $chrocolor Chromosome色 * @param string $dispcolor 表示領域色 * @param string $stringcol キャプション色 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawChromosome($chrostartx,$chroendx,$dispstartx,$dispendx,$stringleft,$stringright,$id='',$rownum=1,$chrotype='UTGB',$chroheight=10,$fontsize=1,$strposleft='LEFT',$strposright='RIGHT',$uppoint=200,$delimspace=200,$unitname='k',$chrocolor='yellow',$dispcolor='steelblue',$stringcol='cornflowerblue',$operation='',$comment=''){ //Chromosomeオブジェクト作成 $chromosome = new Chromosome(); //IDセット $oid = $chromosome->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $chromosome->setData($chrostartx,$chroendx,$dispstartx,$dispendx,$chrotype,$chroheight,$uppoint,$delimspace,$rownum); //Stringセット $chromosome->setString($stringleft,$stringright,$unitname,$fontsize,$strposleft,$strposright,$stringcol,$this->fontfile); //オプションセット $chromosome->setOptions($chrocolor,$dispcolor); //操作XMLデータ $chromosome->setOperations($operation,$comment); //バッファ追加 $chromosome->writeBufferFile($this->bufferobject); //オブジェクト解放 $chromosome->__destruct(); } /** * Legendを描画 * @access public * @param string $string 表示文字 * @param string $stringcol 表示文字色 * @param string $id オブジェクトID * @param int $rownum 列番号 * @param int $fontsize 表示文字フォントサイズ * @param int $legstartx Legend開始点X座標 * @param int $legstarty Legend開始点Y座標(列中央に対する) * @param int $boxwidth LegendBox幅※BOX表示がない場合は0 * @param int $boxcolor LegendBox色 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawLegend($string,$stringcol,$id='',$rownum=1,$fontsize=1,$legstartx=0,$legstarty=0,$boxwidth=0,$boxcolor='black',$operation='',$comment=''){ // public function drawLegend($string,$stringcol,$id='',$rownum=1,$fontsize=1,$legstartx=0,$legstarty=0,$strpos='RIGHT',$boxwidth=0,$boxcolor='black',$operation='',$comment=''){ //Legendオブジェクト作成 $legend = new Legend(); //IDセット $oid = $legend->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $legend->setData($legstartx,$legstarty,$rownum); //Stringセット $legend->setString($string,$fontsize,'RIGHT',$stringcol,$this->fontfile); //オプションセット $legend->setOptions($boxwidth,$boxcolor); //操作XMLデータ $legend->setOperations($operation,$comment); //バッファ追加 $legend->writeBufferFile($this->bufferobject); //オブジェクト解放 $legend->__destruct(); } /** * Lengthを描画 * @access public * @param int $lenstartx Length開始点X座標 * @param int $lenendx Length終了点X座標 * @param string $string 表示文字 * @param int $fontsize 表示文字フォントサイズ * @param string $drawcolor Length、表示文字色 * @param string $id オブジェクトID * @param int $rownum 列番号 * @param int $linewidth 線幅 * @param int $strand 矢印向き(1=右,-1=左) * @param int $delimspace 区切線間隔 * @param int $delimheight 区切線縦幅(Y軸) * @param int $strpos 表示文字位置 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawLength($lenstartx,$lenendx,$string,$fontsize,$drawcolor,$id='',$rownum=1,$linewidth=1,$strand=1,$delimspace=50,$delimheight=5,$strpos='RIGHT',$operation='',$comment=''){ //lengthオブジェクト作成 $length = new Length(); //IDセット $oid = $length->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $length->setData($lenstartx,$lenendx,$linewidth,$rownum); //Stringセット $length->setString($string,$fontsize,$strpos,$drawcolor,$this->fontfile); //オプションセット $length->setOptions($strand,$delimspace,$delimheight); //操作XMLデータ $length->setOperations($operation,$comment); //バッファ追加 $length->writeBufferFile($this->bufferobject); //オブジェクト解放 $length->__destruct(); } /** * 画像を挿入する * @access public * @param string $filepath 挿入する画像のパス * @param int $pos 挿入する位置(bp) * @param int $height 挿入する高さ(詳細要検討) * @param int $size 画像サイズ * @param string $mode 挿入モード * @param int $rownum 描画列番号 * @param string $id オブジェクトID * @param string $string 表示文字(キャプション等) * @param string $strcolor 表示文字色 * @param string $strpos 表示文字位置 * @param int $fontsize 表示文字サイズ * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function insertPicture($filepath,$pos,$height,$size,$mode,$rownum=1,$id='',$string='',$strcolor='black',$strpos='RIGHT',$fontsize=2,$operation='',$comment=''){ // public function setData($filepath,$pos,$rownum){ // public function setID($id,$uid,$oid){ // public function setOptions($height,$size,$mode){ // public function setString($string,$strcolor,$strpos,$fontsize){ //Pictureオブジェクト作成 $picture = new Picture(); //IDセット $oid = $picture->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $picture->setData($filepath,$pos,$rownum); //オプションセット $picture->setOptions($height,$size,$mode); //ストリングセット $picture->setString($string,$fontsize,$strpos,$strcolor,$this->fontfile); //操作XMLデータ $picture->setOperations($operation,$comment); // //バッファ追加 $picture->writeBufferFile($this->bufferobject); //オブジェクト解放 $picture->__destruct(); } /** * TilingArrayを描画 * @access public * @param array $start Probe始点 * @param int $end Probe終点 * @param int $signal シグナル強度 * @param string $color シグナル描画色 * @param int $alpha 透過度 * @param string $frame 枠線色 * @param int $max 最大値(透過度=0) * @param int $min 最小値(透過度=127) * @param int $rownum 描画列番号 * @param int $height Boxタイプ * @param string $id オブジェクトID * @param string $type 描画形態タイプ * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawTilingArray($start,$end,$signal,$color='',$alpha=0,$frame='',$max=0,$min=0,$rownum=1,$height='100%',$id='',$type='Box',$operation='',$comment=''){ //TilingArrayオブジェクト作成 $tilingArray = new TilingArray(); //IDセット $oid = $tilingArray->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $tilingArray->setData($start,$end,$signal,$rownum); //オプションセット $tilingArray->setOptions($height,$color,$alpha,$frame,$type,$max,$min); //操作XMLデータ $tilingArray->setOperations($operation,$comment); //バッファ追加 $tilingArray->writeBufferFile($this->bufferobject); //オブジェクト解放 $tilingArray->__destruct(); } /** * INDEXを描画 * @access public * @param string $string Index文字列 * @param int $rownum 描画列番号 * @param string $strcolor 文字色 * @param int $fontsize フォントサイズ * @param string $id オブジェクトID * @param string $alignx 文字描画位置(横方向) * @param string $aligny 文字描画位置(縦方向) * @param string $marginx 余白(横方向、alignxがRIGHT/LEFTの時) * @param string $marginy 余白(縦方向、alignyがtop/bottomの時) * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawIndex($string,$rownum,$strcolor='black',$fontsize=3,$id='',$alignx='CENTER',$aligny='CENTER',$marginx=0,$marginy=0,$operation='',$comment=''){ //Indexオブジェクト作成 $index = new Index(); //IDセット $oid = $index->setID($id,$this->uid,$this->oid); $this->oid = $oid; //データセット $index->setData($rownum); //オプションセット $index->setOptions($alignx,$aligny,$marginx,$marginy); //ストリングセット $index->setString($string,$fontsize,$strcolor,$this->fontfile); //操作XMLデータ $index->setOperations($operation,$comment); //バッファ追加 $index->writeBufferFile($this->bufferobject); //オブジェクト解放 $index->__destruct(); } //基本図形描画メソッド /** * Lineを描画(画像座標) * @access public * @param int $x1 Line始点X座標 * @param int $y1 Line始点Y座標 * @param int $x2 Line終点X座標 * @param int $y2 Line終点Y座標 * @param string $col Line基本色 * @param int $size Lineの太さ */ public function renderLine($x1, $y1, $x2, $y2, $color='black', $size=1){ $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagesetthickness($this->image,$size); imageline($this->image,$x1,$y1,$x2,$y2,$col); } /** * Lineを描画 * @access public * @param int $rownum 描画列番号 * @param int $start_x Line始点X座標 * @param int $start_y Line始点Y座標(列中央に対する) * @param int $end_x Line終点X座標 * @param int $end_y Line終点Y座標(列中央に対する) * @param string $color Line基本色 * @param int $size Lineの太さ * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLine($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$id='',$operation='',$comment='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start_x; $object_end_pos = $end_x; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLine'; $fc_args = "$start_x|$start_y|$end_x|$end_y|$color|$size"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start_x); $x2 = self::convertPositionString($end_x); $row_center = self::convertRowToHeight($rownum); $y1 = $row_center + $start_y; $y2 = $row_center + $end_y; //renderLineに丸投げ self::renderLine($x1,$y1,$x2,$y2,$color,$size); } /** * 水平Lineを描画 * @access public * @param int $rownum 描画列番号 * @param int $start Line始点X座標 * @param int $end Line終点X座標 * @param int $pos_y LineのY座標(列中央に対する) * @param string $color Line基本色 * @param int $size Lineの太さ * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLineX($rownum,$start,$end,$pos_y,$color='black',$size=1,$id='',$operation='',$comment='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $end; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLineX'; $fc_args = "$start|$end|$pos_y|$color|$size"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start); $x2 = self::convertPositionString($end); $row_center = self::convertRowToHeight($rownum); $y = $row_center + $pos_y; //renderLineに丸投げ self::renderLine($x1,$y,$x2,$y,$color,$size); } /** * 垂直Lineを描画 * @access public * @param int $rownum 描画列番号 * @param int $pos_x LineのX座標 * @param int $start Line始点Y座標(列中央に対する) * @param int $end Line終点Y座標(列中央に対する) * @param string $color Line基本色 * @param int $size Lineの太さ * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLineY($rownum,$pos_x,$start,$end,$color='black',$size=1,$id='',$operation='',$comment='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $pos_x; $object_end_pos = $pos_x; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLineY'; $fc_args = "$pos_x|$start|$end|$color|$size"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x = self::convertPositionString($pos_x); $row_center = self::convertRowToHeight($rownum); $y1 = $row_center + $start; $y2 = $row_center + $end; //renderLineに丸投げ self::renderLine($x,$y1,$x,$y2,$color,$size); } /** * 山形Lineを描画 * @access public * @param int $rownum 描画列番号 * @param int $start_x Line始点X座標 * @param int $end_x Line終点X座標 * @param int $posy LineY座標(列中央に対する) * @param int $f_size 折れる高さ * @param int $f_dir 山:+1 谷:-1 * @param string $color Line基本色 * @param int $size Lineの太さ * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLineYFolded($rownum,$start_x,$end_x,$posy,$f_size,$f_dir=1,$color='black',$size=1,$id='',$operation='',$comment='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start_x; $object_end_pos = $end_x; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLineYFolded'; $fc_args = "$start_x|$end_x|$posy|$f_size|$f_dir|$color|$size"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start_x); $x2 = self::convertPositionString($end_x); //Y座標 if($rownum){ $row_center = self::convertRowToHeight($rownum); }else{ $row_center = 0; } if($posy){ $position_y = self::convertHeight($posy); }else{ $position_y = 0; } $y = $row_center + $position_y; //中間点X座標 $mid_x = ($x1+$x2)/2; //中間点Y座標 if($f_dir > 0){ $mid_y = $y - $f_size; }else{ $mid_y = $y + $f_size; } //renderLineに丸投げ self::renderLine($x1,$y,$mid_x,$mid_y,$color,$size); self::renderLine($mid_x,$mid_y,$x2,$y,$color,$size); } /** * Lineを描画(拡張Y座標対応) * @access public * @param int $rownum 描画列番号 * @param string $start_x Line始点X座標 * @param string $start_y Line始点Y座標 * @param string $end_x Line終点X座標 * @param string $end_y Line終点Y座標 * @param string $color Line基本色 * @param int $size Lineの太さ * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLineAlpha($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$id='',$operation='',$comment='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start_x; $object_end_pos = $end_x; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLineAlpha'; $fc_args = "$start_x|$start_y|$end_x|$end_y|$color|$size"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start_x); $x2 = self::convertPositionString($end_x); if($rownum){ $y1 = self::convertRowToHeight($rownum) + self::convertHeight($start_y); $y2 = self::convertRowToHeight($rownum) + self::convertHeight($end_y); }else{ $y1 = self::convertHeight($start_y); $y2 = self::convertHeight($end_y); } //renderLineに丸投げ self::renderLine($x1,$y1,$x2,$y2,$color,$size); } /** * 矢印付Lineを描画 * @access public * @param int $rownum 描画列番号 * @param int $start_x Line始点X座標 * @param int $start_y Line始点Y座標(列中央に対する) * @param int $end_x Line終点X座標 * @param int $end_y Line終点Y座標(列中央に対する) * @param int $color Line基本色 * @param int $size Lineの太さ * @param boolean $start_flg 矢印の有無(始点) * @param boolean $end_flg 矢印の有無(終点) * @param int $height 矢頭の幅 * @param string $arrowcolor 矢頭の色 * @param int $style 矢頭のスタイル * @param int $angle1 矢頭の角度(矢印の方向+1に対して、列中央を基準に三角形上の角度。-1では下) * @param int $angle2 矢頭の角度(矢印の方向+1に対して、列中央を基準に三角形下の角度。-1では上) * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLineArrow($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$start_flg=FALSE,$end_flg=TRUE,$height=10,$arrowcolor='',$style=1,$angle1=45,$angle2=45,$id='',$operation='',$comment='',$direct=TRUE){ // public function drawLineArrow($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$start_flg=FALSE,$end_flg=TRUE,$height=10,$arrowcolor='',$style=1,$angle=45,$direct=TRUE){ // public function drawLineArrow($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$start_flg=FALSE,$end_flg=TRUE,$height=10,$arrowcolor='',$style=1,$angle1=45,$angle2=45,$direct=TRUE){ // if(!($angle1)){ // $angle1 = 45; // } // if(!($angle2)){ // $angle2 = 45; // } if(!($angle1) && !($angle2)){ $angle1 = 45; $angle2 = 45; } //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start_x; $object_end_pos = $end_x; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLineArrow'; $fc_args = "$start_x|$start_y|$end_x|$end_y|$color|$size|$start_flg|$end_flg|$height|$arrowcolor|$style|$angle1|$angle2"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //とりあえず水平・垂直線のみについて作成 //座標変換 $x1 = self::convertPositionString($start_x); $x2 = self::convertPositionString($end_x); $row_center = self::convertRowToHeight($rownum); $y1 = $row_center + $start_y; $y2 = $row_center + $end_y; // self::addDebugMessage("$x1,$x2,$y1,$y2,$color,$size",1); if(!($color)){ $color = 'black'; } if(!($size)){ $size = 1; } //Line部分の表示 self::renderLine($x1,$y1,$x2,$y2,$color,$size); //矢頭部分の表示 ////色設定 if(!($arrowcolor)){ $arrowcolor = $color; } //向きの判定 if($x1==$x2){ if($y1<$y2){ $start_dir = 90; $end_dir = 270; }else{ $start_dir = 270; $end_dir = 90; } }else{ if($x1<$x2){ $start_dir = 180; $end_dir = 0; }else{ $start_dir = 0; $end_dir = 180; } } //始点 if($start_flg){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($x1,$y1,$start_dir,$style,$arrowcolor,$size,$height,$angle); self::drawArrowHead($x1,$y1,$start_dir,$style,$arrowcolor,$size,$height,$angle1,$angle2); } //終点 if($end_flg){ // self::drawArrowHead($x2,$y2,$end_dir,$style,$arrowcolor,$size,$height,$angle); self::drawArrowHead($x2,$y2,$end_dir,$style,$arrowcolor,$size,$height,$angle1,$angle2); } } /** * 反復矢印付Lineを描画 * @access public * @param int $rownum 描画列番号 * @param int $start_x Line始点X座標 * @param int $start_y Line始点Y座標(列中央に対する) * @param int $end_x Line終点X座標 * @param int $end_y Line終点Y座標(列中央に対する) * @param int $color Line基本色 * @param int $size Lineの太さ * @param boolean $arrow_dir 矢印の方向(+1/-1) * @param boolean $interval 矢頭の表示間隔 * @param int $height 矢頭の幅 * @param string $arrowcolor 矢頭の色 * @param int $style 矢頭のスタイル * @param int $angle1 矢頭の角度(矢印の方向+1に対して、列中央を基準に三角形上の角度。-1では下) * @param int $angle2 矢頭の角度(矢印の方向+1に対して、列中央を基準に三角形下の角度。-1では上) * @param string $id オブジェクトID * @param string $operation 操作XMLデータ * @param string $comment コメント * @param boolean $direct 直接描画 */ public function drawLineArrowMulti($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$arrow_dir=1,$interval=10,$height=10,$arrowcolor='',$style=1,$angle1=45,$angle2=45,$id='',$operation='',$comment='',$direct=TRUE){ // public function drawLineArrowMulti($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$arrow_dir=1,$interval=10,$height=10,$arrowcolor='',$style=1,$angle=45,$direct=TRUE){ // public function drawLineArrowMulti($rownum,$start_x,$start_y,$end_x,$end_y,$color='black',$size=1,$arrow_dir=1,$interval=10,$height=10,$arrowcolor='',$style=1,$angle1=45,$angle2=45,$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start_x; $object_end_pos = $end_x; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawLineArrowMulti'; $fc_args = "$start_x|$start_y|$end_x|$end_y|$color|$size|$arrow_dir|$interval|$height|$arrowcolor|$style|$angle1|$angle2"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //とりあえず水平・垂直線のみについて作成 //座標変換 $x1 = self::convertPositionString($start_x); $x2 = self::convertPositionString($end_x); $row_center = self::convertRowToHeight($rownum); $y1 = $row_center + $start_y; $y2 = $row_center + $end_y; // self::addDebugMessage("$x1,$x2,$y1,$y2,$color,$size",1); if(!($color)){ $color = 'black'; } if(!($size)){ $size = 1; } //Line部分の表示 self::renderLine($x1,$y1,$x2,$y2,$color,$size); //矢頭部分の表示 ////色設定 if(!($arrowcolor)){ $arrowcolor = $color; } // return TRUE; //向きの判定と矢頭表示点の設定 if($x1==$x2){ $x = $x1; // if($angle1 > 0 && $angle2 > 0){ list($widtha,$heighta) = self::calcArrowSize($height,$angle2,$angle1); } if($y1<$y2){ $start_dir = 90; $end_dir = 270; if($arrow_dir == 1){ for($i=$y2;$i>$y1+$widtha;$i-=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($x,$i,$end_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($x,$i,$end_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } }else{ for($i=$y1;$i<$y2-$widtha;$i+=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($x,$i,$start_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($x,$i,$start_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } } }else{ $start_dir = 270; $end_dir = 90; if($arrow_dir == 1){ for($i=$y2;$i<$y1-$widtha;$i+=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($x,$i,$end_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($x,$i,$end_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } }else{ for($i=$y1;$i>$y2+$widtha;$i-=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($x,$i,$start_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($x,$i,$start_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } } } }else{ //水平方向のLine $y = $y1; // if($angle1 > 0 && $angle2 > 0){ list($widtha,$heighta) = self::calcArrowSize($height,$angle2,$angle1); } if($x1<$x2){ $start_dir = 180; $end_dir = 0; if($arrow_dir == 1){ for($i=$x2;$i>$x1+$widtha;$i-=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($i,$y,$end_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($i,$y,$end_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } }else{ for($i=$x1;$i<$x2-$widtha;$i+=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($i,$y,$start_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($i,$y,$start_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } } }else{ $start_dir = 0; $end_dir = 180; if($arrow_dir == 1){ for($i=$x2;$i<$x1-$widtha;$i+=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($i,$y,$end_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($i,$y,$end_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } }else{ for($i=$x1;$i>$x2+$widtha;$i-=$interval){ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45){ // self::drawArrowHead($i,$y,$start_dir,1,$arrowcolor,$size,$height,$angle); self::drawArrowHead($i,$y,$start_dir,1,$arrowcolor,$size,$height,$angle1,$angle2); } } } } } /** * 矢頭を描画 DELETE * @access public * @param int $x 矢頭頂点のX座標 * @param int $y 矢頭頂点のY座標 * @param int $direction 矢頭の向き(上下左右?) * @param string $style 矢頭のスタイル * @param string $color 矢頭の色 * @param int $size 矢頭の線の太さ(スタイルに依る) * @param int $height 矢頭の幅 * @param int $angle 矢頭の開き角度 */ /** public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle=45,$direct=TRUE){ //三角関数による矢頭の長さの取得 if($angle >= 90){ $angle = 90; $angle_rad = deg2rad($angle); $width = 0; }else{ $angle_rad = deg2rad($angle); $tangent = tan($angle_rad); if($tangent > 0){ $width = $height/(2*$tangent); }else{ $width = $height; } } //directionによる座標の設定 //とりあえず反時計回りにX軸方向から0/90/180/270 if($direction == 90){ //1つ目の端点 $x1 = $x + $height/2; $y1 = $y + $width; //2つ目の端点 $x2 = $x - $height/2; $y2 = $y1; }elseif($direction==180){ //1つ目の端点 $x1 = $x + $width; $y1 = $y - $height/2; //2つ目の端点 $x2 = $x1; $y2 = $y + $height/2; }elseif($direction==270){ //1つ目の端点 $x1 = $x + $height/2; $y1 = $y - $width; //2つ目の端点 $x2 = $x - $height/2; $y2 = $y1; }else{ //1つ目の端点 $x1 = $x - $width; $y1 = $y - $height/2; //2つ目の端点 $x2 = $x1; $y2 = $y + $height/2; } self::renderLine($x,$y,$x1,$y1,$color,$size); self::renderLine($x,$y,$x2,$y2,$color,$size); } */ /** * 矢頭を描画 * @access public * @param int $x 矢頭頂点のX座標 * @param int $y 矢頭頂点のY座標 * @param int $direction 矢頭の向き(上下左右?) * @param string $style 矢頭のスタイル * @param string $color 矢頭の色 * @param int $size 矢頭の線の太さ(スタイルに依る) * @param int $height 矢頭の幅 * @param int $angle 矢頭の開き角度1(X座標に対する上側の矢の角度)※矢頭の向きが右の場合。他の方向の場合は矢印が回転するイメージで対象が変わる。 * @param int $angle 矢頭の開き角度2(X座標に対する下側の矢の角度)※矢頭の向きが右の場合。他の方向の場合は矢印が回転するイメージで対象が変わる。 * @param boolean $direct 直接描画 */ // public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle1=45,$angle2=45,$direct=TRUE){ public function drawArrowHead($x,$y,$direction=0,$style=1,$color='black',$size=1,$height=5,$angle1=45,$angle2=45){ //矢頭の内側の広がり角度 if($angle1 > 90){ $angle1 = 90; } if($angle2 > 90){ $angle2 = 90; } $width1 = 0; $width2 = 0; $height1 = 0; $height2 = 0; //角度1の三角形における中央ラインの長さと、高さ if($angle1 > 0){ list($width1,$height1) = self::calcArrowSize($height,$angle2,$angle1); } //角度2の三角形における中央ラインの長さと、高さ if($angle2 > 0){ list($width2,$height2) = self::calcArrowSize($height,$angle1,$angle2); } //directionによる座標の設定 //とりあえず反時計回りにX軸方向から0/90/180/270 if($direction == 90){ //1つ目の端点 $x1 = $x - $height1; $y1 = $y + $width1; //2つ目の端点 $x2 = $x + $height2; $y2 = $y + $width2; }elseif($direction==180){ //1つ目の端点 $x1 = $x + $width1; $y1 = $y + $height1; //2つ目の端点 $x2 = $x + $width2 ; $y2 = $y - $height2; }elseif($direction==270){ //1つ目の端点 $x1 = $x + $height1; $y1 = $y - $width1; //2つ目の端点 $x2 = $x - $height2; $y2 = $y - $width2; }else{ //1つ目の端点 $x1 = $x - $width1; $y1 = $y - $height1; //2つ目の端点 $x2 = $x - $width2; $y2 = $y + $height2; } //塗りつぶし矢頭 if($style == 2){ //角度0の場合 if($angle1 == 0){ $x1 = $x2; $y1 = $y; } //角度0の場合 if($angle2 == 0){ $x2 = $x1; $y2 = $y; } $coods_converted = array($x,$y,$x1,$y1,$x2,$y2); $coodsnum = 3;// 三角形 $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagefilledpolygon($this->image,$coods_converted,$coodsnum,$col); //ライン矢頭 }else{ self::renderLine($x,$y,$x1,$y1,$color,$size); self::renderLine($x,$y,$x2,$y2,$color,$size); } } /** * Boxを描画 * @access public * @param int $rownum 描画列番号 * @param int $start Box始点X座標 * @param int $end Box終点X座標 * @param int $height Boxの高さ * @param string $color Box基本色 * @param string $frame Box枠線色 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawBox($rownum,$start,$end,$height,$color='',$frame='',$operation='',$comment='',$id='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $end; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawBox'; $fc_args = "$start|$end|$height|$color|$frame"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start); $x2 = self::convertPositionString($end); $row_center = self::convertRowToHeight($rownum); if(eregi("([0-9]+)(%)",$height,$pat)){ $up_max = floor(($this->rowheight-1)/2); $up_height = round($pat[1]*$up_max/100,0); $under_max = ceil(($this->rowheight-1)/2); $under_height = round($pat[1]*$under_max/100,0); $y1 = $row_center - $up_height; $y2 = $row_center + $under_height; }else{ $box_height = $height; $y1 = $row_center - floor($box_height/2); $y2 = $row_center + ceil($box_height/2); } // self::log_info("$row_center, $y1,$y2\n"); //色関係 if($color){ $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagefilledrectangle($this->image,$x1,$y1,$x2,$y2,$col); } if($frame){ $col_array2 = ColorUtil::getRGB($frame); $col2 = imagecolorallocate($this->image,$col_array2[0],$col_array2[1],$col_array2[2]); imagerectangle($this->image,$x1,$y1,$x2,$y2,$col2); } // self::createXMLStringFromPositions($x1,$y1,$x2,$y2,$op_type,$op_args); if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x1,$y1,$x2,$y2,$operation,$comment); } } /** * 棒グラフ様Boxを描画 * @access public * @param int $rownum 描画列番号 * @param int $start Box始点X座標 * @param int $end Box終点X座標 * @param int $top 上辺の高さ(列下辺からの) * @param int $bottom 下辺高さ(列下辺からの) * @param string $color Box基本色 * @param string $frame Box枠色 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawBoxGraph($rownum,$start,$end,$top,$bottom=0,$color='',$frame='',$operation='',$comment='',$id='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $end; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawBoxGraph'; $fc_args = "$start|$end|$top|$bottom|$color|$frame"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start); $x2 = self::convertPositionString($end); $row_bottom = self::convertRowToBottomHeight($rownum); //TOPの高さ if(eregi("(.+)(%)",$top,$pat)){ $top_height = $pat[1]*($this->rowheight-1)/100; }else{ $top_height = $top; } //BOTTOMの高さ if(eregi("(.+)(%)",$bottom,$pat)){ $bottom_height = $pat[1]*($this->rowheight-1)/100; }else{ $bottom_height = $bottom; } //Y座標 $y1 = $row_bottom - round($top_height,0); $y2 = $row_bottom - round($bottom_height,0); //前列最下ピクセル if($rownum == 1){ $prev_bottom = $this->originy -1; }else{ $prev_bottom = self::convertRowToBottomHeight($rownum - 1); } // self::log_info("$row_center, $y1,$y2\n"); if($y1 <= $prev_bottom +1){ $y1 += 1; } //色関係 if($color){ $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagefilledrectangle($this->image,$x1,$y1,$x2,$y2,$col); } if($frame){ $col_array = ColorUtil::getRGB($frame); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagerectangle($this->image,$x1,$y1,$x2,$y2,$col); } // self::createXMLStringFromPositions($x1,$y1,$x2,$y2,$op_type,$op_args); if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x1,$y1,$x2,$y2,$operation,$comment); } } /** * 透過度のあるBoxを描画 * @access public * @param int $rownum 描画列番号 * @param int $start Box始点X座標 * @param int $end Box終点X座標 * @param int $height Boxの高さ * @param string $color Box基本色 * @param string $alpha 透過度 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawBoxAlpha($rownum,$start,$end,$height,$color='',$alpha=0,$operation='',$comment='',$id='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $end; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawBoxAlpha'; $fc_args = "$start|$end|$height|$color|$alpha"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start); $x2 = self::convertPositionString($end); $row_center = self::convertRowToHeight($rownum); $prev_bottom = self::convertRowToBottomHeight($rownum - 1); if(eregi("([0-9]+)(%)",$height,$pat)){ $up_max = floor(($this->rowheight-1)/2); $up_height = round($pat[1]*$up_max/100,0); $under_max = ceil(($this->rowheight-1)/2); $under_height = round($pat[1]*$under_max/100,0); $y1 = $row_center - $up_height; $y2 = $row_center + $under_height; }else{ $box_height = $height; $y1 = $row_center - floor($box_height/2); $y2 = $row_center + ceil($box_height/2); } // self::log_info("$row_center, $y1,$y2\n"); if($y1 <= $prev_bottom){ $y1 += 1; } // if($y2 > $row_bottom){ // $y2 = $row_bottom; // } //色関係 if($color){ $col_array = ColorUtil::getRGB($color); $col = imagecolorallocatealpha($this->image,$col_array[0],$col_array[1],$col_array[2],$alpha); imagefilledrectangle($this->image,$x1,$y1,$x2,$y2,$col); } // self::createXMLStringFromPositions($x1,$y1,$x2,$y2,$op_type,$op_args); if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x1,$y1,$x2,$y2,$operation,$comment); } } /** * BoxSharpを描画 * @access public * @param int $start Box始点X座標 * @param int $end Box終点X座標 * @param int $height Box縦幅 * @param string $color Box基本色 * @param string $strand Sharp部分の方向 * @param string $angle Sharp部分の鋭利さ * @param string $frame 枠線色 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawBoxSharp($rownum,$start,$end,$height,$color='',$strand=1,$angle=45,$frame='',$operation='',$comment='',$id='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $end; $string_extend_pixel = 0; $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawBoxSharp'; $fc_args = "$start|$end|$height|$color|$strand|$angle|$frame"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //座標変換 $x1 = self::convertPositionString($start); $x2 = self::convertPositionString($end); $row_center = self::convertRowToHeight($rownum); //座標変換 $start_converted = self::convertPositionString($start); $end_converted = self::convertPositionString($end); if($start_converted < $end_converted){ $x1 = $start_converted; $x2 = $end_converted; }else{ $x1 = $end_converted; $x2 = $start_converted; } // $this->debugobject->addDebugMessage("$x1 - $x2",1); $width = abs($x2-$x1); $row_center = self::convertRowToHeight($rownum); $y1 = $row_center - floor($height/2); $y2 = $row_center + ceil($height/2); // self::log_info("$row_center, $y1,$y2\n"); //三角関数による鋭利部分の幅計算 if($angle >= 90){ $angle = 90; $angle_rad = deg2rad($angle); $sharp_width = 0; }else{ $angle_rad = deg2rad($angle); $tangent = tan($angle_rad); if($tangent > 0){ $sharp_width = $height/(2*$tangent); }else{ $sharp_width = $width; } } if($sharp_width > $width){ $sharp_width = $width; } // self::drawString("$angle_rad : $tangent : $sharp_width",400,180,3,'black'); //strand向き分岐 if($strand == 1){ //polygon描画点設定 $points = array($x1,$y1,$x2-$sharp_width,$y1,$x2,$y1+$height/2,$x2-$sharp_width,$y1+$height,$x1,$y1+$height); }else{ //polygon描画点設定 $points = array($x1,$y1+$height/2,$x1+$sharp_width,$y1,$x2,$y1,$x2,$y1+$height,$x1+$sharp_width,$y1+$height); } //描画 //color有り if($color){ //色設定 $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagefilledpolygon($this->image,$points,5,$col); } //frame有り if($frame){ $col_array2 = ColorUtil::getRGB($frame); $col2 = imagecolorallocate($this->image,$col_array2[0],$col_array2[1],$col_array2[2]); imagepolygon($this->image,$points,5,$col2); } //XML作成 if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x1,$y1,$x2,$y2,$operation,$comment); } } /** * 多角形を描画 * @access public * @param int $rownum 描画列番号 * @param array $coods 頂点座標(染色体位置と描画列の底からの高さ%) * @param int $coodsnum 頂点数 * @param int $color 描画色 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawPolygon($rownum,$coods,$coodsnum,$color='red',$operation='',$comment='',$id='',$direct=TRUE){ //直接描画 if(!($direct)){ //占有領域取得 $pos_y = array($coods[0][1]); $pos_x = array($coods[0][0]); $buf_coods = $pos_x[0]."_".$pos_y[0]; for($i=1;$iuid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } $count = count($coods); $height = $this->rowheight-1; $base = self::convertRowToBottomHeight($rownum); $coods_converted = array(); foreach($coods as $cood){ $x_converted = self::convertPositionString($cood[0]); $y_converted = round($base - $height*$cood[1]/100,0); array_push($coods_converted,$x_converted); array_push($coods_converted,$y_converted); } //print_r($coods_converted); $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); imagefilledpolygon($this->image,$coods_converted,$coodsnum,$col); // self::addDebugMessage("$count,$coodsnum,$rownum,$base,$color ",1); // self::addDebugMessage(" ".$coods[1][0]." ".$coods[1][1]); } /** * 文字列を描画 * @access public * @param int $fontsize フォントサイズ * @param int $x String始点X座標 * @param int $y String始点Y座標 * @param int $string フォントサイズ * @param string $color 色文字列 */ public function renderString($fontsize,$x,$y,$string,$color,$ttf_file=''){ $col_array = ColorUtil::getRGB($color); $col = imagecolorallocate($this->image,$col_array[0],$col_array[1],$col_array[2]); if($ttf_file){ imagettftext($this->image,$fontsize,0,$x,$y,$col,$ttf_file,$string); }else{ imagestring($this->image, $fontsize, $x, $y, $string, $col); } } /** * 文字列を描画 * @access public * @param int $rownum 描画列番号 * @param string $string 描画文字列 * @param int $start String始点X座標(染色体位置) * @param int $fontsize フォントサイズ * @param string $color 色文字列 * @param string $strpos 文字描画位置 * @param string $margin 文字前余白 * @param string $posy 文字縦方向位置 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawString($rownum,$string,$start,$fontsize=3,$color='black',$strpos='RIGHT',$margin=0,$posy=0,$operation='',$comment='',$id='',$direct=TRUE){ // $this->debugobject->addDebugMessage("$rownum,$string,$start,$fontsize,$color,$strpos,$margin,$posy",1); //直接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $start; list($sw,$sh) = StringUtil::myGetStringSize($string,$fontsize); if($strpos=='LEFT'){ $string_extend_pixel = -$sw; }else{ $string_extend_pixel = $sw; } $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawString'; $fc_args = "$string|$start|$fontsize|$color|$strpos|$margin|$posy"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //ポジション指定(X軸) $occupy_x1_converted = self::convertPositionString($start); //ポジション指定(Y軸) if($rownum){ $row_center = self::convertRowToHeight($rownum); }else{ $row_center = 0; } if($posy){ $postition_y = self::convertHeight($posy); }else{ $postition_y = 0; } //座標変換 list($fontwidth,$fontheight) = StringUtil::myGetStringSize($string,$fontsize); if($strpos == 'LEFT'){ $x = $occupy_x1_converted - $margin - $fontwidth; }else{ $x = $occupy_x1_converted + $margin; } $y = $row_center + $postition_y; $y -= $fontheight/2; self::renderString($fontsize, $x, $y, $string,$color); //self::drawString($args[0],$string_start,$args[2],$args[3],$args[4]); //XML作成 if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x,$y,$x+$fontwidth,$y+$fontheight,$operation,$comment); } } /** * TTFフォントの文字列を描画 * フォントファイルはメンバにセットされたものを使用 * @access public * @param int $rownum 描画列番号 * @param string $string 描画文字列 * @param int $start String始点X座標(染色体位置) * @param int $fontsize フォントサイズ * @param string $color 色文字列 * @param string $strpos 文字描画位置 * @param string $margin 文字前余白 * @param string $posy 文字縦方向位置 * @param string $operation 操作XMLデータ * @param string $comment コメント * @param string $id オブジェクトID * @param boolean $direct 直接描画 */ public function drawStringTTF($rownum,$string,$start,$fontsize=10,$color='black',$strpos='RIGHT',$margin=0,$posy=0,$operation='',$comment='',$id='',$direct=TRUE){ // $this->debugobject->addDebugMessage("$rownum,$string,$start,$fontsize,$color,$strpos,$margin,$posy",1); if(!($this->fontfile)){ self::drawString($rownum,$string,$start,$fontsize,$color,$strpos,$margin,$posy,$operation,$comment,$id,$direct); return; } //間接描画 if(!($direct)){ //占有領域取得 $object_start_pos = $start; $object_end_pos = $start; //フォントサイズ $array = StringUtil::myGetStringSizeTTF($string,$fontsize,$this->fontfile); if($strpos=='LEFT'){ $string_extend_pixel = -$array[2]; }else{ $string_extend_pixel = $array[2]; } $occupied_args = "$object_start_pos|$object_end_pos|$string_extend_pixel|$rownum"; //メソッド設定 $function = 'drawStringTTF'; $fc_args = "$string|$start|$fontsize|$color|$strpos|$margin|$posy"; if(!($id)){ $id = $this->uid."_".$this->oid; $this->oid++; } //バッファ格納 $this->bufferobject->myAddBufferFile($id,$occupied_args,$function,$fc_args,$operation,$comment); //リターン return; } //フォントサイズ $array = StringUtil::myGetStringSizeTTF($string,$fontsize,$this->fontfile); //ポジション指定(X軸) $occupy_x1_converted = self::convertPositionString($start); //ポジション指定(Y軸) if($rownum){ $row_center = self::convertRowToHeight($rownum); }else{ $row_center = 0; } if($posy){ $postition_y = self::convertHeight($posy); }else{ $postition_y = 0; } if($strpos == 'LEFT'){ $x = $occupy_x1_converted - $margin - $array[2]; }else{ $x = $occupy_x1_converted + $margin; } $y = $row_center + $postition_y; //TTFフォントサイズ分調整 $y -= ($array[1]+$array[7])/2; self::renderString($fontsize, $x, $y, $string,$color,$this->fontfile); //self::drawString($args[0],$string_start,$args[2],$args[3],$args[4]); //XML作成 if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x+$array[6],$y+$array[7],$x+$array[2],$y+$array[3],$operation,$comment); } } /** * 箱詰め文字列を描画 * @access public * @param int $rownum 描画列番号 * @param string $string 描画文字列 * @param int $startx String始点X座標(染色体位置) * @param int $axisy  String軸Y座標(列中央からの高さ) * @param int $width 描画Box幅(bp) * @param int $height 描画Box高(pixel) * @param int $xalign 横の配置(LEFT/CENTER/RIGHT) * @param int $yalign 縦の配置(TOP/CENTER/BOTTOM) * @param int $margin LEFT/RIGHT or TOP/BOTTOM時の余白 * @param int $fontsize フォントサイズ * @param string $color 色文字列 * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function drawBoxedString($rownum,$string,$startx,$axisy,$width,$height,$xalign='CENTER',$yalign='CENTER',$margin=5,$fontsize=3,$color=black,$operation='',$comment='',$direct=TRUE){ //座標変換 ////X座標 $x1 = self::convertPositionString($startx); $width_converted = self::convertPositionString($width); $end = $startx + $width; $x2 = self::convertPositionString($end); $x_center = (int)(($x1+$x2)/2); ////Y座標 $row_center = self::convertRowToHeight($rownum); $y_center = (int)$row_center + $axisy; $y1 = $y_center - $height/2; $y2 = $y_center + $height/2; //文字位置計算 if($this->fontfile){ $array = StringUtil::myGetStringSizeTTF($string,$fontsize,$this->fontfile); $fontw = $array[2] - $array[0]; $fonth = $array[7] - $array[1]; while($fontw > $width_converted || $fonth > $height){ $fontsize--; if($fontsize < 1){ return FALSE; } $array = StringUtil::myGetStringSizeTTF($string,$fontsize,$this->fontfile); $fontw = $array[2] - $array[0]; $fonth = $array[7] - $array[1]; } //X軸ベースポイント $array = StringUtil::myGetStringSizeTTF($string,$fontsize,$this->fontfile); if($xalign == 'LEFT'){ $x = $x1 + $margin - $array[0]; }elseif($xalign == 'RIGHT'){ $x = $x2 - $margin - $array[2]; }else{ $x = $x_center - ceil(($array[0] + $array[2])/2); } //Y軸ベースポイント if($yalign == 'TOP'){ $y = $y1 + $margin - $array[7]; }elseif($yalign == 'BOTTOM'){ $y = $y2 - $margin - $array[1]; }else{ $y = $y_center - ceil(($array[1] + $array[7])/2); } }else{ list($fontw,$fonth) = StringUtil::myGetStringSize($string,$fontsize); while($fontw > $width_converted || $fonth > $height){ $fontsize--; if($fontsize < 1){ return FALSE; } list($fontw,$fonth) = StringUtil::myGetStringSize($string,$fontsize); } if($xalign == 'LEFT'){ $x = $x1 + $margin; }elseif($xalign == 'RIGHT'){ $x = $x2 - $margin - $fontw; }else{ $x = $x_center - $fontw/2; } if($yalign == 'TOP'){ $y = $y1 + $margin; }elseif($yalign == 'BOTTOM'){ $y = $y2 - $margin - $fonth; }else{ $y = $y_center - $fonth/2; } } // $black = imagecolorallocate($this->image,0,0,0); // imagesetpixel($this->image,$x_center,$y_center,$black); // imagesetpixel($this->image,$x,$y_center,$black); self::renderString($fontsize, $x, $y, $string,$color,$this->fontfile); //XML作成 if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x,$y,$x+$fontw,$y+$fonth,$operation,$comment); } } /** * 画像を貼り付け * @access public * @param string $rownum 描画列番号 * @param string $filepath 挿入画像パス * @param int $pos 挿入位置(X) * @param int $height 挿入位置(Y) * @param string $size 挿入サイズ(%) * @param string $mode 挿入モード * @param string $operation 操作XMLデータ * @param string $comment コメント */ public function copyPicture($rownum,$filepath,$pos,$height,$size,$mode,$operation='',$comment=''){ //座標変換 $x1 = self::convertPositionString($pos); $row_center = self::convertRowToHeight($rownum); //画像サイズ取得 list($src_w,$src_h,$type,$attr) = getimagesize($filepath); $x2 = $x1 + $src_w; $y1 = $row_center - $src_h/2; $y2 = $row_center + $src_h/2; //1 = GIF, 2 = JPG, 3 =PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM switch ($type) { case 1: $src_image = imagecreatefromgif($filepath); break; case 2: $src_image = imagecreatefromjpeg($filepath); break; case 3: $src_image = imagecreatefrompng($filepath); break; default: break; } //イメージコピー ////サイズ変更する場合 if($size != 0 && $size != 100){ //サイズ変更後サイズ $dst_w = $src_w*$size/100; $dst_h = $src_h*$size/100; $x2 = $x1 + $dst_w; $y1 = $row_center - $dst_h/2; $y2 = $row_center + $dst_h/2; }else{ //サイズ変更後サイズ=元サイズ $dst_w = $src_w; $dst_h = $src_h; } ////パラメータ設定 if($mode == 'WITHIN'){ $src_x = 0; $src_y = 0; $dst_x = $x1; $dst_y = $y1; if($this->rowheight < $dst_h){ $dst_h = $this->rowheight; $dst_w = $src_w*$dst_h/$src_h; $dst_y = $row_center- $dst_h/2; //bool imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h ) imagecopyresampled($this->image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dst_h,$src_w,$src_h); $x2 = $x1 + $dst_w; $y1 = $row_center - $dst_h/2; $y2 = $row_center + $dst_h/2; }else{ if($dst_w == $src_w){//サイズ変更なし imagecopy($this->image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h); }else{//サイズ変更あり imagecopyresampled($this->image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dst_h,$src_w,$src_h); } } }else{ $src_x = 0; $src_y = 0; $dst_x = $x1; $dst_y = $y1; if($dst_w == $src_w){//サイズ変更なし imagecopy($this->image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h); }else{//サイズ変更あり imagecopyresampled($this->image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dst_h,$src_w,$src_h); } } //XML作成 if($this->xmlobject){ $this->xmlobject->createXMLStringFromPositions($x1,$y1,$x2,$y2,$operation,$comment); } } //座標変換 /** * 描画可能画像幅と描画する染色体長から倍率を計算 * @access public * @param int $widthi 染色体上座標 * @param int $bases 描画する染色体の塩基数 * @return float 塩基倍率 */ public function calcMagnification($widthi,$bases){ $magnification = $bases/$widthi; return $magnification; } /** * 染色体座標を画像座標に変換(X軸方向) * @access public * @param int $position_x 染色体上座標 * @param int $magnification 倍率 * @param int $marginx X軸方向の余白 * @return int 画像座標(X軸方向) */ public function convertPosition($position_x, $magnification=0, $marginx=0){ if(!($magnification)){ $magnification = $this->magnification; } if(!($marginx)){ $marginx = $this->marginx; } $position_x_image = $position_x - $this->chr_start; // $x_converted = $position_x_image/$magnification + $marginx; $x_converted = $position_x_image*$this->widthi/$this->bases + $marginx; return floor($x_converted); } /** * 染色体座標+を画像座標に変換(X軸方向) * @access public * @param string $position_x 染色体上座標 * @param int $magnification 倍率 * @param int $marginx X軸方向の余白 * @return int 画像座標(X軸方向) */ public function convertPositionString($position_x){ //戻り値(画像上でのX座標) $position_x_image = 0; //pos1 + pos2 + pos3 ... //variation // 50 as chromosome position // %50 as percentage of image width // !50 as pixel length $poses = explode('+',$position_x); foreach($poses as $posstring){ if(eregi("\!(.+)",$posstring,$pixel)){//ピクセル指定 $position_x_image += $pixel[1]; }elseif(eregi("\%(.+)",$posstring,$percent)){//パーセント指定 $chr_pos = $this->bases*$percent[1]/100; $position_x_image += self::convertPosition($chr_pos); }else{//染色体位置指定 $position_x_image += self::convertPosition($posstring); } } return (int)$position_x_image; } /** * 列中央のY座標を算出(Y軸方向) * @access public * @param int $rownum 列番号 * @param int $rowheight 列の縦幅 * @param int $marginy Y軸方向の余白 * @return int 画像座標(Y軸方向) */ public function convertRowToHeight($rownum,$rowheight=0,$marginy=0){ if(!($rowheight)){ $rowheight = $this->rowheight; } if(!($marginy)){ $marginy = $this->marginy; } $y_converted = $marginy + $rowheight*($rownum-1)+floor(($rowheight-1)/2); // $y_converted = $marginy + $rowheight*($rownum - 0.5); return (int)$y_converted; } /** * 列の上辺ののY座標を算出(Y軸方向) * @access public * @param int $rownum 列番号 * @param int $rowheight 列の縦幅 * @param int $marginy Y軸方向の余白 * @return int 画像座標(Y軸方向) */ public function convertRowToTopHeight($rownum, $rowheight=0, $marginy=0){ if(!($rowheight)){ $rowheight = $this->rowheight; } if(!($marginy)){ $marginy = $this->marginy; } $y_converted = $marginy + $rowheight*($rownum - 1); return (int)$y_converted; } /** * 列の下辺ののY座標を算出(Y軸方向) * @access public * @param int $rownum 列番号 * @param int $rowheight 列の縦幅 * @param int $marginy Y軸方向の余白 * @return int 画像座標(Y軸方向) */ public function convertRowToBottomHeight($rownum, $rowheight=0, $marginy=0){ if(!($rowheight)){ $rowheight = $this->rowheight; } if(!($marginy)){ $marginy = $this->marginy; } if($rownum <= 0){ $rownum= 0; } $y_converted = $marginy + $rowheight*$rownum -1; return (int)$y_converted; } /** * 列中央のY座標を算出(Y軸方向) * @access public * @param string $heightstring * @return int 画像座標(Y軸方向) */ public function convertHeight($heightstring){ //返り値(画像上Y座標) $position_y_image = 0; $poses = explode('+',$heightstring); foreach($poses as $posstring){ if(eregi("\!(.+)",$posstring,$pixel)){//ピクセル指定 $position_y_image += $pixel[1]; }elseif(eregi("\%(.+)",$posstring,$percent)){//列内パーセント指定 $height_pixel = $percent[1]*($this->rowheight-1)/100; $position_y_image += $height_pixel; }elseif(eregi("\@(.+)",$posstring,$percent)){//画像内内パーセント指定 $height_pixel = $percent[1]*($this->height-1)/100; $position_y_image += $height_pixel; }else{//列番号指定 $position_y_image += self::convertRowToHeight($posstring); } } return (int)$position_y_image; } /** * 矢頭の長さ、中心ラインからの広がり幅の長さ * @access public * @param int $height 矢頭の広がりの全体幅 * @param int $angle1 矢頭の中心ラインからの角度(幅の長さを取得する非対象の角度) * @param int $angle2 矢頭の中心ラインからの角度(幅の長さを取得する対象の角度) * @return array 矢頭の横幅、縦幅 */ private function calcArrowSize($height,$angle1,$angle2){ $rate = ($angle1+$angle2)/$angle2; //三角関数による矢頭の長さの取得 if($angle2 >= 90){ $angle2 = 90; $angle_rad = deg2rad($angle2); $width = 0; }else{ $angle_rad = deg2rad($angle2); $tangent = tan($angle_rad); if($tangent > 0){ $width = $height/($rate*$tangent); }else{ $width = $height; } } //矢頭の広がり幅の長さを取得 $height = $height/$rate; return array($width, $height); } //DEBUG関連メソッド /** * デバッグプションを設定する。 * @access public * @param boolean デバッグモードフラグ * @param int デバッグ文字列フォントサイズ * @param string デバッグ文字列色 * @param string デバッグ領域背景色 * @param string デバッグ文字フォントパス(FreeType Font使用時) */ public function setDebugOptions($debugmode=FALSE,$debugfontsize=3,$debugfontcolor='',$debugbgcolor='',$debugfont=''){ if(!($debugbgcolor)){ $debugbgcolor = $this->bgcolor; } if(!($debugfontcolor)){ $debugfontcolor = ColorUtil::getComplementaryColor($debugbgcolor); } if($this->fontfile && !($debugfont)){ $debugfont = $this->fontfile; if(!($debugfontsize)){ $debugfontsize = 10; } } $this->debugobject = new DebugObject(); $this->debugobject->setDebugOptions($debugmode,$debugfontsize,$debugfontcolor,$debugbgcolor,$debugfont); } /** * デバッグストリングを追加する。 * @access private * @param string 追加メッセージ * @param int 次行フラグ(同行=0、次行=1) */ public function addDebugMessage($message,$next=0){ if(isset($this->debugobject)){ $this->debugobject->addDebugMessage($message,$next); } } /** * デバッグストリングを描画する。 * @access private * @param int $fontsize 文字サイズ */ public function drawDebugMessage(){ if(isset($this->debugobject)){ $this->image = $this->debugobject->drawDebugMessage($this->image); } } /** * デバッグストリングをログに出力する。 * @access private */ public function outputDebugMessageToLog(){ if(isset($this->logobject)){ $this->debugobject->outputDebugMessageToLog($this->logobject); } } /** * デバッグスケールを追加する。 * @access private */ public function drawDebugScales(){ } }