+ private function display_header($header) {
+ $header = explode("\n",$header);
+ $count = $header[0];
+ $header = array_slice($header, 1);
+ if($count > $this->max_branches)
+ $count = $this->max_branches;
+ if(!$this->header_height) {
+ $maxlen = 0;
+ foreach($header as $head) {
+ $head = explode(":", $head, 2);
+ $name = $head[1];
+ if(strlen($name) > $maxlen)
+ $maxlen = strlen($name);
+ }
+ $this->header_height = $maxlen * 2 + 15;
+ }
+ $image = imagecreatetruecolor($count * $this->size + 60, $this->header_height);
+ $transparentIndex = imagecolorallocate($image, 217, 216, 209);
+ imagefill($image, 0, 0, $transparentIndex);
+ $branches = 0;
+ foreach($header as $head) {
+ $head = explode(":", $head, 2);
+ $color = $this->get_color($head[0], true);
+ $name = $head[1];
+ $branches++;
+ $color = imagecolorallocatealpha($image, $color[0], $color[1], $color[2], 0);
+ imagettftext($image, 8, 28, ($head[0]-1) * $this->size + 10, $this->header_height-2, $color, realpath(dirname(__FILE__)."/../")."/res/arial.ttf", $name);
+ }
+ if(!$branches) die();
+ imagecolortransparent($image, $transparentIndex);
+ header('Content-Type: image/png');
+ imagepng($image);
+ imagedestroy($image);
+ }
+