当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::GetWidth方法代码示例

本文整理汇总了PHP中Text::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::GetWidth方法的具体用法?PHP Text::GetWidth怎么用?PHP Text::GetWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Text的用法示例。


在下文中一共展示了Text::GetWidth方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Create

 function Create()
 {
     if ($this->ready) {
         return;
     }
     $this->graph = new CanvasGraph($this->width, $this->height, 'auto');
     $this->graph->SetMargin(5, 11, 6, 11);
     /*
         $this->graph->SetShadow();
         $this->graph->SetMarginColor( "teal");
         $this->graph->InitFrame(); 
     */
     $hpos = 15;
     $text = new Text("ADEI", $this->width / 2, $hpos);
     $text->SetFont(FF_ARIAL, FS_BOLD, 24);
     $text->Align('center', 'top');
     $text->Stroke($this->graph->img);
     $hpos += $text->GetTextHeight($this->graph->img) + 10;
     //    $msg = "Welcome to the Advanced Data Extraction Infrastructure! Please";
     $msg = preg_replace(array("/\n([^\n])/"), array(' \\1'), file_get_contents("docs/welcome.txt"));
     $text_width = $this->width - 50;
     if ($text_width < 100) {
         return;
     }
     $text = new Text($msg, $this->width / 2, $hpos);
     $text->SetFont(FF_ARIAL, FS_NORMAL, 18);
     $text->Align('center', 'top');
     $width = $text->GetWidth($this->graph->img);
     if ($width > $text_width) {
         $char_width = ceil($width / strlen($msg));
         $cpl = $text_width / $char_width;
         $wmsg = wordwrap($msg, $cpl, "\n", true);
         $text->Set($wmsg);
         $width = $text->GetWidth($this->graph->img);
         while ($width > $text_width && $cpl > 10) {
             $cpl -= $cpl / 10;
             $wmsg = wordwrap($msg, $cpl, "\n", true);
             $text->Set($wmsg);
             $width = $text->GetWidth($this->graph->img);
         }
     }
     $text->Stroke($this->graph->img);
     //    $text->ParagraphAlign('center');
     //    $text->SetBox( "white", "black","gray");
     /*
     //    $text->Align('left', 'top');
     //    $text->ParagraphAlign('left'); 
     //    $text->SetBox( "white", "black","gray"); 
         $width = $text->GetWidth($this->graph->img);
     */
     //    $text->Stroke( $this->graph->img);
 }
开发者ID:nicolaisi,项目名称:adei,代码行数:52,代码来源:welcome.php

示例2: addTextToGraph

 /**
  * @return Text
  */
 private function addTextToGraph($msg, $padding_left, $padding_top, $font_weight, $font_size, $img_width)
 {
     $text = new Text($msg, $padding_left, $padding_top);
     $text->SetFont($this->getFont(), $font_weight, $font_size);
     $text->SetColor($this->getMainColor());
     //word wrap
     $width = $text->GetWidth($this->jpgraph_instance->img) - $padding_left;
     $text->SetWordWrap(floor(strlen($msg) * ($this->img_width - 3 * $padding_left) / $width));
     $text->Stroke($this->jpgraph_instance->img);
     return $text;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:14,代码来源:ErrorChart.class.php

示例3: CreateMessage

 function CreateMessage($header, $msg)
 {
     $this->graph = new CanvasGraph($this->width, $this->height, 'auto');
     $this->graph->SetMargin(5, 11, 6, 11);
     $this->graph->SetShadow();
     $this->graph->SetMarginColor("teal");
     $this->graph->InitFrame();
     $text_width = $this->width - 50;
     if ($text_width < 100) {
         return;
     }
     $text = new Text($msg, 25, 25);
     $text->SetFont(FF_ARIAL, FS_NORMAL, 24);
     //    $text->Align('left', 'top');
     //    $text->ParagraphAlign('left');
     //    $text->SetBox( "white", "black","gray");
     $width = $text->GetWidth($this->graph->img);
     if ($width > $text_width) {
         $char_width = ceil($width / strlen($msg));
         $cpl = $text_width / $char_width;
         /*
         	Does not taken into the account by GetWidth function
         	$text->SetWordWrap($cpl);
         */
         $wmsg = wordwrap($msg, $cpl, "\n", true);
         $text->Set($wmsg);
         $width = $text->GetWidth($this->graph->img);
         while ($width > $text_width && $cpl > 10) {
             $cpl -= $cpl / 10;
             $wmsg = wordwrap($msg, $cpl, "\n", true);
             $text->Set($wmsg);
             $width = $text->GetWidth($this->graph->img);
         }
     }
     $text->Stroke($this->graph->img);
 }
开发者ID:nicolaisi,项目名称:adei,代码行数:36,代码来源:drawtext.php

示例4: Stroke

 function Stroke($aImg, $ax = -1, $ay = -1)
 {
     // To position the super script correctly we need different
     // cases to handle the alignmewnt specified since that will
     // determine how we can interpret the x,y coordinates
     $w = parent::GetWidth($aImg);
     $h = parent::GetTextHeight($aImg);
     switch ($this->valign) {
         case 'top':
             $sy = $this->y;
             break;
         case 'center':
             $sy = $this->y - $h / 2;
             break;
         case 'bottom':
             $sy = $this->y - $h;
             break;
         default:
             JpGraphError::Raise('PANIC: Internal error in SuperScript::Stroke(). Unknown vertical alignment for text');
             exit;
     }
     switch ($this->halign) {
         case 'left':
             $sx = $this->x + $w;
             break;
         case 'center':
             $sx = $this->x + $w / 2;
             break;
         case 'right':
             $sx = $this->x;
             break;
         default:
             JpGraphError::Raise('PANIC: Internal error in SuperScript::Stroke(). Unknown horizontal alignment for text');
             exit;
     }
     $sx += $this->iSuperMargin;
     $sy += $this->iVertOverlap;
     // Should we automatically determine the font or
     // has the user specified it explicetly?
     if ($this->sfont_family == "") {
         if ($this->font_family <= FF_FONT2) {
             if ($this->font_family == FF_FONT0) {
                 $sff = FF_FONT0;
             } elseif ($this->font_family == FF_FONT1) {
                 if ($this->font_style == FS_NORMAL) {
                     $sff = FF_FONT0;
                 } else {
                     $sff = FF_FONT1;
                 }
             } else {
                 $sff = FF_FONT1;
             }
             $sfs = $this->font_style;
             $sfz = $this->font_size;
         } else {
             // TTF fonts
             $sff = $this->font_family;
             $sfs = $this->font_style;
             $sfz = floor($this->font_size * $this->iSuperScale);
             if ($sfz < 8) {
                 $sfz = 8;
             }
         }
         $this->sfont_family = $sff;
         $this->sfont_style = $sfs;
         $this->sfont_size = $sfz;
     } else {
         $sff = $this->sfont_family;
         $sfs = $this->sfont_style;
         $sfz = $this->sfont_size;
     }
     parent::Stroke($aImg, $ax, $ay);
     // For the builtin fonts we need to reduce the margins
     // since the bounding bx reported for the builtin fonts
     // are much larger than for the TTF fonts.
     if ($sff <= FF_FONT2) {
         $sx -= 2;
         $sy += 3;
     }
     $aImg->SetTextAlign('left', 'bottom');
     $aImg->SetFont($sff, $sfs, $sfz);
     $aImg->PushColor($this->color);
     $aImg->StrokeText($sx, $sy, $this->iSuper, $this->iSDir, 'left');
     $aImg->PopColor();
 }
开发者ID:hostellerie,项目名称:nexpro,代码行数:85,代码来源:jpgraph.php

示例5: getWidth

 function getWidth($aImg)
 {
     $scaling = 1;
     //$this->iAntiAlias ? 2 : 1 ;
     if ($this->iSize > 0 && $this->iSize < 1) {
         $this->iSize *= min($aImg->width, $aImg->height);
     }
     $value = new Text();
     $value->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize * $scaling);
     $value->SetColor($this->iFontColor);
     // Setup extra size around the graph needed so that the labels
     // doesn't get cut. For this we need to find the largest label.
     // The code below gives a possible a little to large margin. The
     // really, really proper way would be to account for what angle
     // the label are at
     $n = count($this->iLabels);
     if ($n > 0) {
         $maxh = 0;
         $maxw = 0;
         foreach ($this->iLabels as $key => $lbl) {
             $value->Set($lbl);
             $maxw = max($maxw, $value->GetWidth($aImg));
         }
     } else {
         $value->Set('888.888');
         // Dummy value to get width/height
         $maxw = $value->GetWidth($aImg);
     }
     // Add an extra margin of 50% the font size
     $maxw += round($this->iFontSize * $scaling * 0.4);
     $valxmarg = 1.5 * $maxw + 2 * $this->iLabelMargin * $scaling;
     $w = round($this->iSize * $scaling + $valxmarg);
     // Make sure that the width of the legend fits
     $legendwidth = $this->_StrokeLegend($aImg, 0, 0, $scaling, true) + 10 * $scaling;
     $w = max($w, $legendwidth);
     return $w;
 }
开发者ID:muthulatha,项目名称:iem,代码行数:37,代码来源:jpgraph_windrose.php

示例6: Stroke

 function Stroke(&$aImg)
 {
     $scaling = $this->iAntiAlias ? 2 : 1;
     $value = new Text();
     $value->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize * $scaling);
     $value->SetColor($this->iFontColor);
     $n = count($this->iLabels);
     if ($n > 0) {
         $maxh = 0;
         $maxw = 0;
         foreach ($this->iLabels as $key => $lbl) {
             $value->Set($lbl);
             $maxh = max($maxh, $value->GetHeight($aImg));
             $maxw = max($maxw, $value->GetWidth($aImg) / 2);
         }
     } else {
         $value->Set("180.8");
         $maxh = $value->GetHeight($aImg);
         $maxw = $value->GetWidth($aImg);
     }
     $maxh += round($this->iFontSize * $scaling * 0.5);
     $maxw += round($this->iFontSize * $scaling * 0.5);
     $valxmarg = 2 * $maxw + 2 * $this->iLabelMargin * $scaling;
     $valymarg = 2 * $maxh + 2 * $this->iLabelMargin * $scaling;
     $w = round($this->iSize * $scaling + $valxmarg);
     $legendwidth = $this->_StrokeLegend($aImg, 0, 0, $scaling, true) + 10 * $scaling;
     $w = max($w, $legendwidth);
     $legendheight = round($this->legend->iShow ? 1 : 0);
     $legendheight *= max($this->legend->iCircleRadius * 2, $this->legend->iTxtFontSize * 2) + $this->legend->iMargin + $this->legend->iBottomMargin + 2;
     $legendheight *= $scaling;
     $h = round($this->iSize * $scaling + $valymarg) + $legendheight;
     if ($this->iAntiAlias) {
         $dblImg = new Image($w, $h);
         $dblImg->SetColor($this->iColor);
         $dblImg->FilledRectangle(0, 0, $w, $h);
     } else {
         $dblImg =& $aImg;
         $dblImg->SetTranslation($this->iX - $w / 2, $this->iY - $h / 2);
     }
     if (__DEBUG) {
         $dblImg->SetColor('red');
         $dblImg->Rectangle(0, 0, $w - 1, $h - 1);
     }
     $dblImg->SetColor('black');
     if ($this->iShowBox) {
         $dblImg->SetColor($this->iBoxColor);
         $dblImg->SetLineWeight($this->iBoxWeight);
         $dblImg->Rectangle(0, 0, $w - 1, $h - 1);
         $dblImg->SetLineWeight(1);
     }
     $xc = round($w / 2);
     $yc = round(($h - $legendheight) / 2);
     $this->iSize *= $scaling;
     $ri = $this->iCenterSize / 2;
     $r = round($this->iSize / 2);
     $n = $this->scale->GetNumCirc();
     $ri *= $scaling;
     $rr = round(($r - $ri) / $n);
     for ($i = 1; $i <= $n; ++$i) {
         $this->_ThickCircle($dblImg, $xc, $yc, $rr * $i + $ri, $this->iCircGridWeight, $this->iGridColor1);
     }
     $num = 0;
     if ($this->iType == WINDROSE_TYPEFREE) {
         $this->_StrokeFreeRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri);
     } else {
         if ($this->iOrdinalEncoding == KEYENCODING_CLOCKWISE) {
             if ($this->iType == WINDROSE_TYPE16) {
                 $const1 = 19;
                 $const2 = 16;
             } elseif ($this->iType == WINDROSE_TYPE8) {
                 $const1 = 9;
                 $const2 = 8;
             } else {
                 $const1 = 4;
                 $const2 = 4;
             }
             $tmp = array();
             $n = count($this->iData);
             foreach ($this->iData as $key => $val) {
                 if (is_numeric($key)) {
                     $key = ($const1 - $key) % $const2;
                 }
                 $tmp[$key] = $val;
             }
             $this->iData = $tmp;
         }
         $this->_StrokeRegularRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri);
     }
     $this->scale->iFontSize *= $scaling;
     $this->scale->iZFontSize *= $scaling;
     $this->scale->StrokeLabels($dblImg, $xc, $yc, $ri, $rr);
     $this->_ThickCircle($dblImg, $xc, $yc, $ri, $this->iCircGridWeight, $this->iGridColor1);
     $ww = $w / $scaling;
     $hh = $h / $scaling;
     if ($ww > $aImg->width) {
         JpgraphError::RaiseL(22020);
     }
     $x = $xc;
     $y = $h;
     $this->_StrokeLegend($dblImg, $x, $y, $scaling);
//.........这里部分代码省略.........
开发者ID:natanoj,项目名称:nuBuilderPro,代码行数:101,代码来源:jpgraph_windrose.php

示例7: getWidth

 /**
  * @param Image $aImg
  * @return unknown_type
  */
 function getWidth(Image $aImg)
 {
     if (!$this->ishow) {
         return 0;
     }
     $this->InitSize($aImg);
     $t = new Text();
     $t->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize);
     if ($this->ilayout == 0 || $this->ilayout == 2) {
         $t->Set(sprintf($this->iLabelFormatString, $this->iMin));
         $minw = $t->GetWidth($aImg);
         $t->Set(sprintf($this->iLabelFormatString, $this->iMax));
         $maxw = $t->GetWidth($aImg);
         return $this->imodwidth + $this->ilabelmargin + max($minw, $maxw) + 1;
     }
 }
开发者ID:nicolaisi,项目名称:kitcube-lidar,代码行数:20,代码来源:jpgraph_matrix.php

示例8: Stroke

 function Stroke(&$aImg, $ax = -1, $ay = -1)
 {
     $w = parent::GetWidth($aImg);
     $h = parent::GetTextHeight($aImg);
     switch ($this->valign) {
         case 'top':
             $sy = $this->y;
             break;
         case 'center':
             $sy = $this->y - $h / 2;
             break;
         case 'bottom':
             $sy = $this->y - $h;
             break;
         default:
             JpGraphError::RaiseL(25052);
             break;
     }
     switch ($this->halign) {
         case 'left':
             $sx = $this->x + $w;
             break;
         case 'center':
             $sx = $this->x + $w / 2;
             break;
         case 'right':
             $sx = $this->x;
             break;
         default:
             JpGraphError::RaiseL(25053);
             break;
     }
     $sx += $this->iSuperMargin;
     $sy += $this->iVertOverlap;
     if ($this->sfont_family == "") {
         if ($this->font_family <= FF_FONT2) {
             if ($this->font_family == FF_FONT0) {
                 $sff = FF_FONT0;
             } elseif ($this->font_family == FF_FONT1) {
                 if ($this->font_style == FS_NORMAL) {
                     $sff = FF_FONT0;
                 } else {
                     $sff = FF_FONT1;
                 }
             } else {
                 $sff = FF_FONT1;
             }
             $sfs = $this->font_style;
             $sfz = $this->font_size;
         } else {
             $sff = $this->font_family;
             $sfs = $this->font_style;
             $sfz = floor($this->font_size * $this->iSuperScale);
             if ($sfz < 8) {
                 $sfz = 8;
             }
         }
         $this->sfont_family = $sff;
         $this->sfont_style = $sfs;
         $this->sfont_size = $sfz;
     } else {
         $sff = $this->sfont_family;
         $sfs = $this->sfont_style;
         $sfz = $this->sfont_size;
     }
     parent::Stroke($aImg, $ax, $ay);
     if ($sff <= FF_FONT2) {
         $sx -= 2;
         $sy += 3;
     }
     $aImg->SetTextAlign('left', 'bottom');
     $aImg->SetFont($sff, $sfs, $sfz);
     $aImg->PushColor($this->color);
     $aImg->StrokeText($sx, $sy, $this->iSuper, $this->iSDir, 'left');
     $aImg->PopColor();
 }
开发者ID:natanoj,项目名称:nuBuilderPro,代码行数:76,代码来源:jpgraph.php

示例9: barVPlot

 private function barVPlot($question, $datax, $datay, $width, $height)
 {
     include_once BASE . "jpgraph.php";
     include_once BASE . "jpgraph_bar.php";
     $tFontSize = 11;
     $xFontSize = 6 + $height / $this->amountOfVariants / 30;
     $maxX = 0;
     foreach ($datax as $x) {
         if (($t = strlen($x)) > $maxX) {
             $maxX = $t;
         }
     }
     for ($i = 0; $i < $this->amountOfVariants; $i++) {
         $x =& $datax[$i];
         if (($t = strlen($x)) >= MAXCHARSPERLINE) {
             $index = strrpos(substr($x, 0, MAXCHARSPERLINE - 1), ' ');
             if ($index === false) {
                 $index = MAXCHARSPERLINE - 3;
             }
             $x[$index] = "\n";
             if ($t > $index + MAXCHARSPERLINE) {
                 $x = substr($x, 0, $index + MAXCHARSPERLINE - 3) . "...";
             }
         }
     }
     unset($x);
     // Set the basic parame graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin", 0, 100);
     //if (amountOfVariants>5) $xFontSize--;
     $lm = 0;
     foreach ($datax as $x) {
         $linia = strtok($x, "\n");
         while ($linia != '') {
             $t = new Text($linia);
             $t->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
             $lineWidth = $t->GetWidth($graph->img);
             if ($lineWidth > $lm) {
                 $lm = $lineWidth;
             }
             //echo $linia.$lineWidth."<BR>";
             $linia = strtok("\n");
         }
     }
     // Rotate graph 90 degrees and set margin
     $graph->SetMargin(35, 20, 40, $lm + 15);
     // Set white margin color
     $graph->SetMarginColor('gray@0.95');
     // Setup title
     //$graph->title->Set($question);
     //$graph->title->SetMargin(10);
     //$graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize);
     $graph->tabtitle->Set($question);
     $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, $tFontSize);
     $tWidth = $graph->tabtitle->GetWidth($graph->img);
     //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2);
     if ($tWidth > $width) {
         $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' ');
         //echo $index;
         if ($index === false) {
             $index = $len / 2 - 3;
         }
         $question[$index] = "\n";
         $graph->tabtitle->Set($question);
         $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, $tFontSize -= 2);
     }
     // Setup X-axis
     $graph->xaxis->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetColor('black');
     $graph->xaxis->SetLabelAngle(80);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('center', 'top');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     $graph->yaxis->scale->SetGrace(10);
     //$graph->yaxis->SetPos('max');
     //$graph->yaxis->SetLabelAlign('center', 'top');
     //$graph->yaxis->SetLabelSide('SIDE_RIGHT');
     $graph->yaxis->SetLabelFormat('%2d%%');
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetWidth(0.4);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_VERDANA, FS_NORMAL, $xFontSize);
     //$bplot->SetShadow("black@0.1",2,2);
     //$bplot->value->SetAlign('left','center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%d%%');
     //$bplot->SetValuePos('max');
     //$graph->SetMarginColor('green');
     // Box around plotarea
     $graph->SetBox();
     $graph->SetFrame(false);
     //	$graph->SetShadow();
     // Setup the X and Y grid
     $graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:phppool,代码行数:101,代码来源:PlotQuestion.php


注:本文中的Text::GetWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。