- Timestamp:
- 2007/07/20 15:58:59 (17 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update
-
Property
svn:ignore
set to
.cache
.settings
.projectOptions
-
Property
svn:ignore
set to
-
branches/feature-module-update/html/admin/total/class/SC_GraphBase.php
r12157 r15078 13 13 require_once(realpath(dirname( __FILE__)) . "/lib.php"); 14 14 15 // SC_Graph ¶¦ÄÌ¥¯¥é¥¹15 // SC_Graph共通クラス 16 16 class SC_GraphBase { 17 17 var $arrRGB; … … 34 34 var $arrLegend; 35 35 36 // ¥³¥ó¥¹¥È¥é¥¯¥¿36 // コンストラクタ 37 37 function SC_GraphBase($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left, $top) { 38 38 global $ARR_GRAPH_RGB; … … 46 46 global $ARR_GRID_COLOR; 47 47 48 // ²èÁüºîÀ®48 // 画像作成 49 49 $this->bgw = $bgw; 50 50 $this->bgh = $bgh; 51 51 $this->image = imagecreatetruecolor($bgw, $bgh); 52 // ¥¢¥ó¥Á¥¨¥¤¥ê¥¢¥¹Í¸ú52 // アンチエイリアス有効 53 53 if (function_exists("imageantialias")) imageantialias($this->image, true); 54 // ÇØ·Ê¿§¤ò¥»¥Ã¥È54 // 背景色をセット 55 55 imagefill($this->image, 0, 0, lfGetImageColor($this->image, $ARR_BG_COLOR)); 56 56 57 // »ÈÍÑ¿§¤ÎÀ¸À®57 // 使用色の生成 58 58 $this->setColorList($ARR_GRAPH_RGB); 59 // ¥°¥é¥ÕÉÁ²è°ÌÃÖ¤ÎÀßÄê59 // グラフ描画位置の設定 60 60 $this->left = $left; 61 61 $this->top = $top; … … 68 68 $this->grid_color = lfGetImageColor($this->image, $ARR_GRID_COLOR); 69 69 70 // ±Æ¤¢¤ê70 // 影あり 71 71 $this->shade_on = true; 72 72 } 73 73 74 // ¥ê¥µ¥ó¥×¥ë(²èÁü¤ò³ê¤é¤«¤Ë½Ì¾®¤¹¤ë)74 // リサンプル(画像を滑らかに縮小する) 75 75 function resampled() { 76 76 $new_width = $this->bgw * 0.8; … … 83 83 84 84 85 // ¥ª¥Ö¥¸¥§¥¯¥È¥«¥é¡¼¤ÎÀßÄê85 // オブジェクトカラーの設定 86 86 function setColorList($arrRGB) { 87 87 $this->arrRGB = $arrRGB; 88 88 $count = count($this->arrRGB); 89 // Ä̾￧¤ÎÀßÄê89 // 通常色の設定 90 90 for($i = 0; $i < $count; $i++) { 91 91 $this->arrColor[$i] = lfGetImageColor($this->image, $this->arrRGB[$i]); 92 92 } 93 // °Å¿§¤ÎÀßÄê93 // 暗色の設定 94 94 for($i = 0; $i < $count; $i++) { 95 95 $this->arrDarkColor[$i] = lfGetImageDarkColor($this->image, $this->arrRGB[$i]); … … 97 97 } 98 98 99 // ±Æ¤Î¤¢¤ê¤Ê¤·99 // 影のありなし 100 100 function setShadeOn($shade_on) { 101 101 $this->shade_on = $shade_on; 102 102 } 103 103 104 // ²èÁü¤ò½ÐÎϤ¹¤ë104 // 画像を出力する 105 105 function outputGraph($header = true, $filename = "") { 106 106 if($header) { … … 117 117 } 118 118 119 // ÉÁ²è»þ¤Î¥Æ¥¥¹¥ÈÉý¤òµá¤á¤ë119 // 描画時のテキスト幅を求める 120 120 function getTextWidth($text, $font_size) { 121 121 $text_len = strlen($text); 122 122 $ret = $font_size * $text_len * TEXT_RATE; 123 123 /* 124 ¢¨Àµ³Î¤ÊÃͤ¬¼èÆÀ¤Ç¤¤Ê¤«¤Ã¤¿¤Î¤ÇÇÑ»ß125 // ¥Æ¥¥¹¥ÈÉý¤Î¼èÆÀ124 ※正確な値が取得できなかったので廃止 125 // テキスト幅の取得 126 126 $arrPos = imagettfbbox($font_size, 0, FONT_PATH, $text); 127 127 $ret = $arrPos[2] - $arrPos[0]; … … 130 130 } 131 131 132 // ¥Æ¥¥¹¥È¤ò½ÐÎϤ¹¤ë132 // テキストを出力する 133 133 function setText($font_size, $left, $top, $text, $color = NULL, $angle = 0, $labelbg = false) { 134 // »þ·×²ó¤ê¤Ë³ÑÅÙ¤òÊѹ¹134 // 時計回りに角度を変更 135 135 $angle = -$angle; 136 // ¥é¥Ù¥ëÇØ·Ê136 // ラベル背景 137 137 if($labelbg) { 138 138 $text_width = $this->getTextWidth($text, $font_size); … … 148 148 } 149 149 150 // ¥¿¥¤¥È¥ë¤ò½ÐÎϤ¹¤ë150 // タイトルを出力する 151 151 function drawTitle($text, $font_size = TITLE_FONT_SIZE) { 152 // ½ÐÎÏ°ÌÃ֤λ»½Ð152 // 出力位置の算出 153 153 $text_width = $this->getTextWidth($text, $font_size); 154 154 $left = ($this->bgw - $text_width) / 2; … … 157 157 } 158 158 159 // ¥í¥°¤ò½ÐÎϤ¹¤ë159 // ログを出力する 160 160 function debugPrint($text) { 161 161 $text = mb_convert_encoding($text, "UTF-8", CHAR_CODE); … … 163 163 $this->text_top = FONT_SIZE + LINE_PAD; 164 164 } 165 // ¥Æ¥¥¹¥ÈÉÁ²è165 // テキスト描画 166 166 ImageTTFText($this->image, FONT_SIZE, 0, LINE_PAD, $this->text_top, $this->text_color, FONT_PATH, $text); 167 167 $this->text_top += FONT_SIZE + LINE_PAD; 168 168 } 169 169 170 // ¥«¥é¡¼¥é¥Ù¥ë¤òÉÁ²è170 // カラーラベルを描画 171 171 function drawLegend($legend_max = "", $clabelbg = true) { 172 // ËÞÎ㤬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤ÐÃæ»ß172 // 凡例が登録されていなければ中止 173 173 if(count($this->arrLegend) <= 0) { 174 174 return; … … 185 185 $width_max = 0; 186 186 187 // °ìÈÖʸ»ú¿ô¤¬Â¿¤¤¤â¤Î¤ò¼èÆÀ187 // 一番文字数が多いものを取得 188 188 for($i = 0; $i < $label_max; $i++) { 189 189 $text_len = strlen($this->arrLegend[$i]); … … 195 195 $width_max = FONT_SIZE * $text_max * TEXT_RATE; 196 196 197 // ¥«¥é¡¼¥¢¥¤¥³¥ó¤Èʸ»ú´Ö¤ò´Þ¤á¤¿Éý197 // カラーアイコンと文字間を含めた幅 198 198 $width_max += FONT_SIZE + (LINE_PAD * 2); 199 199 $left = $this->bgw - $width_max - LEGEND_RIGHT; 200 200 $top = LEGEND_TOP; 201 // ¥«¥é¡¼¥é¥Ù¥ëÇطʤÎÉÁ²è201 // カラーラベル背景の描画 202 202 if($clabelbg) { 203 203 $this->drawClabelBG($left - LINE_PAD, $top, $left + $width_max, $top + $height_max + LINE_PAD); … … 205 205 $top += LINE_PAD; 206 206 207 // ¿§¿ô¤Î¼èÆÀ207 // 色数の取得 208 208 $c_max = count($this->arrColor); 209 209 for($i = 0; $i < $label_max; $i++) { 210 // ¥«¥é¡¼¥¢¥¤¥³¥ó¤Îɽ¼¨210 // カラーアイコンの表示 211 211 imagerectangle($this->image, $left, $top, $left + FONT_SIZE, $top + FONT_SIZE, $this->flame_color); 212 212 imagefilledrectangle($this->image, $left + 1, $top + 1, $left + FONT_SIZE - 1, $top + FONT_SIZE - 1, $this->arrColor[($i % $c_max)]); 213 // ¥é¥Ù¥ë¤Îɽ¼¨213 // ラベルの表示 214 214 $this->setText(FONT_SIZE, $left + FONT_SIZE + LINE_PAD, $top, $this->arrLegend[$i]); 215 215 $top += FONT_SIZE + LINE_PAD; … … 217 217 } 218 218 219 // ¥«¥é¡¼¥é¥Ù¥ëÇطʤÎÉÁ²è219 // カラーラベル背景の描画 220 220 function drawClabelBG($left, $top, $right, $bottom) { 221 // ±Æ¤ÎÉÁ²è221 // 影の描画 222 222 if($this->shade_on) { 223 223 imagefilledrectangle($this->image, $left + 2, $top + 2, $right + 2, $bottom + 2, $this->shade_color); 224 224 } 225 // ¥«¥é¡¼¥é¥Ù¥ëÇطʤÎÉÁ²è225 // カラーラベル背景の描画 226 226 imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->clabelbg_color); 227 227 imagerectangle($this->image, $left, $top, $right, $bottom, $this->flame_color); 228 228 } 229 229 230 // ËÞÎã¤ò¥»¥Ã¥È¤¹¤ë230 // 凡例をセットする 231 231 function setLegend($arrLegend) { 232 232 $this->arrLegend = array_values((array)$arrLegend);
Note: See TracChangeset
for help on using the changeset viewer.