Ejemplo n.º 1
0
 function Stroke($aData, $aFile = '', $aOnlyDebug = false)
 {
     $topmargin = 10;
     $bottommargin = 10;
     $textmargin = 5;
     $txtmargin = 4;
     $this->iHeight *= $this->iModuleWidth;
     $spec = $this->iEncoder->Enc($aData);
     if ($aOnlyDebug) {
         return $spec->toString();
     }
     $this->AdjustSpec($spec);
     $data = '';
     if (is_array($aData)) {
         $n = count($aData);
         for ($i = 0; $i < $n; ++$i) {
             $data .= $aData[$i][1];
         }
     } elseif (is_string($aData)) {
         $data = $aData;
     }
     if (!$this->iFontSpecified) {
         if ($this->iModuleWidth > 1) {
             $this->iFontFam = FF_ARIAL;
             $this->iFontStyle = FS_BOLD;
             $this->iFontSize = 10;
         } else {
             $this->iFontFam = FF_ARIAL;
             $this->iFontStyle = FS_NORMAL;
             $this->iFontSize = 7;
         }
     }
     $s = '';
     $g = new CanvasGraph(0, 0);
     // Dummy graph context
     $g->img->SetImgFormat($this->iImgFormat);
     $w = round($spec->iModuleWidth);
     // Calculate total width
     $totwidth = $spec->iLeftMargin * $w;
     $n = count($spec->iBar[0]);
     for ($i = 0; $i < $n; ++$i) {
         $b = $spec->iBar[0][$i];
         $bn = strlen($b[3]);
         for ($j = 0; $j < $bn; ++$j) {
             $wb = substr($b[3], $j, 1) * $w;
             $totwidth += $wb;
         }
     }
     $totwidth += $spec->iRightMargin * $w;
     // Calculate total height
     $height = $this->iHeight * count($spec->iBar) + $topmargin + $bottommargin;
     $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
     $th = $g->img->GetTextHeight($data) + $txtmargin;
     if ($spec->iStrokeDataBelow) {
         $height += $th;
     }
     $width = $totwidth;
     $g->img->SetFont(FF_FONT2);
     $tw = 2 * $textmargin + $g->img->GetTextWidth($s);
     if ($width < $tw) {
         $width = $tw;
     }
     $g = new CanvasGraph($width, $height);
     $g->img->SetImgFormat($this->iImgFormat);
     $g->SetMarginColor($this->iBkgColor);
     $g->SetColor($this->iBkgColor);
     if ($this->iShowFrame) {
         $g->InitFrame();
     } else {
         $g->frame_weight = 0;
         $g->InitFrame();
     }
     $g->img->SetLineWeight(1);
     $g->img->SetColor('black');
     $x = $w * $spec->iLeftMargin;
     $ystart = $topmargin;
     $inunder = false;
     $under_s = '';
     $startx = $x;
     for ($r = 0; $r < count($spec->iBar); ++$r) {
         $yend = $ystart + $this->iHeight - 1;
         $x = $startx;
         for ($i = 0; $i < $n; ++$i) {
             $b = $spec->iBar[$r][$i];
             $bn = strlen($b[3]);
             for ($j = 0; $j < $bn; ++$j) {
                 $wb = substr($b[3], $j, 1) * $w;
                 if (!($j % 2)) {
                     $g->img->SetColor($this->iColor);
                     $g->img->FilledRectangle($x, $ystart, $x + $wb - 1, $yend);
                 }
                 $x += $wb;
             }
         }
         $ystart += $this->iHeight;
     }
     // row
     $g->img->SetColor($this->iColor);
     if ($spec->iStrokeDataBelow) {
         // Center data underneath
         $y = $yend + $txtmargin;
         $bw = $totwidth - $spec->iLeftMargin * $w - $spec->iRightMargin * $w;
         $x = $spec->iLeftMargin * $w + floor($bw / 2);
         $g->img->SetTextAlign('center', 'top');
         $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
         $g->img->StrokeText($x, $y, $data);
     }
     if (ADD_DEMOTXT) {
         $ystart = 0;
         $t = new Text(" DEMO ", $totwidth / 2, $ystart);
         if ($this->iModuleWidth > 1) {
             if ($this->iModuleWidth > 2) {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 24);
                 $step = 120;
             } else {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 16);
                 $step = 100;
             }
         } else {
             $t->SetFont(FF_ARIAL, FS_BOLD, 12);
             $step = 80;
         }
         $t->SetColor('red@0.5');
         $t->Align('center', 'top');
         $t->SetAngle(-15);
         $n = ceil($totwidth / $step);
         for ($y = $ystart; $y < $yend; $y += 50) {
             for ($i = 0; $i < $n; ++$i) {
                 $t->SetPos(-30 + $i * $step, $y);
                 $t->Stroke($g->img);
             }
         }
     }
     if ($this->iVertical) {
         $g->img->img = $this->Rotate($g->img->img, 90);
     }
     if ($this->iScale != 1) {
         $nwidth = round($width * $this->iScale);
         $nheight = round($height * $this->iScale);
         if ($this->iVertical) {
             $tmp = $height;
             $height = $width;
             $width = $tmp;
             $tmp = $nheight;
             $nheight = $nwidth;
             $nwidth = $tmp;
         }
         $img = @imagecreatetruecolor($nwidth, $nheight);
         if ($img) {
             imagealphablending($img, true);
             imagecopyresampled($img, $g->img->img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
             $g->img->CreateImgCanvas($nwidth, $nheight);
             $g->img->img = $img;
         } else {
             return false;
         }
     }
     $g->Stroke($aFile);
     return true;
 }
Ejemplo n.º 2
0
 function Stroke($aData, $aFile = '', $aShowDetails = false, $aShowEncodingDetails = false)
 {
     $textmargin = 5;
     $this->iEncoder->AddChecksum($this->iUseChecksum);
     $spec = $this->iEncoder->Enc($aData);
     $this->AdjustSpec($spec);
     if ($this->iFontFam == -1) {
         if ($this->iModuleWidth > 1) {
             $this->iFontFam = FF_FONT2;
             $this->iFontStyle = FS_BOLD;
         } else {
             $this->iFontFam = FF_FONT1;
             $this->iFontStyle = FS_BOLD;
         }
     }
     $s = '';
     $n = count($spec->iBar);
     $g = new CanvasGraph(0, 0);
     $g->img->SetImgFormat($this->iImgFormat);
     if ($aShowDetails) {
         $s = $spec->iEncoding . "\n";
         $s .= 'Data: ' . $spec->iData . "\n";
         if ($spec->iInfo != '') {
             $s .= 'Info: ' . $spec->iInfo . "\n";
         }
     }
     $w = round($spec->iModuleWidth);
     $totwidth = $spec->iLeftMargin * $w;
     $n = count($spec->iBar);
     for ($i = 0; $i < $n; ++$i) {
         $b = $spec->iBar[$i];
         $bn = strlen($b[3]);
         for ($j = 0; $j < $bn; ++$j) {
             $wb = substr($b[3], $j, 1) * $w;
             $totwidth += $wb;
         }
     }
     if ($spec->iInterCharModuleSpace) {
         $totwidth += ($n - 2) * $w;
     }
     $totwidth += $spec->iRightMargin * $w + 1;
     $height = $this->iHeight;
     if ($aShowDetails) {
         $g->img->SetFont(FF_FONT2);
         $height += $g->img->GetTextHeight($s);
     }
     $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
     $th = $g->img->GetTextHeight($spec->iData);
     if ($spec->iStrokeDataBelow) {
         $height += $th + $this->iDataBelowMargin;
     }
     if ($height < round(0.15 * ($totwidth - $spec->iRightMargin * $w - $spec->iLeftMargin * $w))) {
         $height = round(0.15 * $totwidth);
     }
     $g->img->SetFont(FF_FONT2);
     $tw = 2 * $textmargin + $g->img->GetTextWidth($s);
     $width = $totwidth;
     if ($width < $tw) {
         $width = $tw;
     }
     if ($aShowEncodingDetails) {
         $g->img->SetFont(FF_FONT2);
         $height += $n * $g->img->GetTextHeight('0');
         $width = max(300, $totwidth);
     }
     $g = new CanvasGraph($width, $height);
     $g->img->SetImgFormat($this->iImgFormat);
     $g->SetMarginColor('white');
     if ($this->iShowFrame) {
         $g->frame_color = $this->iFrameColor;
         $g->InitFrame();
     }
     $g->img->SetColor('black');
     $x = $w * $spec->iLeftMargin;
     $ystart = $this->iTopMargin;
     $yend = $height - $this->iBottomMargin - 1;
     if ($aShowDetails) {
         $ystart += $g->img->GetTextHeight($s);
     }
     if ($aShowEncodingDetails) {
         $g->img->SetFont(FF_FONT2);
         $ystart += $n * $g->img->GetTextHeight('0');
     }
     if ($spec->iStrokeDataBelow) {
         $yend -= $th + $this->iDataBelowMargin;
     }
     $inunder = false;
     $under_s = '';
     $under_x = 0;
     for ($i = 0; $i < $n; ++$i) {
         $b = $spec->iBar[$i];
         if ($aShowEncodingDetails) {
             $s .= sprintf("%02d", $i) . " : {$b['0']}, {$b['1']}, {$b['2']}, {$b['3']}\n";
         }
         $bn = strlen($b[3]);
         if ($b[2] == 0 && !$this->iNoHumanText) {
             if (!$inunder) {
                 $inunder = true;
                 $under_x = $x;
                 $under_s = $b[0];
             } else {
                 $under_s .= $b[0];
             }
         } else {
             if ($inunder) {
                 $inunder = false;
                 if ($under_s != '') {
                     $t = new Text($under_s, ($under_x + $x - 1) / 2, $yend - $th / 1.3);
                     $t->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
                     $t->Align('center', 'top');
                     $t->Stroke($g->img);
                 }
             }
         }
         $startx = $x;
         for ($j = 0; $j < $bn; ++$j) {
             $wb = substr($b[3], $j, 1) * $w;
             if ($j % 2 == $b[1]) {
                 $g->img->SetColor($this->iBkgColor);
             } else {
                 $g->img->SetColor($this->iColor);
             }
             if ($b[2] == 1 || $this->iNoHumanText) {
                 $g->img->FilledRectangle($x, $ystart, $x + $wb - 1, $yend);
             } else {
                 $g->img->FilledRectangle($x, $ystart, $x + $wb - 1, $yend - $th);
             }
             $x += $wb;
         }
         if ($this->iDebugBackground) {
             $g->SetAlphaBlending();
             if (($i & 1) == 0) {
                 $g->img->SetColor('lightblue@0.5');
             } else {
                 $g->img->SetColor('yellow@0.5');
             }
             $g->img->FilledRectangle($startx, $ystart - 2, $x, $yend);
         }
         if ($spec->iInterCharModuleSpace) {
             $x += $w;
         }
     }
     $g->img->SetColor($this->iColor);
     if (!($spec->iLeftData === '')) {
         $g->img->SetTextAlign('right', 'top');
         $g->img->SetFont($this->iSmallFontFam, $this->iSmallFontStyle, $this->iSmallFontSize);
         $g->img->StrokeText($w * $spec->iLeftMargin - 3, $yend - $th, $spec->iLeftData);
     }
     if (!($spec->iRightData === '')) {
         $g->img->SetTextAlign('left', 'top');
         $g->img->SetFont($this->iSmallFontFam, $this->iSmallFontStyle, $this->iSmallFontSize);
         $g->img->StrokeText($x + 3, $yend - $th, $spec->iRightData);
     }
     if ($spec->iStrokeDataBelow) {
         $y = $yend + $this->iDataBelowMargin;
         $bw = $totwidth - $spec->iLeftMargin * $w - $spec->iRightMargin * $w;
         $x = $spec->iLeftMargin * $w + floor($bw / 2);
         $g->img->SetTextAlign('center', 'top');
         $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
         if ($this->iHumanTxt !== '') {
             $g->img->StrokeText($x, $y, $this->iHumanTxt);
         } else {
             $g->img->StrokeText($x, $y, $spec->iData);
         }
     }
     if ($aShowDetails) {
         $g->img->SetColor('navy');
         $g->img->SetTextAlign('left', 'top');
         $g->img->SetFont(FF_FONT2);
         $g->img->StrokeText($textmargin, $this->iTopMargin, $s);
     }
     if (ADD_DEMOTXT === true) {
         $t = new Text("<<DEMO>>", $totwidth / 2, $ystart);
         if ($this->iModuleWidth > 1) {
             if ($this->iModuleWidth > 4) {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 32);
                 $step = 140;
                 $yadj = 50;
             } else {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 24);
                 $step = 110;
                 $yadj = 40;
             }
         } else {
             $t->SetFont(FF_ARIAL, FS_BOLD, 18);
             $step = 80;
             $yadj = 30;
         }
         $t->SetColor('red@0.4');
         $t->Align('center', 'center');
         $t->SetAngle(-25);
         $n = ceil($totwidth / $step);
         for ($i = 0; $i < $n; ++$i) {
             $t->SetPos(-30 + $i * $step, ($yend - $ystart) / 2 - $yadj);
             $t->Stroke($g->img);
         }
     }
     if ($this->iVertical) {
         $g->img->img = $this->Rotate($g->img->img, 90);
     }
     if ($this->iScale != 1) {
         $nwidth = round($width * $this->iScale);
         $nheight = round($height * $this->iScale);
         if ($this->iVertical) {
             $tmp = $height;
             $height = $width;
             $width = $tmp;
             $tmp = $nheight;
             $nheight = $nwidth;
             $nwidth = $tmp;
         }
         $img = @imagecreatetruecolor($nwidth, $nheight);
         if ($img) {
             imagealphablending($img, true);
             imagecopyresampled($img, $g->img->img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
             $g->img->CreateImgCanvas($nwidth, $nheight);
             $g->img->img = $img;
         } else {
             return false;
         }
     }
     return $g->Stroke($aFile);
 }
Ejemplo n.º 3
0
 function strokeLabels()
 {
     $t = new Text();
     $t->SetColor($this->labelColor);
     $t->SetFont($this->labelFF, $this->labelFS, $this->labelFSize);
     $t->SetAlign('center', 'center');
     foreach ($this->labels as $cont_idx => $pos) {
         if ($cont_idx >= 10) {
             return;
         }
         foreach ($pos as $idx => $coord) {
             $t->Set(sprintf("%.1f", $coord[2]));
             $t->SetAngle($coord[3]);
             $t->Stroke($this->g->img, $coord[0], $coord[1]);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Construct the graph
  * 
  */
 private function Init()
 {
     // Setup limits for color indications
     $lowx = $this->iXMin;
     $highx = $this->iXMax;
     $lowy = $this->iYMin;
     $highy = $this->iYMax;
     $width = $this->iWidth;
     $height = $this->iHeight;
     // Margins
     $lm = 50;
     $rm = 40;
     $tm = 60;
     $bm = 40;
     if ($width <= 300 || $height <= 250) {
         $labelsize = 8;
         $lm = 25;
         $rm = 25;
         $tm = 45;
         $bm = 25;
     } elseif ($width <= 450 || $height <= 300) {
         $labelsize = 8;
         $lm = 30;
         $rm = 30;
         $tm = 50;
         $bm = 30;
     } elseif ($width <= 600 || $height <= 400) {
         $labelsize = 9;
     } else {
         $labelsize = 11;
     }
     if ($this->iSubTitle == '') {
         $tm -= $labelsize + 4;
     }
     $graph = new Graph($width, $height);
     $graph->SetScale('intint', $lowy, $highy, $lowx, $highx);
     $graph->SetMargin($lm, $rm, $tm, $bm);
     $graph->SetMarginColor($this->iMarginColor[$this->iColorMap]);
     $graph->SetClipping();
     $graph->title->Set($this->iTitle);
     $graph->subtitle->Set($this->iSubTitle);
     $graph->title->SetFont(FF_ARIAL, FS_BOLD, $labelsize + 4);
     $graph->subtitle->SetFont(FF_ARIAL, FS_BOLD, $labelsize + 1);
     $graph->SetBox(true, 'black@0.3');
     $graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, $labelsize);
     $graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, $labelsize);
     $graph->xaxis->scale->ticks->Set(CCBPGraph::TickStep, CCBPGraph::TickStep);
     $graph->yaxis->scale->ticks->Set(CCBPGraph::TickStep, CCBPGraph::TickStep);
     $graph->xaxis->HideZeroLabel();
     $graph->yaxis->HideZeroLabel();
     $graph->xaxis->SetLabelFormatString('%d%%');
     $graph->yaxis->SetLabelFormatString('%d%%');
     // For the x-axis we adjust the color so labels on the left of the Y-axis are in black
     $n1 = floor(abs($this->iXMin / 25)) + 1;
     $n2 = floor($this->iXMax / 25);
     if ($this->iColorMap == 0) {
         $xlcolors = array();
         for ($i = 0; $i < $n1; ++$i) {
             $xlcolors[$i] = 'black';
         }
         for ($i = 0; $i < $n2; ++$i) {
             $xlcolors[$n1 + $i] = 'lightgray:1.5';
         }
         $graph->xaxis->SetColor('gray', $xlcolors);
         $graph->yaxis->SetColor('gray', 'lightgray:1.5');
     } else {
         $graph->xaxis->SetColor('darkgray', 'darkgray:0.8');
         $graph->yaxis->SetColor('darkgray', 'darkgray:0.8');
     }
     $graph->SetGridDepth(DEPTH_FRONT);
     $graph->ygrid->SetColor('gray@0.6');
     $graph->ygrid->SetLineStyle('dotted');
     $graph->ygrid->Show();
     $graph->xaxis->SetWeight(1);
     $graph->yaxis->SetWeight(1);
     $ytitle = new Text(CCBPGraph::YTitle, floor($lm * 0.75), ($height - $tm - $bm) / 2 + $tm);
     #$ytitle->SetFont(FF_VERA,FS_BOLD,$labelsize+1);
     $ytitle->SetAlign('right', 'center');
     $ytitle->SetAngle(90);
     $graph->Add($ytitle);
     $xtitle = new Text(CCBPGraph::XTitle, ($width - $lm - $rm) / 2 + $lm, $height - 10);
     #$xtitle->SetFont(FF_VERA,FS_BOLD,$labelsize);
     $xtitle->SetAlign('center', 'bottom');
     $graph->Add($xtitle);
     $df = 'D j:S M, Y';
     if ($width < 400) {
         $df = 'D j:S M';
     }
     $time = new Text(date($df), $width - 10, $height - 10);
     $time->SetAlign('right', 'bottom');
     #$time->SetFont(FF_VERA,FS_NORMAL,$labelsize-1);
     $time->SetColor('darkgray');
     $graph->Add($time);
     // Use an accumulated fille line graph to create the colored bands
     $n = 3;
     for ($i = 0; $i < $n; ++$i) {
         $b = $this->iColorInd[$i][0];
         $k = ($this->iColorInd[$i][1] - $this->iColorInd[$i][0]) / $this->iXMax;
         $colarea[$i] = array(array($lowx, $lowx * $k + $b), array($highx, $highx * $k + $b));
     }
     $colarea[3] = array(array($lowx, $highy), array($highx, $highy));
     $cb = array();
     for ($i = 0; $i < 4; ++$i) {
         $cb[$i] = new LinePlot(array($colarea[$i][0][1], $colarea[$i][1][1]), array($colarea[$i][0][0], $colarea[$i][1][0]));
         $cb[$i]->SetFillColor($this->iColorSpec[$this->iColorMap][$i]);
         $cb[$i]->SetFillFromYMin();
     }
     $graph->Add(array_slice(array_reverse($cb), 0, 4));
     $this->graph = $graph;
 }
Ejemplo n.º 5
0
 public function Draw($aTitle, $aStart, $aEnd, $n = 64, $aReverse = false, $addColorNames = false)
 {
     // Setup to draw colormap with names platoe colors
     $lmarg = ColorMapDriver::LMARG;
     // left margin
     $rmarg = ColorMapDriver::RMARG;
     // right margin
     $width = ColorMapDriver::WIDTH;
     // Overall image width
     // Module height
     $mh = ColorMapDriver::MODHEIGHT;
     // Step between each map
     $ymarg = $mh + ColorMapDriver::MAPMARG;
     if ($addColorNames) {
         $ymarg += 50;
     }
     // Start position
     $xs = $lmarg;
     $ys = ColorMapDriver::YSTART;
     // Setup a basic canvas graph
     $height = ($aEnd - $aStart + 1) * $ymarg + 50;
     $graph = new CanvasGraph($width, $height);
     $graph->img->SetColor('darkgray');
     $graph->img->Rectangle(0, 0, $width - 1, $height - 1);
     $t = new Text($aTitle, $width / 2, 5);
     $t->SetAlign('center', 'top');
     $t->SetFont(FF_ARIAL, FS_BOLD, 14);
     $t->Stroke($graph->img);
     // Instantiate a colormap
     $cm = new ColorMap();
     $cm->InitRGB($graph->img->rgb);
     for ($mapidx = $aStart; $mapidx <= $aEnd; ++$mapidx, $ys += $ymarg) {
         $cm->SetMap($mapidx, $aReverse);
         $n = $cm->SetNumColors($n);
         list($mapidx, $maparray) = $cm->GetCurrMap();
         $ncols = count($maparray);
         $colbuckets = $cm->GetBuckets();
         // The module width will depend on the actual number of colors
         $mw = round(($width - $lmarg - $rmarg) / $n);
         // Draw color map title (name)
         $t->Set('Basic colors: ' . $ncols . ',   Total colors: ' . $n);
         $t->SetAlign('center', 'bottom');
         $t->SetAngle(0);
         $t->SetFont(FF_TIMES, FS_NORMAL, 14);
         $t->Stroke($graph->img, $width / 2, $ys - 3);
         // Add the name/number of the map to the left
         $t->SetAlign('right', 'center');
         $t->Set('Map: ' . $mapidx);
         $t->SetFont(FF_ARIAL, FS_NORMAL, 14);
         $t->Stroke($graph->img, $xs - 20, round($ys + $mh / 2));
         // Setup text properties for the color names
         if ($addColorNames) {
             $t->SetAngle(30);
             $t->SetFont(FF_ARIAL, FS_NORMAL, 12);
             $t->SetAlign('right', 'top');
         }
         // Loop through all colors in the map
         $x = $xs;
         $y = $ys;
         $k = 0;
         for ($i = 0; $i < $n; ++$i) {
             $graph->img->SetColor($colbuckets[$i]);
             $graph->img->FilledRectangle($x, $y, $x + $mw, $y + $mh);
             // Mark all basic colors in the map with a bar and name
             if ($i % (($n - $ncols) / ($ncols - 1) + 1) == 0) {
                 $graph->img->SetColor('black');
                 $graph->img->FilledRectangle($x, $y + $mh + 4, $x + $mw - 1, $y + $mh + 6);
                 if ($addColorNames) {
                     $t->Set($maparray[$k++]);
                     $t->Stroke($graph->img, $x + $mw / 2, $y + $mh + 10);
                 }
             }
             $x += $mw;
         }
         // Draw a border around the map
         $graph->img->SetColor('black');
         $graph->img->Rectangle($xs, $ys, $xs + $mw * $n, $ys + $mh);
     }
     // Send back to client
     $graph->Stroke();
 }
Ejemplo n.º 6
0
 /**
  * Internal. Stroke labels
  * @param MatrixPlot $aMPlot
  * @param Image $aImg
  */
 function Stroke(MatrixPlot $aMPlot, Image $aImg)
 {
     $t = new Text();
     $t->SetColor($this->iColor);
     $t->SetFont($this->iFF, $this->iFS, $this->iFSize);
     $n = count($this->iLabels);
     $rows = count($aMPlot->iData);
     $cols = count($aMPlot->iData[0]);
     list($modwidth, $modheight) = $aMPlot->GetModSizes();
     $x = $this->iStartX;
     $y = $this->iStartY;
     if (!empty($this->csimtargets) || is_array($this->csimtargets) && count($this->csimtargets) == 0) {
         $csn = count($this->csimtargets);
         if ($csn != $n) {
             JpGraphError::RaiseL(29210, $csn, $n);
             // CSIM Target for matrix labels must be the same length as the labels
         }
     }
     $csim = '';
     switch ($this->iSide) {
         case 'top':
         case 'bottom':
             $t->SetAngle($this->iAngle);
             $x += round($modwidth / 2);
             if ($this->iSide == 'top') {
                 $y -= $this->iMargin;
                 $t->SetAlign('center', 'bottom');
             } else {
                 $y += $this->iMargin + $rows * $modheight;
                 if ($this->iAngle > 0 && $this->iAngle < 90) {
                     $t->SetAlign('right', 'top');
                 } else {
                     $t->SetAlign('center', 'top');
                 }
             }
             for ($i = 0; $i < $n && $i < $cols; ++$i, $x += $modwidth) {
                 $t->Set($this->iLabels[$i]);
                 if (!empty($this->csimtargets)) {
                     if (!empty($this->csimalts[$i]) && !empty($this->csimwintargets[$i])) {
                         $t->SetCSIMTarget($this->csimtargets[$i], $this->csimalts[$i], $this->csimwintargets[$i]);
                     } elseif (!empty($this->csimalts[$i])) {
                         $t->SetCSIMTarget($this->csimtargets[$i], $this->csimalts[$i]);
                     } elseif (!empty($this->csimwintargets[$i])) {
                         $t->SetCSIMTarget($this->csimtargets[$i], '', $this->csimwintargets[$i]);
                     } else {
                         $t->SetCSIMTarget($this->csimtargets[$i]);
                     }
                 }
                 $t->Stroke($aImg, $x, $y);
                 $csim .= $t->GetCSIMareas();
             }
             break;
         case 'left':
         case 'right':
             $t->SetAngle($this->iAngle);
             $y += round($modheight / 2);
             if ($this->iSide == 'left') {
                 $x -= $this->iMargin + 1;
                 $t->SetAlign('right', 'center');
             } else {
                 $x += $this->iMargin + $cols * $modwidth;
                 $t->SetAlign('left', 'center');
             }
             for ($i = 0; $i < $n && $i < $rows; ++$i, $y += $modheight) {
                 $t->Set($this->iLabels[$i]);
                 if (!empty($this->csimtargets)) {
                     if (!empty($this->csimalts[$i]) && !empty($this->csimwintargets[$i])) {
                         $t->SetCSIMTarget($this->csimtargets[$i], $this->csimalts[$i], $this->csimwintargets[$i]);
                     } elseif (!empty($this->csimalts[$i])) {
                         $t->SetCSIMTarget($this->csimtargets[$i], $this->csimalts[$i]);
                     } elseif (!empty($this->csimwintargets[$i])) {
                         $t->SetCSIMTarget($this->csimtargets[$i], '', $this->csimwintargets[$i]);
                     } else {
                         $t->SetCSIMTarget($this->csimtargets[$i]);
                     }
                 }
                 $t->Stroke($aImg, $x, $y);
                 $csim .= $t->GetCSIMareas();
             }
             break;
     }
     $this->csimareas = $csim;
 }
Ejemplo n.º 7
0
 function create_image()
 {
     include './lib/jpgraph/jpgraph.php';
     include './lib/jpgraph/jpgraph_polar.php';
     $graph = new PolarGraph(250, 250);
     $graph->SetScale('lin');
     $graph->SetMargin(0, 1, 0, 1);
     $graph->axis->ShowAngleLabel(false);
     $graph->axis->HideTicks();
     $graph->axis->HideLabels();
     $graph->axis->HideLine();
     $fonts = array(FF_ARIAL, FF_VERDANA, FF_TREBUCHE, FF_GEORGIA, FF_COMIC, FF_COURIER, FF_TIMES);
     $styles = array(FS_NORMAL, FS_BOLD, FS_ITALIC);
     $text = $this->generate_pass(6);
     $font = $fonts[rand(0, count($fonts) - 1)];
     $style = $styles[rand(0, count($styles) - 1)];
     if ($font == FF_COMIC && $style == FS_ITALIC) {
         $style = FS_NORMAL;
     }
     $txt = new Text($text);
     $txt->Pos(rand(10, 140), rand(10, 140));
     $txt->SetFont($font, $style, rand(20, 26));
     $txt->SetColor('black');
     $txt->SetAngle(rand(-45, 45));
     $graph->AddText($txt);
     $graph->Stroke('./register.png');
     return array(md5("{$this->sets['db_pass']}{$this->sets['mostonlinetime']}{$text}"), './register.png');
 }
Ejemplo n.º 8
0
 /**
  * Stroke all stored labels to the plot
  *
  * @return void
  */
 function StrokeLabels()
 {
     $t = new Text();
     $t->SetColor($this->labelColor);
     $t->SetFont($this->labelFF, $this->labelFS, $this->labelFSize);
     $t->SetAlign('center', 'center');
     foreach ($this->labels as $cont_idx => $pos) {
         // FIXME:
         //if( $cont_idx >= 10 ) return;
         foreach ($pos as $idx => $coord) {
             $t->Set(sprintf("%.1f", $coord[2]));
             if ($this->angledLabels) {
                 $t->SetAngle($coord[3]);
             }
             //$t->SetBox2('lightyellow:1.9');
             $t->Stroke($this->img, $coord[0], $coord[1]);
         }
     }
 }
Ejemplo n.º 9
0
 function create_image()
 {
     include './lib/jpgraph/jpgraph.php';
     include './lib/jpgraph/jpgraph_polar.php';
     if (!function_exists('imagejpeg')) {
         JpGraphError::Raise("This PHP installation is not configured with JPEG support meaning that anti-robot registration cannnot be run at this current time. Please recompile PHP with GD and JPEG support to run JpGraph and that will allow anti-robot registration to fully function. (Function imagejpeg() does not exist)");
     }
     $graph = new PolarGraph(250, 250);
     $graph->SetScale('lin');
     $graph->SetMargin(0, 1, 0, 1);
     $graph->axis->ShowAngleLabel(false);
     $graph->axis->HideTicks();
     $graph->axis->HideLabels();
     $graph->axis->HideLine();
     $fonts = array(FF_ARIAL, FF_VERDANA, FF_TREBUCHE, FF_GEORGIA, FF_COMIC, FF_COURIER, FF_TIMES);
     $styles = array(FS_NORMAL, FS_BOLD, FS_ITALIC);
     $text = $this->generate_pass(6);
     $font = $fonts[rand(0, count($fonts) - 1)];
     $style = $styles[rand(0, count($styles) - 1)];
     if ($font == FF_COMIC && $style == FS_ITALIC) {
         $style = FS_NORMAL;
     }
     $txt = new Text($text);
     $txt->Pos(rand(10, 140), rand(10, 140));
     $txt->SetFont($font, $style, rand(20, 26));
     $txt->SetColor('black');
     $txt->SetAngle(rand(-45, 45));
     $graph->AddText($txt);
     $graph->Stroke('./register.png');
     return array(md5("{$this->sets['db_pass']}{$this->sets['mostonlinetime']}{$text}"), './register.png');
 }