Example #1
0
 function Stroke(&$aImg)
 {
     // Constant
     $fillBoxFrameWeight = 1;
     if ($this->hide) {
         return;
     }
     $aImg->SetFont($this->font_family, $this->font_style, $this->font_size);
     if ($this->reverse) {
         $this->txtcol = array_reverse($this->txtcol);
     }
     $n = count($this->txtcol);
     if ($n == 0) {
         return;
     }
     // Find out the max width and height of each column to be able
     // to size the legend box.
     $numcolumns = $n > $this->layout_n ? $this->layout_n : $n;
     for ($i = 0; $i < $numcolumns; ++$i) {
         $colwidth[$i] = $aImg->GetTextWidth($this->txtcol[$i][0]) + 2 * $this->xmargin + 2 * $this->mark_abs_hsize;
         $colheight[$i] = 0;
     }
     // Find our maximum height in each row
     $rows = 0;
     $rowheight[0] = 0;
     for ($i = 0; $i < $n; ++$i) {
         $h = max($this->mark_abs_vsize, $aImg->GetTextHeight($this->txtcol[$i][0])) + $this->ymargin;
         if ($i % $numcolumns == 0) {
             $rows++;
             $rowheight[$rows - 1] = 0;
         }
         $rowheight[$rows - 1] = max($rowheight[$rows - 1], $h);
     }
     $abs_height = 0;
     for ($i = 0; $i < $rows; ++$i) {
         $abs_height += $rowheight[$i];
     }
     // Make sure that the height is at least as high as mark size + ymargin
     $abs_height = max($abs_height, $this->mark_abs_vsize);
     // We add 3 extra pixels height to compensate for the difficult in
     // calculating font height
     $abs_height += $this->ymargin + 3;
     // Find out the maximum width in each column
     for ($i = $numcolumns; $i < $n; ++$i) {
         $colwidth[$i % $numcolumns] = max($aImg->GetTextWidth($this->txtcol[$i][0]) + 2 * $this->xmargin + 2 * $this->mark_abs_hsize, $colwidth[$i % $numcolumns]);
     }
     // Get the total width
     $mtw = 0;
     for ($i = 0; $i < $numcolumns; ++$i) {
         $mtw += $colwidth[$i];
     }
     // Find out maximum width we need for legend box
     $abs_width = $mtw + $this->xlmargin;
     if ($this->xabspos === -1 && $this->yabspos === -1) {
         $this->xabspos = $this->xpos * $aImg->width;
         $this->yabspos = $this->ypos * $aImg->height;
     }
     // Positioning of the legend box
     if ($this->halign == 'left') {
         $xp = $this->xabspos;
     } elseif ($this->halign == 'center') {
         $xp = $this->xabspos - $abs_width / 2;
     } else {
         $xp = $aImg->width - $this->xabspos - $abs_width;
     }
     $yp = $this->yabspos;
     if ($this->valign == 'center') {
         $yp -= $abs_height / 2;
     } elseif ($this->valign == 'bottom') {
         $yp -= $abs_height;
     }
     // Stroke legend box
     $aImg->SetColor($this->color);
     $aImg->SetLineWeight($this->frameweight);
     $aImg->SetLineStyle('solid');
     if ($this->shadow) {
         $aImg->ShadowRectangle($xp, $yp, $xp + $abs_width + $this->shadow_width, $yp + $abs_height + $this->shadow_width, $this->fill_color, $this->shadow_width, $this->shadow_color);
     } else {
         $aImg->SetColor($this->fill_color);
         $aImg->FilledRectangle($xp, $yp, $xp + $abs_width, $yp + $abs_height);
         $aImg->SetColor($this->color);
         $aImg->Rectangle($xp, $yp, $xp + $abs_width, $yp + $abs_height);
     }
     // x1,y1 is the position for the legend mark
     $x1 = $xp + $this->mark_abs_hsize + $this->xlmargin;
     $y1 = $yp + $this->ymargin;
     $f2 = round($aImg->GetTextHeight('X') / 2);
     $grad = new Gradient($aImg);
     $patternFactory = null;
     // Now stroke each legend in turn
     // Each plot has added the following information to  the legend
     // p[0] = Legend text
     // p[1] = Color,
     // p[2] = For markers a reference to the PlotMark object
     // p[3] = For lines the line style, for gradient the negative gradient style
     // p[4] = CSIM target
     // p[5] = CSIM Alt text
     $i = 1;
     $row = 0;
     foreach ($this->txtcol as $p) {
         // STROKE DEBUG BOX
         if (_JPG_DEBUG) {
             $aImg->SetLineWeight(1);
             $aImg->SetColor('red');
             $aImg->SetLineStyle('solid');
             $aImg->Rectangle($xp, $y1, $xp + $abs_width, $y1 + $rowheight[$row]);
         }
         $aImg->SetLineWeight($this->weight);
         $x1 = round($x1);
         $y1 = round($y1);
         if (!empty($p[2]) && $p[2]->GetType() > -1) {
             // Make a plot mark legend
             $aImg->SetColor($p[1]);
             if (is_string($p[3]) || $p[3] > 0) {
                 $aImg->SetLineStyle($p[3]);
                 $aImg->StyleLine($x1 - $this->mark_abs_hsize, $y1 + $f2, $x1 + $this->mark_abs_hsize, $y1 + $f2);
             }
             // Stroke a mark with the standard size
             // (As long as it is not an image mark )
             if ($p[2]->GetType() != MARK_IMG) {
                 // Clear any user callbacks since we ont want them called for
                 // the legend marks
                 $p[2]->iFormatCallback = '';
                 $p[2]->iFormatCallback2 = '';
                 // Since size for circles is specified as the radius
                 // this means that we must half the size to make the total
                 // width behave as the other marks
                 if ($p[2]->GetType() == MARK_FILLEDCIRCLE || $p[2]->GetType() == MARK_CIRCLE) {
                     $p[2]->SetSize(min($this->mark_abs_vsize, $this->mark_abs_hsize) / 2);
                     $p[2]->Stroke($aImg, $x1, $y1 + $f2);
                 } else {
                     $p[2]->SetSize(min($this->mark_abs_vsize, $this->mark_abs_hsize));
                     $p[2]->Stroke($aImg, $x1, $y1 + $f2);
                 }
             }
         } elseif (!empty($p[2]) && (is_string($p[3]) || $p[3] > 0)) {
             // Draw a styled line
             $aImg->SetColor($p[1]);
             $aImg->SetLineStyle($p[3]);
             $aImg->StyleLine($x1 - 1, $y1 + $f2, $x1 + $this->mark_abs_hsize, $y1 + $f2);
             $aImg->StyleLine($x1 - 1, $y1 + $f2 + 1, $x1 + $this->mark_abs_hsize, $y1 + $f2 + 1);
         } else {
             // Draw a colored box
             $color = $p[1];
             // We make boxes slightly larger to better show
             $boxsize = min($this->mark_abs_vsize, $this->mark_abs_hsize) + 2;
             $ym = round($y1 + $f2 - $boxsize / 2);
             // We either need to plot a gradient or a
             // pattern. To differentiate we use a kludge.
             // Patterns have a p[3] value of < -100
             if ($p[3] < -100) {
                 // p[1][0] == iPattern, p[1][1] == iPatternColor, p[1][2] == iPatternDensity
                 if ($patternFactory == null) {
                     $patternFactory = new RectPatternFactory();
                 }
                 $prect = $patternFactory->Create($p[1][0], $p[1][1], 1);
                 $prect->SetBackground($p[1][3]);
                 $prect->SetDensity($p[1][2] + 1);
                 $prect->SetPos(new Rectangle($x1, $ym, $boxsize, $boxsize));
                 $prect->Stroke($aImg);
                 $prect = null;
             } else {
                 if (is_array($color) && count($color) == 2) {
                     // The client want a gradient color
                     $grad->FilledRectangle($x1, $ym, $x1 + $boxsize, $ym + $boxsize, $color[0], $color[1], -$p[3]);
                 } else {
                     $aImg->SetColor($p[1]);
                     $aImg->FilledRectangle($x1, $ym, $x1 + $boxsize, $ym + $boxsize);
                 }
                 $aImg->SetColor($this->color);
                 $aImg->SetLineWeight($fillBoxFrameWeight);
                 $aImg->Rectangle($x1, $ym, $x1 + $boxsize, $ym + $boxsize);
             }
         }
         $aImg->SetColor($this->font_color);
         $aImg->SetFont($this->font_family, $this->font_style, $this->font_size);
         $aImg->SetTextAlign("left", "top");
         $aImg->StrokeText(round($x1 + $this->mark_abs_hsize + $this->xmargin), $y1, $p[0]);
         // Add CSIM for Legend if defined
         if (!empty($p[4])) {
             $xe = $x1 + $this->xmargin + $this->mark_abs_hsize + $aImg->GetTextWidth($p[0]);
             $ye = $y1 + max($this->mark_abs_vsize, $aImg->GetTextHeight($p[0]));
             $coords = "{$x1},{$y1},{$xe},{$y1},{$xe},{$ye},{$x1},{$ye}";
             if (!empty($p[4])) {
                 $this->csimareas .= "<area shape=\"poly\" coords=\"{$coords}\" href=\"" . atk_htmlentities($p[4]) . "\"";
                 if (!empty($p[6])) {
                     $this->csimareas .= " target=\"" . $p[6] . "\"";
                 }
                 if (!empty($p[5])) {
                     $tmp = sprintf($p[5], $p[0]);
                     $this->csimareas .= " title=\"{$tmp}\" alt=\"{$tmp}\" ";
                 }
                 $this->csimareas .= " />\n";
             }
         }
         if ($i >= $this->layout_n) {
             $x1 = $xp + $this->mark_abs_hsize + $this->xlmargin;
             $y1 += $rowheight[$row++];
             $i = 1;
         } else {
             $x1 += $colwidth[($i - 1) % $numcolumns];
             ++$i;
         }
     }
 }
Example #2
0
<?php

atkPage::getInstance()->register_script(atkconfig('atkroot') . 'atk/javascript/overlibmws/overlibmws.js');
$theme = atkinstance("atk.ui.atktheme");
$image = $theme->imgPath("help");
$tooltip = atk_htmlentities(str_replace(array("\r\n", "\r", "\n"), ' ', $tooltip));
?>

<img align="top" src="<?php 
echo $image;
?>
" border="0" style="margin-left: 3px;"
     onmouseover="return overlib( & quot;<?php 
echo $tooltip;
?>
 & quot; , BGCLASS, 'overlib_bg', FGCLASS, 'overlib_fg', TEXTFONTCLASS, 'overlib_txt', WIDTH, 300);"
     onmouseout="return nd();"/>
Example #3
0
 function meth_Misc_Alert($Source, $Message, $NoErrMsg = false)
 {
     $x = '<br /><b>TinyButStrong Error</b> (' . $Source . '): ' . atk_htmlentities($Message);
     if ($NoErrMsg) {
         $x = $x . ' <em>This message can be cancelled using parameter \'noerr\'.</em>';
     }
     $x = $x . "<br />\n";
     $x = str_replace($this->ChrOpen, $this->ChrProtect, $x);
     //echo $x;
     return false;
 }
 function Stroke($img, $x, $y)
 {
     if (!$this->show) {
         return;
     }
     if ($this->iFormatCallback != '' || $this->iFormatCallback2 != '') {
         if ($this->iFormatCallback != '') {
             $f = $this->iFormatCallback;
             list($width, $color, $fcolor) = call_user_func($f, $this->yvalue);
             $filename = $this->iFileName;
             $imgscale = $this->iScale;
         } else {
             $f = $this->iFormatCallback2;
             list($width, $color, $fcolor, $filename, $imgscale) = call_user_func($f, $this->yvalue, $this->xvalue);
             if ($filename == "") {
                 $filename = $this->iFileName;
             }
             if ($imgscale == "") {
                 $imgscale = $this->iScale;
             }
         }
         if ($width == "") {
             $width = $this->width;
         }
         if ($color == "") {
             $color = $this->color;
         }
         if ($fcolor == "") {
             $fcolor = $this->fill_color;
         }
     } else {
         $fcolor = $this->fill_color;
         $color = $this->color;
         $width = $this->width;
         $filename = $this->iFileName;
         $imgscale = $this->iScale;
     }
     if ($this->type == MARK_IMG || $this->type >= MARK_FLAG1 && $this->type <= MARK_FLAG4 || $this->type >= MARK_IMG_PUSHPIN) {
         // Note: For the builtin images we use the "filename" parameter
         // to denote the color
         $anchor_x = 0.5;
         $anchor_y = 0.5;
         switch ($this->type) {
             case MARK_FLAG1:
             case MARK_FLAG2:
             case MARK_FLAG3:
             case MARK_FLAG4:
                 $this->markimg = FlagCache::GetFlagImgByName($this->type - MARK_FLAG1 + 1, $filename);
                 break;
             case MARK_IMG:
                 // Load an image and use that as a marker
                 // Small optimization, if we have already read an image don't
                 // waste time reading it again.
                 if ($this->markimg == '' || !($this->oldfilename === $filename)) {
                     $this->markimg = Graph::LoadBkgImage('', $filename);
                     $this->oldfilename = $filename;
                 }
                 break;
             case MARK_IMG_PUSHPIN:
             case MARK_IMG_SPUSHPIN:
             case MARK_IMG_LPUSHPIN:
                 if ($this->imgdata_pushpins == null) {
                     require_once 'imgdata_pushpins.inc.php';
                     $this->imgdata_pushpins = new ImgData_PushPins();
                 }
                 $this->markimg = $this->imgdata_pushpins->GetImg($this->type, $filename);
                 list($anchor_x, $anchor_y) = $this->imgdata_pushpins->GetAnchor();
                 break;
             case MARK_IMG_SQUARE:
                 if ($this->imgdata_squares == null) {
                     require_once 'imgdata_squares.inc.php';
                     $this->imgdata_squares = new ImgData_Squares();
                 }
                 $this->markimg = $this->imgdata_squares->GetImg($this->type, $filename);
                 list($anchor_x, $anchor_y) = $this->imgdata_squares->GetAnchor();
                 break;
             case MARK_IMG_STAR:
                 if ($this->imgdata_stars == null) {
                     require_once 'imgdata_stars.inc.php';
                     $this->imgdata_stars = new ImgData_Stars();
                 }
                 $this->markimg = $this->imgdata_stars->GetImg($this->type, $filename);
                 list($anchor_x, $anchor_y) = $this->imgdata_stars->GetAnchor();
                 break;
             case MARK_IMG_BEVEL:
                 if ($this->imgdata_bevels == null) {
                     require_once 'imgdata_bevels.inc.php';
                     $this->imgdata_bevels = new ImgData_Bevels();
                 }
                 $this->markimg = $this->imgdata_bevels->GetImg($this->type, $filename);
                 list($anchor_x, $anchor_y) = $this->imgdata_bevels->GetAnchor();
                 break;
             case MARK_IMG_DIAMOND:
                 if ($this->imgdata_diamonds == null) {
                     require_once 'imgdata_diamonds.inc.php';
                     $this->imgdata_diamonds = new ImgData_Diamonds();
                 }
                 $this->markimg = $this->imgdata_diamonds->GetImg($this->type, $filename);
                 list($anchor_x, $anchor_y) = $this->imgdata_diamonds->GetAnchor();
                 break;
             case MARK_IMG_BALL:
             case MARK_IMG_SBALL:
             case MARK_IMG_MBALL:
             case MARK_IMG_LBALL:
                 if ($this->imgdata_balls == null) {
                     require_once 'imgdata_balls.inc.php';
                     $this->imgdata_balls = new ImgData_Balls();
                 }
                 $this->markimg = $this->imgdata_balls->GetImg($this->type, $filename);
                 list($anchor_x, $anchor_y) = $this->imgdata_balls->GetAnchor();
                 break;
         }
         $w = $img->GetWidth($this->markimg);
         $h = $img->GetHeight($this->markimg);
         $dw = round($imgscale * $w);
         $dh = round($imgscale * $h);
         // Do potential rotation
         list($x, $y) = $img->Rotate($x, $y);
         $dx = round($x - $dw * $anchor_x);
         $dy = round($y - $dh * $anchor_y);
         $this->width = max($dx, $dy);
         $img->Copy($this->markimg, $dx, $dy, 0, 0, $dw, $dh, $w, $h);
         if (!empty($this->csimtarget)) {
             $this->csimareas = "<area shape=\"rect\" coords=\"" . $dx . ',' . $dy . ',' . round($dx + $dw) . ',' . round($dy + $dh) . '" ' . "href=\"" . atk_htmlentities($this->csimtarget) . "\"";
             if (!empty($this->csimwintarget)) {
                 $this->csimareas .= " target=\"" . $this->csimwintarget . "\" ";
             }
             if (!empty($this->csimalt)) {
                 $tmp = sprintf($this->csimalt, $this->yvalue, $this->xvalue);
                 $this->csimareas .= " title=\"{$tmp}\" alt=\"{$tmp}\" ";
             }
             $this->csimareas .= " />\n";
         }
         // Stroke title
         $this->title->Align("center", "top");
         $this->title->Stroke($img, $x, $y + round($dh / 2));
         return;
     }
     $weight = $this->weight;
     $dx = round($width / 2, 0);
     $dy = round($width / 2, 0);
     $pts = 0;
     switch ($this->type) {
         case MARK_SQUARE:
             $c[] = $x - $dx;
             $c[] = $y - $dy;
             $c[] = $x + $dx;
             $c[] = $y - $dy;
             $c[] = $x + $dx;
             $c[] = $y + $dy;
             $c[] = $x - $dx;
             $c[] = $y + $dy;
             $c[] = $x - $dx;
             $c[] = $y - $dy;
             $pts = 5;
             break;
         case MARK_UTRIANGLE:
             ++$dx;
             ++$dy;
             $c[] = $x - $dx;
             $c[] = $y + 0.87 * $dy;
             // tan(60)/2*$dx
             $c[] = $x;
             $c[] = $y - 0.87 * $dy;
             $c[] = $x + $dx;
             $c[] = $y + 0.87 * $dy;
             $c[] = $x - $dx;
             $c[] = $y + 0.87 * $dy;
             // tan(60)/2*$dx
             $pts = 4;
             break;
         case MARK_DTRIANGLE:
             ++$dx;
             ++$dy;
             $c[] = $x;
             $c[] = $y + 0.87 * $dy;
             // tan(60)/2*$dx
             $c[] = $x - $dx;
             $c[] = $y - 0.87 * $dy;
             $c[] = $x + $dx;
             $c[] = $y - 0.87 * $dy;
             $c[] = $x;
             $c[] = $y + 0.87 * $dy;
             // tan(60)/2*$dx
             $pts = 4;
             break;
         case MARK_DIAMOND:
             $c[] = $x;
             $c[] = $y + $dy;
             $c[] = $x - $dx;
             $c[] = $y;
             $c[] = $x;
             $c[] = $y - $dy;
             $c[] = $x + $dx;
             $c[] = $y;
             $c[] = $x;
             $c[] = $y + $dy;
             $pts = 5;
             break;
         case MARK_LEFTTRIANGLE:
             $c[] = $x;
             $c[] = $y;
             $c[] = $x;
             $c[] = $y + 2 * $dy;
             $c[] = $x + $dx * 2;
             $c[] = $y;
             $c[] = $x;
             $c[] = $y;
             $pts = 4;
             break;
         case MARK_RIGHTTRIANGLE:
             $c[] = $x - $dx * 2;
             $c[] = $y;
             $c[] = $x;
             $c[] = $y + 2 * $dy;
             $c[] = $x;
             $c[] = $y;
             $c[] = $x - $dx * 2;
             $c[] = $y;
             $pts = 4;
             break;
         case MARK_FLASH:
             $dy *= 2;
             $c[] = $x + $dx / 2;
             $c[] = $y - $dy;
             $c[] = $x - $dx + $dx / 2;
             $c[] = $y + $dy * 0.7 - $dy;
             $c[] = $x + $dx / 2;
             $c[] = $y + $dy * 1.3 - $dy;
             $c[] = $x - $dx + $dx / 2;
             $c[] = $y + 2 * $dy - $dy;
             $img->SetLineWeight($weight);
             $img->SetColor($color);
             $img->Polygon($c);
             $img->SetLineWeight(1);
             $this->AddCSIMPoly($c);
             break;
     }
     if ($pts > 0) {
         $this->AddCSIMPoly($c);
         $img->SetLineWeight($weight);
         $img->SetColor($fcolor);
         $img->FilledPolygon($c);
         $img->SetColor($color);
         $img->Polygon($c);
         $img->SetLineWeight(1);
     } elseif ($this->type == MARK_CIRCLE) {
         $img->SetColor($color);
         $img->Circle($x, $y, $width);
         $this->AddCSIMCircle($x, $y, $width);
     } elseif ($this->type == MARK_FILLEDCIRCLE) {
         $img->SetColor($fcolor);
         $img->FilledCircle($x, $y, $width);
         $img->SetColor($color);
         $img->Circle($x, $y, $width);
         $this->AddCSIMCircle($x, $y, $width);
     } elseif ($this->type == MARK_CROSS) {
         // Oversize by a pixel to match the X
         $img->SetColor($color);
         $img->SetLineWeight($weight);
         $img->Line($x, $y + $dy + 1, $x, $y - $dy - 1);
         $img->Line($x - $dx - 1, $y, $x + $dx + 1, $y);
         $this->AddCSIMCircle($x, $y, $dx);
     } elseif ($this->type == MARK_X) {
         $img->SetColor($color);
         $img->SetLineWeight($weight);
         $img->Line($x + $dx, $y + $dy, $x - $dx, $y - $dy);
         $img->Line($x - $dx, $y + $dy, $x + $dx, $y - $dy);
         $this->AddCSIMCircle($x, $y, $dx + $dy);
     } elseif ($this->type == MARK_STAR) {
         $img->SetColor($color);
         $img->SetLineWeight($weight);
         $img->Line($x + $dx, $y + $dy, $x - $dx, $y - $dy);
         $img->Line($x - $dx, $y + $dy, $x + $dx, $y - $dy);
         // Oversize by a pixel to match the X
         $img->Line($x, $y + $dy + 1, $x, $y - $dy - 1);
         $img->Line($x - $dx - 1, $y, $x + $dx + 1, $y);
         $this->AddCSIMCircle($x, $y, $dx + $dy);
     }
     // Stroke title
     $this->title->Align("center", "center");
     $this->title->Stroke($img, $x, $y);
 }
Example #5
0
 function Stroke($img, $xscale, $yscale)
 {
     $numpoints = count($this->coords[0]);
     if (isset($this->coords[1])) {
         if (count($this->coords[1]) != $numpoints) {
             JpGraphError::Raise("Number of X and Y points are not equal. Number of X-points:" . count($this->coords[1]) . "Number of Y-points:{$numpoints}");
         } else {
             $exist_x = true;
         }
     } else {
         $exist_x = false;
     }
     $numbars = count($this->coords[0]);
     // Use GetMinVal() instead of scale[0] directly since in the case
     // of log scale we get a correct value. Log scales will have negative
     // values for values < 1 while still not representing negative numbers.
     if ($yscale->GetMinVal() >= 0) {
         $zp = $yscale->scale_abs[0];
     } else {
         $zp = $yscale->Translate(0);
     }
     if ($this->abswidth > -1) {
         $abswidth = $this->abswidth;
     } else {
         $abswidth = round($this->width * $xscale->scale_factor, 0);
     }
     // Count pontetial pattern array to avoid doing the count for each iteration
     if (is_array($this->iPattern)) {
         $np = count($this->iPattern);
     }
     $grad = null;
     for ($i = 0; $i < $numbars; ++$i) {
         // If value is NULL, or 0 then don't draw a bar at all
         if ($this->coords[0][$i] === null || $this->coords[0][$i] === '') {
             continue;
         }
         if ($exist_x) {
             $x = $this->coords[1][$i];
         } else {
             $x = $i;
         }
         $x = $xscale->Translate($x);
         // Comment Note: This confuses the positioning when using acc together with
         // grouped bars. Workaround for fixing #191
         /*
         	    if( !$xscale->textscale ) {
         	    	if($this->align=="center")
         		    $x -= $abswidth/2;
         		elseif($this->align=="right")
         		    $x -= $abswidth;			
         	    }
         */
         // Stroke fill color and fill gradient
         $pts = array($x, $zp, $x, $yscale->Translate($this->coords[0][$i]), $x + $abswidth, $yscale->Translate($this->coords[0][$i]), $x + $abswidth, $zp);
         if ($this->grad) {
             if ($grad === null) {
                 $grad = new Gradient($img);
             }
             if (is_array($this->grad_fromcolor)) {
                 // The first argument (grad_fromcolor) can be either an array or a single color. If it is an array
                 // then we have two choices. It can either a) be a single color specified as an RGB triple or it can be
                 // an array to specify both (from, to style) for each individual bar. The way to know the difference is
                 // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB
                 // triple.
                 $ng = count($this->grad_fromcolor);
                 if ($ng === 3) {
                     if (is_numeric($this->grad_fromcolor[0]) && $this->grad_fromcolor[0] > 0 && $this->grad_fromcolor[0] < 256) {
                         // RGB Triple
                         $fromcolor = $this->grad_fromcolor;
                         $tocolor = $this->grad_tocolor;
                         $style = $this->grad_style;
                     }
                 } else {
                     $fromcolor = $this->grad_fromcolor[$i % $ng][0];
                     $tocolor = $this->grad_fromcolor[$i % $ng][1];
                     $style = $this->grad_fromcolor[$i % $ng][2];
                 }
                 $grad->FilledRectangle($pts[2], $pts[3], $pts[6], $pts[7], $fromcolor, $tocolor, $style);
             } else {
                 $grad->FilledRectangle($pts[2], $pts[3], $pts[6], $pts[7], $this->grad_fromcolor, $this->grad_tocolor, $this->grad_style);
             }
         } elseif (!empty($this->fill_color)) {
             if (is_array($this->fill_color)) {
                 $img->PushColor($this->fill_color[$i % count($this->fill_color)]);
             } else {
                 $img->PushColor($this->fill_color);
             }
             $img->FilledPolygon($pts);
             $img->PopColor();
         }
         // Remember value of this bar
         $val = $this->coords[0][$i];
         if (!empty($val) && !is_numeric($val)) {
             JpGraphError::Raise('All values for a barplot must be numeric. You have specified value[' . $i . '] == \'' . $val . '\'');
         }
         // Determine the shadow
         if ($this->bar_shadow && $val != 0) {
             $ssh = $this->bar_shadow_hsize;
             $ssv = $this->bar_shadow_vsize;
             // Create points to create a "upper-right" shadow
             if ($val > 0) {
                 $sp[0] = $pts[6];
                 $sp[1] = $pts[7];
                 $sp[2] = $pts[4];
                 $sp[3] = $pts[5];
                 $sp[4] = $pts[2];
                 $sp[5] = $pts[3];
                 $sp[6] = $pts[2] + $ssh;
                 $sp[7] = $pts[3] - $ssv;
                 $sp[8] = $pts[4] + $ssh;
                 $sp[9] = $pts[5] - $ssv;
                 $sp[10] = $pts[6] + $ssh;
                 $sp[11] = $pts[7] - $ssv;
             } elseif ($val < 0) {
                 $sp[0] = $pts[4];
                 $sp[1] = $pts[5];
                 $sp[2] = $pts[6];
                 $sp[3] = $pts[7];
                 $sp[4] = $pts[0];
                 $sp[5] = $pts[1];
                 $sp[6] = $pts[0] + $ssh;
                 $sp[7] = $pts[1] - $ssv;
                 $sp[8] = $pts[6] + $ssh;
                 $sp[9] = $pts[7] - $ssv;
                 $sp[10] = $pts[4] + $ssh;
                 $sp[11] = $pts[5] - $ssv;
             }
             if (is_array($this->bar_shadow_color)) {
                 $numcolors = count($this->bar_shadow_color);
                 if ($numcolors == 0) {
                     JpGraphError::Raise('You have specified an empty array for shadow colors in the bar plot.');
                 }
                 $img->PushColor($this->bar_shadow_color[$i % $numcolors]);
             } else {
                 $img->PushColor($this->bar_shadow_color);
             }
             $img->FilledPolygon($sp);
             $img->PopColor();
         }
         // Stroke the pattern
         if (is_array($this->iPattern)) {
             $f = new RectPatternFactory();
             if (is_array($this->iPatternColor)) {
                 $pcolor = $this->iPatternColor[$i % $np];
             } else {
                 $pcolor = $this->iPatternColor;
             }
             $prect = $f->Create($this->iPattern[$i % $np], $pcolor, 1);
             $prect->SetDensity($this->iPatternDensity[$i % $np]);
             if ($val < 0) {
                 $rx = $pts[0];
                 $ry = $pts[1];
             } else {
                 $rx = $pts[2];
                 $ry = $pts[3];
             }
             $width = abs($pts[4] - $pts[0]) + 1;
             $height = abs($pts[1] - $pts[3]) + 1;
             $prect->SetPos(new Rectangle($rx, $ry, $width, $height));
             $prect->Stroke($img);
         } else {
             if ($this->iPattern > -1) {
                 $f = new RectPatternFactory();
                 $prect = $f->Create($this->iPattern, $this->iPatternColor, 1);
                 $prect->SetDensity($this->iPatternDensity);
                 if ($val < 0) {
                     $rx = $pts[0];
                     $ry = $pts[1];
                 } else {
                     $rx = $pts[2];
                     $ry = $pts[3];
                 }
                 $width = abs($pts[4] - $pts[0]) + 1;
                 $height = abs($pts[1] - $pts[3]) + 1;
                 $prect->SetPos(new Rectangle($rx, $ry, $width, $height));
                 $prect->Stroke($img);
             }
         }
         // Stroke the outline of the bar
         if (is_array($this->color)) {
             $img->SetColor($this->color[$i % count($this->color)]);
         } else {
             $img->SetColor($this->color);
         }
         $pts[] = $pts[0];
         $pts[] = $pts[1];
         if ($this->weight > 0) {
             $img->SetLineWeight($this->weight);
             $img->Polygon($pts);
         }
         // Determine how to best position the values of the individual bars
         $x = $pts[2] + ($pts[4] - $pts[2]) / 2;
         if ($this->valuepos == 'top') {
             $y = $pts[3];
             if ($img->a === 90) {
                 if ($val < 0) {
                     $this->value->SetAlign('right', 'center');
                 } else {
                     $this->value->SetAlign('left', 'center');
                 }
             }
             $this->value->Stroke($img, $val, $x, $y);
         } elseif ($this->valuepos == 'max') {
             $y = $pts[3];
             if ($img->a === 90) {
                 if ($val < 0) {
                     $this->value->SetAlign('left', 'center');
                 } else {
                     $this->value->SetAlign('right', 'center');
                 }
             } else {
                 $this->value->SetAlign('center', 'top');
             }
             $this->value->SetMargin(-3);
             $this->value->Stroke($img, $val, $x, $y);
         } elseif ($this->valuepos == 'center') {
             $y = ($pts[3] + $pts[1]) / 2;
             $this->value->SetAlign('center', 'center');
             $this->value->SetMargin(0);
             $this->value->Stroke($img, $val, $x, $y);
         } elseif ($this->valuepos == 'bottom' || $this->valuepos == 'min') {
             $y = $pts[1];
             if ($img->a === 90) {
                 if ($val < 0) {
                     $this->value->SetAlign('right', 'center');
                 } else {
                     $this->value->SetAlign('left', 'center');
                 }
             }
             $this->value->SetMargin(3);
             $this->value->Stroke($img, $val, $x, $y);
         } else {
             JpGraphError::Raise('Unknown position for values on bars :' . $this->valuepos);
         }
         // Create the client side image map
         $rpts = $img->ArrRotate($pts);
         $csimcoord = round($rpts[0]) . ", " . round($rpts[1]);
         for ($j = 1; $j < 4; ++$j) {
             $csimcoord .= ", " . round($rpts[2 * $j]) . ", " . round($rpts[2 * $j + 1]);
         }
         if (!empty($this->csimtargets[$i])) {
             $this->csimareas .= '<area shape="poly" coords="' . $csimcoord . '" ';
             $this->csimareas .= " href=\"" . atk_htmlentities($this->csimtargets[$i]) . "\"";
             if (!empty($this->csimwintargets[$i])) {
                 $this->csimareas .= " target=\"" . $this->csimwintargets[$i] . "\" ";
             }
             $sval = '';
             if (!empty($this->csimalts[$i])) {
                 $sval = sprintf($this->csimalts[$i], $this->coords[0][$i]);
                 $this->csimareas .= " title=\"{$sval}\" alt=\"{$sval}\" ";
             }
             $this->csimareas .= " />\n";
         }
     }
     return true;
 }