public function create() { $legend = $this->getArg('legend'); $y = $this->getArg('y'); if ($y === NULL) { awImage::drawError("Class LightLinePattern: Argument 'y' must not be NULL."); } $plot = new LinePlot($y); $plot->setSize(0.7, 1); $plot->setCenter(0.35, 0.5); $plot->setPadding(35, 15, 35, 30); $plot->setColor(new Orange()); $plot->setFillColor(new LightOrange(80)); $plot->grid->setType(Line::DASHED); $plot->mark->setType(Mark::CIRCLE); $plot->mark->setFill(new MidRed()); $plot->mark->setSize(6); $plot->legend->setPosition(1, 0.5); $plot->legend->setAlign(Legend::LEFT); $plot->legend->shadow->smooth(TRUE); if ($legend !== NULL) { $plot->legend->add($plot, $legend, Legend::MARK); } return $plot; }
/** * Load a pattern * * @param string $pattern Pattern name * @return Component */ public static function get($pattern) { $file = ARTICHOW_PATTERN . DIRECTORY_SEPARATOR . $pattern . '.php'; if (is_file($file)) { require_once $file; $class = $pattern . 'Pattern'; if (class_exists($class)) { return new $class(); } else { awImage::drawError("Class Pattern: Class '" . $class . "' does not exist."); } } else { awImage::drawError("Class Pattern: Pattern '" . $pattern . "' does not exist."); } }
function create() { $group = new PlotGroup(); $group->setSpace(2, 2, 2, 0); $group->setPadding(30, 10, NULL, NULL); $group->grid->hideVertical(TRUE); $group->grid->setType(LINE_DASHED); $yForeground = $this->getArg('yForeground'); $yBackground = $this->getArg('yBackground'); $legendForeground = $this->getArg('legendForeground'); $legendBackground = $this->getArg('legendBackground'); $colorForeground = $this->getArg('colorForeground', new LightBlue(10)); $colorBackground = $this->getArg('colorBackground', new Orange(25)); if ($yForeground === NULL) { awImage::drawError("Class BarDepthPattern: Argument 'yForeground' must not be NULL."); } // Background if ($yBackground !== NULL) { $plot = $this->getPlot($yBackground, 6); $plot->setBarColor($colorBackground); $group->add($plot); if ($legendBackground !== NULL) { $group->legend->add($plot, $legendBackground, LEGEND_BACKGROUND); } } // Foreground $plot = $this->getPlot($yForeground, 0); $plot->setBarColor($colorForeground); $group->add($plot); if ($legendForeground !== NULL) { $group->legend->add($plot, $legendForeground, LEGEND_BACKGROUND); } $group->axis->bottom->hideTicks(TRUE); $group->legend->shadow->setSize(0); $group->legend->setAlign(LEGEND_CENTER); $group->legend->setSpace(6); $group->legend->setTextFont(new Tuffy(8)); $group->legend->setPosition(0.5, 0.1); $group->legend->setBackgroundColor(new Color(255, 255, 255, 10)); $group->legend->setColumns(2); return $group; }
private function cache($data) { if (ARTICHOW_CACHE and $this->name !== NULL) { if (is_writable(ARTICHOW_CACHE_DIRECTORY) === FALSE) { awImage::drawError("Class Graph: Cache directory is not writable."); } file_put_contents($this->fileCache, $data); file_put_contents($this->fileCacheTime, $this->timeout . "\n" . $this->getFormatString()); } }
protected function ellipseLinearGradient(awGradient $gradient, $x1, $y1, $x2, $y2) { // Gauche->droite : 90° if ($y1 - $y2 > 0) { if ($y1 - $y2 != $x2 - $x1) { awImage::drawError("Class GDGradientDriver: Linear gradients are only implemented on circle, not ellipses."); } $r = ($x2 - $x1) / 2; // Init gradient $this->init($gradient, $x2 - $x1); for ($i = -$r; $i <= $r; $i++) { $h = sin(acos($i / $r)) * $r; $color = $this->color($i + $r); if ($gradient->angle === 90) { // Print the line $p1 = new awPoint($x1 + $i + $r, round(max($y2 + $r - $h + 1, $y2))); $p2 = new awPoint($x1 + $i + $r, round(min($y1 - $r + $h - 1, $y1))); } else { // Print the line $p1 = new awPoint(round(max($x1 + $r - $h + 1, $x1)), $y2 + $i + $r); $p2 = new awPoint(round(min($x2 - $r + $h - 1, $x2)), $y2 + $i + $r); } $this->driver->filledRectangle($color, new awLine($p1, $p2)); unset($color); } } }
function getTextHeight(&$text) { $font = $text->getFont(); if ($this->isCompatibleWithFont($font) === FALSE) { awImage::drawError('Class MingDriver: Incompatible font type (\'' . get_class($font) . '\')'); } // Ming only supports FileFont $fontDriver = $this->fileFontDriver; return $fontDriver->getTextHeight($text, $this); }
private function getGDAverageWidth(awFileFont $font) { $text = "azertyuiopqsdfghjklmmmmmmmwxcvbbbn,;:!?."; $box = imagettfbbox($font->size, 0, $font->font . '.' . $font->getExtension(), $text); if ($box === FALSE) { awImage::drawError("Class FileFontDriver: Unable to get font average width."); } list(, , $x2, $y2, , , $x1, $y1) = $box; return abs($x2 - $x1) / strlen($text); }
/** * Draw border as an ellipse * * @param $driver * @param $center Ellipse center * @param int $width Ellipse width * @param int $height Ellipse height */ function ellipse($driver, $center, $width, $height) { // Border is hidden if ($this->hide) { return; } switch ($this->style) { case LINE_SOLID: $driver->ellipse($this->color, $center, $width, $height); break; default: awImage::drawError("Class Border: Dashed and dotted borders and not yet implemented on ellipses."); break; } }
private function checkArray(&$array) { if (is_array($array) === FALSE) { awImage::drawError("Class Pie: You tried to set values that are not an array."); } foreach ($array as $key => $value) { if (is_numeric($value) === FALSE) { unset($array[$key]); } } if (count($array) < 1) { awImage::drawError("Class Pie: Your graph must have at least 1 value."); } }
private function checkArray(&$array) { if (is_array($array) === FALSE) { awImage::drawError("Class Plot: You tried to set a value that is not an array."); } foreach ($array as $key => $value) { if (is_numeric($value) === FALSE and is_null($value) === FALSE) { awImage::drawError("Class Plot: Expected numeric values for the plot."); } } if (count($array) < 1) { awImage::drawError("Class Plot: Your plot must have at least 1 value."); } }
/** * Add a filled area * * @param int $start Begining of the area * @param int $end End of the area * @param mixed $background Background color or gradient of the area */ public function setFilledArea($start, $stop, $background) { if ($stop <= $start) { awImage::drawError("Class LinePlot: End position can not be greater than begin position in setFilledArea()."); } $this->areas[] = array((int) $start, (int) $stop, $background); }
/** * Select the correct driver * * @param string $driver The desired driver * @return mixed */ function selectDriver($driver) { $drivers = array('gd'); $driver = strtolower((string) $driver); if (in_array($driver, $drivers, TRUE)) { $string = $driver; } else { $string = ARTICHOW_DRIVER; } switch ($string) { case 'gd': require_once ARTICHOW . '/inc/drivers/gd.class.php'; $this->driverString = $string; return new awGDDriver(); default: // We should never get here, unless the wrong string is used AND the ARTICHOW_DRIVER // global has been messed with. awImage::drawError('Class Image: Unknown driver type (\'' . $string . '\')'); break; } }
function errorHandlerArtichow($level, $message, $file, $line) { awImage::drawError($message . ' in ' . $file . ' on line ' . $line . '.'); }
/** * Center Y values of the axis * * @param awAxis $axis An axis * @param float $value The reference value on the axis */ public function setYCenter(awAxis $axis, $value) { // Check vector angle if ($this->line->isHorizontal() === FALSE) { awImage::drawError("Class Axis: setYCenter() can only be used on horizontal axes."); } $p = $axis->getPointFromValue($value); $this->line->setY($p->y, $p->y); }