Esempio n. 1
0
 public function Stroke($aStrokeFileName = '')
 {
     // If the filename is the predefined value = '_csim_special_'
     // we assume that the call to stroke only needs to do enough
     // to correctly generate the CSIM maps.
     // We use this variable to skip things we don't strictly need
     // to do to generate the image map to improve performance
     // a best we can. Therefor you will see a lot of tests !$_csim in the
     // code below.
     $_csim = $aStrokeFileName === _CSIM_SPECIALFILE;
     // We need to know if we have stroked the plot in the
     // GetCSIMareas. Otherwise the CSIM hasn't been generated
     // and in the case of GetCSIM called before stroke to generate
     // CSIM without storing an image to disk GetCSIM must call Stroke.
     $this->iHasStroked = true;
     $n = count($this->plots);
     // Set Y-scale
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax($this->plots);
         $this->yscale->AutoScale($this->img, 0, $max, $this->len / $this->ytick_factor);
     } elseif ($this->yscale->IsSpecified() && ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) {
         // The tick calculation will use the user suplied min/max values to determine
         // the ticks. If auto_ticks is false the exact user specifed min and max
         // values will be used for the scale.
         // If auto_ticks is true then the scale might be slightly adjusted
         // so that the min and max values falls on an even major step.
         $min = $this->yscale->scale[0];
         $max = $this->yscale->scale[1];
         $this->yscale->AutoScale($this->img, $min, $max, $this->len / $this->ytick_factor, $this->yscale->auto_ticks);
     }
     // Set start position end length of scale (in absolute pixels)
     $this->yscale->SetConstants($this->posx, $this->len);
     // We need as many axis as there are data points
     $nbrpnts = $this->plots[0]->GetCount();
     // If we have no titles just number the axis 1,2,3,...
     if ($this->axis_title == null) {
         for ($i = 0; $i < $nbrpnts; ++$i) {
             $this->axis_title[$i] = $i + 1;
         }
     } elseif (count($this->axis_title) < $nbrpnts) {
         Util\JpGraphError::RaiseL(18007);
         // ("Number of titles does not match number of points in plot.");
     }
     for ($i = 0; $i < $n; ++$i) {
         if ($nbrpnts != $this->plots[$i]->GetCount()) {
             Util\JpGraphError::RaiseL(18008);
             //("Each radar plot must have the same number of data points.");
         }
     }
     if (!$_csim) {
         if ($this->background_image != '') {
             $this->StrokeFrameBackground();
         } else {
             $this->StrokeFrame();
             $this->StrokeBackgroundGrad();
         }
     }
     $astep = 2 * M_PI / $nbrpnts;
     if (!$_csim) {
         if ($this->iIconDepth == DEPTH_BACK) {
             $this->StrokeIcons();
         }
         // Prepare legends
         for ($i = 0; $i < $n; ++$i) {
             $this->plots[$i]->Legend($this);
         }
         $this->legend->Stroke($this->img);
         $this->footer->Stroke($this->img);
     }
     if (!$_csim) {
         if ($this->grid_depth == DEPTH_BACK) {
             // Draw axis and grid
             for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) {
                 $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0);
             }
             $this->grid->Stroke($this->img, $grid);
         }
         if ($this->iIconDepth == DEPTH_BACK) {
             $this->StrokeIcons();
         }
     }
     // Plot points
     $a = M_PI / 2;
     for ($i = 0; $i < $n; ++$i) {
         $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a);
     }
     if (!$_csim) {
         if ($this->grid_depth != DEPTH_BACK) {
             // Draw axis and grid
             for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) {
                 $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0);
             }
             $this->grid->Stroke($this->img, $grid);
         }
         $this->StrokeTitles();
         $this->StrokeTexts();
         if ($this->iIconDepth == DEPTH_FRONT) {
             $this->StrokeIcons();
         }
     }
     // Should we do any final image transformation
     if ($this->iImgTrans && !$_csim) {
         $tform = new ImgTrans($this->img->img);
         $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder);
     }
     if (!$_csim) {
         // If the filename is given as the special "__handle"
         // then the image handler is returned and the image is NOT
         // streamed back
         if ($aStrokeFileName == _IMG_HANDLER) {
             return $this->img->img;
         } else {
             // Finally stream the generated picture
             $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
         }
     }
 }
Esempio n. 2
0
 public function Stroke($aStrokeFileName = "")
 {
     // If the filename is the predefined value = '_csim_special_'
     // we assume that the call to stroke only needs to do enough
     // to correctly generate the CSIM maps.
     // We use this variable to skip things we don't strictly need
     // to do to generate the image map to improve performance
     // a best we can. Therefor you will see a lot of tests !$_csim in the
     // code below.
     $_csim = $aStrokeFileName === _CSIM_SPECIALFILE;
     // If we are called the second time (perhaps the user has called GetHTMLImageMap()
     // himself then the legends have alsready been populated once in order to get the
     // CSIM coordinats. Since we do not want the legends to be populated a second time
     // we clear the legends
     $this->legend->Clear();
     // We need to know if we have stroked the plot in the
     // GetCSIMareas. Otherwise the CSIM hasn't been generated
     // and in the case of GetCSIM called before stroke to generate
     // CSIM without storing an image to disk GetCSIM must call Stroke.
     $this->iHasStroked = true;
     $n = count($this->plots);
     if ($this->pieaa) {
         if (!$_csim) {
             if ($this->background_image != "") {
                 $this->StrokeFrameBackground();
             } else {
                 $this->StrokeFrame();
                 $this->StrokeBackgroundGrad();
             }
         }
         $w = $this->img->width;
         $h = $this->img->height;
         $oldimg = $this->img->img;
         $this->img->CreateImgCanvas(2 * $w, 2 * $h);
         $this->img->SetColor($this->margin_color);
         $this->img->FilledRectangle(0, 0, 2 * $w - 1, 2 * $h - 1);
         // Make all icons *2 i size since we will be scaling down the
         // imahe to do the anti aliasing
         $ni = count($this->iIcons);
         for ($i = 0; $i < $ni; ++$i) {
             $this->iIcons[$i]->iScale *= 2;
             if ($this->iIcons[$i]->iX > 1) {
                 $this->iIcons[$i]->iX *= 2;
             }
             if ($this->iIcons[$i]->iY > 1) {
                 $this->iIcons[$i]->iY *= 2;
             }
         }
         $this->StrokeIcons();
         for ($i = 0; $i < $n; ++$i) {
             if ($this->plots[$i]->posx > 1) {
                 $this->plots[$i]->posx *= 2;
             }
             if ($this->plots[$i]->posy > 1) {
                 $this->plots[$i]->posy *= 2;
             }
             $this->plots[$i]->Stroke($this->img, 1);
             if ($this->plots[$i]->posx > 1) {
                 $this->plots[$i]->posx /= 2;
             }
             if ($this->plots[$i]->posy > 1) {
                 $this->plots[$i]->posy /= 2;
             }
         }
         $indent = $this->doframe ? $this->frame_weight + ($this->doshadow ? $this->shadow_width : 0) : 0;
         $indent += $this->framebevel ? $this->framebeveldepth + 1 : 0;
         $this->img->CopyCanvasH($oldimg, $this->img->img, $indent, $indent, $indent, $indent, $w - 2 * $indent, $h - 2 * $indent, 2 * ($w - $indent), 2 * ($h - $indent));
         $this->img->img = $oldimg;
         $this->img->width = $w;
         $this->img->height = $h;
         for ($i = 0; $i < $n; ++$i) {
             $this->plots[$i]->Stroke($this->img, 2);
             // Stroke labels
             $this->plots[$i]->Legend($this);
         }
     } else {
         if (!$_csim) {
             if ($this->background_image != "") {
                 $this->StrokeFrameBackground();
             } else {
                 $this->StrokeFrame();
                 $this->StrokeBackgroundGrad();
             }
         }
         $this->StrokeIcons();
         for ($i = 0; $i < $n; ++$i) {
             $this->plots[$i]->Stroke($this->img);
             $this->plots[$i]->Legend($this);
         }
     }
     $this->legend->Stroke($this->img);
     $this->footer->Stroke($this->img);
     $this->StrokeTitles();
     if (!$_csim) {
         // Stroke texts
         if ($this->texts != null) {
             $n = count($this->texts);
             for ($i = 0; $i < $n; ++$i) {
                 $this->texts[$i]->Stroke($this->img);
             }
         }
         if (_JPG_DEBUG) {
             $this->DisplayCSIMAreas();
         }
         // Should we do any final image transformation
         if ($this->iImgTrans) {
             $tform = new ImgTrans($this->img->img);
             $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder);
         }
         // If the filename is given as the special "__handle"
         // then the image handler is returned and the image is NOT
         // streamed back
         if ($aStrokeFileName == _IMG_HANDLER) {
             return $this->img->img;
         } else {
             // Finally stream the generated picture
             $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
         }
     }
 }
Esempio n. 3
0
 public function Stroke($aStrokeFileName = "")
 {
     // If the filename is the predefined value = '_csim_special_'
     // we assume that the call to stroke only needs to do enough
     // to correctly generate the CSIM maps.
     // We use this variable to skip things we don't strictly need
     // to do to generate the image map to improve performance
     // a best we can. Therefor you will see a lot of tests !$_csim in the
     // code below.
     $_csim = $aStrokeFileName === _CSIM_SPECIALFILE;
     // Should we autoscale dates?
     if (!$this->scale->IsRangeSet()) {
         list($min, $max) = $this->GetBarMinMax();
         $this->scale->SetRange($min, $max);
     }
     $this->scale->AdjustStartEndDay();
     // Check if we should autoscale the image
     $this->AutoSize();
     // Should we start from the top or just spread the bars out even over the
     // available height
     $this->scale->SetVertLayout($this->iLayout);
     if ($this->iLayout == GANTT_FROMTOP) {
         $maxheight = max($this->GetMaxLabelHeight(), $this->GetMaxBarAbsHeight());
         $this->scale->SetVertSpacing($maxheight * (1 + $this->iLabelVMarginFactor));
     }
     // If it hasn't been set find out the maximum line number
     if ($this->scale->iVertLines == -1) {
         $this->scale->iVertLines = $this->GetBarMaxLineNumber() + 1;
     }
     $maxwidth = max($this->scale->actinfo->GetWidth($this->img), max($this->GetMaxLabelWidth(), $this->scale->tableTitle->GetWidth($this->img)));
     $this->scale->SetLabelWidth($maxwidth + $this->scale->divider->iWeight);
     //*(1+$this->iLabelHMarginFactor));
     if (!$_csim) {
         $this->StrokePlotArea();
         if ($this->iIconDepth == DEPTH_BACK) {
             $this->StrokeIcons();
         }
     }
     $this->scale->Stroke();
     if (!$_csim) {
         // Due to a minor off by 1 bug we need to temporarily adjust the margin
         $this->img->right_margin--;
         $this->StrokePlotBox();
         $this->img->right_margin++;
     }
     // Stroke Grid line
     $this->hgrid->Stroke($this->img, $this->scale);
     $n = count($this->iObj);
     for ($i = 0; $i < $n; ++$i) {
         //$this->iObj[$i]->SetLabelLeftMargin(round($maxwidth*$this->iLabelHMarginFactor/2));
         $this->iObj[$i]->Stroke($this->img, $this->scale);
     }
     $this->StrokeTitles();
     if (!$_csim) {
         $this->StrokeConstrains();
         $this->footer->Stroke($this->img);
         if ($this->iIconDepth == DEPTH_FRONT) {
             $this->StrokeIcons();
         }
         // Stroke all added user texts
         $this->StrokeTexts();
         // Should we do any final image transformation
         if ($this->iImgTrans) {
             $tform = new ImgTrans($this->img->img);
             $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder);
         }
         // If the filename is given as the special "__handle"
         // then the image handler is returned and the image is NOT
         // streamed back
         if ($aStrokeFileName == _IMG_HANDLER) {
             return $this->img->img;
         } else {
             // Finally stream the generated picture
             $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
         }
     }
 }