Version 1.9g

This commit is contained in:
nemunaire 2008-11-08 12:00:00 +01:00
commit 4c9814a99c
800 changed files with 237325 additions and 1949 deletions

224
artichow/AntiSpam.class.php Normal file
View file

@ -0,0 +1,224 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Image.class.php";
/**
* AntiSpam
* String printed on the images are case insensitive.
*
* @package Artichow
*/
class awAntiSpam extends awImage {
/**
* Anti-spam string
*
* @var string
*/
protected $string;
/**
* Noise intensity
*
* @var int
*/
protected $noise = 0;
/**
* Construct a new awAntiSpam image
*
* @param string $string A string to display
*/
public function __construct($string = '') {
parent::__construct();
$this->string = (string)$string;
}
/**
* Create a random string
*
* @param int $length String length
* @return string String created
*/
public function setRand($length) {
$length = (int)$length;
$this->string = '';
$letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679';
$number = strlen($letters);
for($i = 0; $i < $length; $i++) {
$this->string .= $letters{mt_rand(0, $number - 1)};
}
return $this->string;
}
/**
* Set noise on image
*
* @param int $nois Noise intensity (from 0 to 10)
*/
public function setNoise($noise) {
if($noise < 0) {
$noise = 0;
}
if($noise > 10) {
$noise = 10;
}
$this->noise = (int)$noise;
}
/**
* Save string value in session
* You can use check() to verify the value later
*
* @param string $qName A name that identify the anti-spam image
*/
public function save($qName) {
$this->session();
$session = 'artichow_'.(string)$qName;
$_SESSION[$session] = $this->string;
}
/**
* Verify user entry
*
* @param string $qName A name that identify the anti-spam image
* @param string $value User-defined value
* @param bool $case TRUE for case insensitive check, FALSE for case sensitive check ? (default to TRUE)
* @return bool TRUE if the value is correct, FALSE otherwise
*/
public function check($qName, $value, $case = TRUE) {
$this->session();
$session = 'artichow_'.(string)$qName;
return (
array_key_exists($session, $_SESSION) === TRUE and
$case ?
(strtolower($_SESSION[$session]) === strtolower((string)$value)) :
($_SESSION[$session] === (string)$value)
);
}
/**
* Draw image
*/
public function draw() {
$fonts = array(
'Tuffy',
'TuffyBold',
'TuffyItalic',
'TuffyBoldItalic'
);
$sizes = array(12, 12.5, 13, 13.5, 14, 15, 16, 17, 18, 19);
$widths = array();
$heights = array();
$texts = array();
// Set up a temporary driver to allow font size calculations...
$this->setSize(10, 10);
$driver = $this->getDriver();
for($i = 0; $i < strlen($this->string); $i++) {
$fontKey = array_rand($fonts);
$sizeKey = array_rand($sizes);
$font = new awTTFFont(
$fonts[$fontKey], $sizes[$sizeKey]
);
$text = new awText(
$this->string{$i},
$font,
NULL,
mt_rand(-15, 15)
);
$widths[] = $driver->getTextWidth($text);
$heights[] = $driver->getTextHeight($text);
$texts[] = $text;
}
// ... and get rid of it.
$this->driver = NULL;
$width = array_sum($widths);
$height = array_max($heights);
$totalWidth = $width + 10 + count($texts) * 10;
$totalHeight = $height + 20;
$this->setSize($totalWidth, $totalHeight);
$this->create();
for($i = 0; $i < strlen($this->string); $i++) {
$this->driver->string(
$texts[$i],
new awPoint(
5 + array_sum(array_slice($widths, 0, $i)) + $widths[$i] / 2 + $i * 10,
10 + ($height - $heights[$i]) / 2
)
);
}
$this->drawNoise($totalWidth, $totalHeight);
$this->send();
}
protected function drawNoise($width, $height) {
$points = $this->noise * 30;
$color = new awColor(0, 0, 0);
for($i = 0; $i < $points; $i++) {
$this->driver->point(
$color,
new awPoint(
mt_rand(0, $width),
mt_rand(0, $height)
)
);
}
}
protected function session() {
// Start session if needed
if(!session_id()) {
session_start();
}
}
}
registerClass('AntiSpam');
?>

85
artichow/Artichow.cfg.php Normal file
View file

@ -0,0 +1,85 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
/*
* Path to Artichow
*/
define('ARTICHOW', dirname(__FILE__));
/*
* Path to TrueType fonts
* DO NOT USE FONT PATH WITH SPACE CHARACTER (" ") WITH GD <= 2.0.18
*/
if(!defined('ARTICHOW_FONT')) {
define('ARTICHOW_FONT', ARTICHOW.DIRECTORY_SEPARATOR.'font');
}
/*
* Patterns directory
*/
if(!defined('ARTICHOW_PATTERN')) {
define('ARTICHOW_PATTERN', ARTICHOW.DIRECTORY_SEPARATOR.'patterns');
}
/*
* Images directory
*/
if(!defined('ARTICHOW_IMAGE')) {
define('ARTICHOW_IMAGE', ARTICHOW.DIRECTORY_SEPARATOR.'images');
}
/*
* Enable/disable cache support
*/
define('ARTICHOW_CACHE', TRUE);
/*
* Cache directory
*/
if(!defined('ARTICHOW_CACHE_DIRECTORY')) {
define('ARTICHOW_CACHE_DIRECTORY', ARTICHOW.DIRECTORY_SEPARATOR.'cache');
}
/*
* Prefix for class names
* No prefix by default
*/
define('ARTICHOW_PREFIX', '');
/*
* Trigger errors when use of a deprecated feature
*/
define('ARTICHOW_DEPRECATED', TRUE);
/*
* Defines the default driver
*/
define('ARTICHOW_DRIVER', 'gd');
/*
* Fonts to use
*/
$fonts = array(
'Tuffy',
'TuffyBold',
'TuffyBoldItalic',
'TuffyItalic'
);
?>

364
artichow/BarPlot.class.php Normal file
View file

@ -0,0 +1,364 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Plot.class.php";
/**
* BarPlot
*
* @package Artichow
*/
class awBarPlot extends awPlot implements awLegendable {
/**
* Labels on your bar plot
*
* @var Label
*/
public $label;
/**
* Bar plot identifier
*
* @var int
*/
protected $identifier;
/**
* Bar plot number
*
* @var int
*/
protected $number;
/**
* Bar plot depth
*
* @var int
*/
protected $depth;
/**
* For moving bars
*
* @var int
*/
protected $move;
/**
* Bars shadow
*
* @var Shadow
*/
public $barShadow;
/**
* Bars border
*
* @var Border
*/
public $barBorder;
/**
* Bars padding
*
* @var Side
*/
protected $barPadding;
/**
* Bars space
*
* @var int
*/
protected $barSpace = 0;
/**
* Bars background
*
* @var Color, Gradient
*/
protected $barBackground;
/**
* Construct a new awBarPlot
*
* @param array $values Some numeric values for Y axis
* @param int $identifier Plot identifier
* @param int $number Bar plot number
* @param int $depth Bar plot depth in pixels
*/
public function __construct($values, $identifier = 1, $number = 1, $depth = 0) {
parent::__construct();
$this->label = new awLabel;
$this->barPadding = new awSide(0.08, 0.08, 0, 0);
$this->barShadow = new awShadow(awShadow::RIGHT_TOP);
$this->barBorder = new awBorder;
$this->setValues($values);
$this->identifier = (int)$identifier;
$this->number = (int)$number;
$this->depth = (int)$depth;
$this->move = new awSide;
// Hide vertical grid
$this->grid->hideVertical(TRUE);
}
/**
* Change bars padding
* This method is not compatible with awBarPlot::setBarPadding()
*
* @param float $left Left padding (between 0 and 1)
* @param float $right Right padding (between 0 and 1)
*/
public function setBarPadding($left = NULL, $right = NULL) {
$this->barPadding->set($left, $right);
}
/**
* Change bars size
* This method is not compatible with awBarPlot::setBarPadding()
*
* @param int $width Bars size (between 0 and 1)
*/
public function setBarSize($size) {
$padding = (1 - $size) / 2;
$this->barPadding->set($padding, $padding);
}
/**
* Move bars
*
* @param int $x
* @param int $y
*/
public function move($x, $y) {
$this->move->set($x, NULL, $y, NULL);
}
/**
* Change bars space
*
* @param int $space Space in pixels
*/
public function setBarSpace($space) {
$this->barSpace = (int)$space;
}
/**
* Change line background color
*
* @param awColor $color
*/
public function setBarColor(awColor $color) {
$this->barBackground = $color;
}
/**
* Change line background gradient
*
* @param awGradient $gradient
*/
public function setBarGradient(awGradient $gradient) {
$this->barBackground = $gradient;
}
/**
* Get the line thickness
*
* @return int
*/
public function getLegendLineThickness() {
}
/**
* Get the line type
*
* @return int
*/
public function getLegendLineStyle() {
}
/**
* Get the color of line
*
* @return Color
*/
public function getLegendLineColor() {
}
/**
* Get the background color or gradient of an element of the component
*
* @return Color, Gradient
*/
public function getLegendBackground() {
return $this->barBackground;
}
/**
* Get a mark object
*
* @return Mark
*/
public function getLegendMark() {
}
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
$count = count($this->datay);
$max = $this->getRealYMax(NULL);
$min = $this->getRealYMin(NULL);
// Find zero for bars
if($this->xAxisZero and $min <= 0 and $max >= 0) {
$zero = 0;
} else if($max < 0) {
$zero = $max;
} else {
$zero = $min;
}
// Get base position
$zero = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint(0, $zero));
// Distance between two values on the graph
$distance = $this->xAxis->getDistance(0, 1);
// Compute paddings
$leftPadding = $this->barPadding->left * $distance;
$rightPadding = $this->barPadding->right * $distance;
$padding = $leftPadding + $rightPadding;
$space = $this->barSpace * ($this->number - 1);
$barSize = ($distance - $padding - $space) / $this->number;
$barPosition = $leftPadding + $barSize * ($this->identifier - 1);
for($key = 0; $key < $count; $key++) {
$value = $this->datay[$key];
if($value !== NULL) {
$position = awAxis::toPosition(
$this->xAxis,
$this->yAxis,
new awPoint($key, $value)
);
$barStart = $barPosition + ($this->identifier - 1) * $this->barSpace + $position->x;
$barStop = $barStart + $barSize;
$t1 = min($zero->y, $position->y);
$t2 = max($zero->y, $position->y);
if(round($t2 - $t1) == 0) {
continue;
}
$p1 = new awPoint(
round($barStart) + $this->depth + $this->move->left,
round($t1) - $this->depth + $this->move->top
);
$p2 = new awPoint(
round($barStop) + $this->depth + $this->move->left,
round($t2) - $this->depth + $this->move->top
);
$this->drawBar($driver, $p1, $p2);
}
}
// Draw labels
foreach($this->datay as $key => $value) {
if($value !== NULL) {
$position = awAxis::toPosition(
$this->xAxis,
$this->yAxis,
new awPoint($key, $value)
);
$point = new awPoint(
$barPosition + ($this->identifier - 1) * $this->barSpace + $position->x + $barSize / 2 + 1 + $this->depth,
$position->y - $this->depth
);
$this->label->draw($driver, $point, $key);
}
}
}
public function getXAxisNumber() {
return count($this->datay) + 1;
}
// ça bidouille à fond ici !
public function getXMax() {
return array_max($this->datax) + 1;
}
public function getXCenter() {
return TRUE;
}
protected function drawBar(awDriver $driver, awPoint $p1, awPoint $p2) {
// Draw shadow
$this->barShadow->draw(
$driver,
$p1,
$p2,
awShadow::OUT
);
if(abs($p2->y - $p1->y) > 1) {
$this->barBorder->rectangle(
$driver,
$p1,
$p2
);
if($this->barBackground !== NULL) {
$size = $this->barBorder->visible() ? 1 : 0;
$b1 = $p1->move($size, $size);
$b2 = $p2->move(-1 * $size, -1 * $size);
// Draw background
$driver->filledRectangle(
$this->barBackground,
new awLine($b1, $b2)
);
}
}
}
}
registerClass('BarPlot');
?>

170
artichow/ChangeLog Normal file
View file

@ -0,0 +1,170 @@
Artichow 1.1
- All new driver-based architecture: Artichow now draws the graphs using drivers, located in 'inc/drivers/'. The move will ease development of new drawing formats (SVG, Flash, etc.) while keeping backward compatibility very high: you shouldn't have to change anything to your existing code and only two methods from the Font class have disappeared (see below) (Laurent)
- Added Image::setDriver() to allow driver selection (Laurent)
- Changed the Drawer class name to Driver. The class is now abstract, the implementation has to be made in the driver file itself. (Laurent)
- Added the GDDriver class to draw with GD: the file is 'inc/drivers/gd.class.php' (Laurent)
- Modified GDDriver::rectangle() so that it doesn't tamper with the Line object passed as an argument any more (Laurent)
- Fixed a bug where calling GDDriver::polygon() wouldn't close the polygon being drawn when using a non-solid border (Laurent)
- Added the constant ARTICHOW_DRIVER to define the default driver to use when none is selected (defaults to 'gd') (Laurent)
- Changed and reorganised the Font related classes: added FileFont and PHPFont, reworked inheritance (Laurent)
- Deleted Font::getTextWidth() and Font::getTextHeight(), replaced by Driver::getTextWidth() and Driver::getTextHeight() (Laurent)
- Added two new helping classes for Font manipulation, PHPFontDriver and FileFontDriver (Laurent)
- Fixed a bug that prevented values passed to Grid::setGrid() to have any effect (Laurent)
- Added four new types of Mark (Mark::INVERTED_TRIANGLE, Mark::RHOMBUS, Mark::CROSS, Mark::PLUS) (Geoffrey)
- Updated Image::drawError() so that it doesn't display HTML tags any more (Laurent)
- Modified Lable::setCallbackFunction() so that it now accepts static method callbacks (i.e. setCallbackFunction(array($this, 'methodName'))) (Vincent)
- Code cleanup and tweaking
Artichow 1.0.9
- Fixed a bug in Font class (second argument of wordwrap() can not be empty) (Vincent)
- Fixed a bug in Drawer class (text size was not handled correctly) (Vincent)
- Added support for using font paths containing space character when using GD <= 2.0.18 (bug#12) (Vincent)
- Fixed a bug where the HTTP headers were sent even though the draw() method was called with Graph::DRAW_RETURN or a filename (Laurent)
- Added support for antialiased pies on non-white background (only work with plain colors) (thanks to Eldwin) (Laurent)
- Anti-aliasing is now handled by the Drawer class (Laurent)
- Added method Drawer::setAntiAliasing() to turn anti-aliasing on or off (Laurent)
- Fixed a bug where a LinePlot with multiple lines of different thickness wouldn't have its anti-aliasing setting correctly handled (Laurent)
- Fixed a bug where the X axis wouldn't be labelled properly (bug#16) (Laurent)
- Added a new type of Mark (Mark::TRIANGLE) (Laurent)
- Fixed a bug where calling Axis::setYMax() wouldn't have any effect when drawing the axis (Vincent)
- Fixed a bug where a dashed line wouldn't been drawn properly in certain circumstances (Laurent)
- Fixed a bug where using Label::setFormat() or Label::setCallbackFunction() would be overriden by Axis::setLabelPrecision() (Laurent)
- Fixed a "division by zero" error when using a gradient fill on a LinePlot with zeroed values (bug#19) (Laurent)
- General code cleanup
Artichow 1.0.8
- Enhanced error support
- Added multi-line text support
- Updated and improved documentation
- Changed Graph::draw() method to accept more options
- Deleted first parameter of Image::send() method
- Added a third parameter to Image::send() method to disable auto-sending of Content-Type header
- Added a second parameter to Image::send() method to return an image instead of outputing it
- Fixed a fatal error on direct access to files Image.class.php and inc/*
- Fixed a bug in configuration file (bad constant definition check for ARTICHOW_CACHE_DIRECTORY)
Artichow 1.0.7
- Added constant ARTICHOW_CACHE_DIRECTORY to choose cache directory
- Fixed a division by zero bug in Axis class
- Improved cache handling
- Fixed a bug with ob_* handlers
- Fixed a bug for lines thickness
- Shadow color now works fine
Artichow 1.0.6
- Added method Plot::setYAxisZero()
- Added auto-scaling for plots
- Added constant ARTICHOW_CACHE to enable/disable the cache
- Improved prefix for classes
Artichow 1.0.5
- Added constant ARTICHOW_PREFIX to prefix Artichow's classes (bug #000002)
- Added methods Shadow::hide() and Shadow::show()
- Added method Plot::reduce()
- It is now possible to save its charts in a file
- Fixed a bug in PlotGroup (setYMin() / setYMax() did not work)
- Fixed an incoherent behaviour if some values in $datay are not numeric (LinePlot, BarPlot, ScatterPlot)
- Fixed an inclusion bug in Pattern
- Fixed a bug for PHP 5.1.0
Artichow 1.0.4
- Added support for GIF images
- Added patterns (Pattern.class.php)
- Added titles on axis
- Renamed Artichow.class.php to Graph.class.php (break backward compatibility)
- Added a README file
- Added support for ScatterPlot
- Merged setBackgroundColor() and setBackgroundGradient() into setFill() in class Mark (break backward compatibility)
- Added an optional argument $size to Mark::setType()
- Grid background in now default to white in class Plot
- Changed class Polygon to accept NULL values
- Added a new legend type (Legend::MARKONLY)
- Added method Legend::show()
- Added methods Mark::move(), Mark::hide() and Mark::show()
- Added new marks (star, book, ...)
- Added methods Label::setBackground() and Legend::setBackground()
- Added methods Plot::setXMax(), Plot::setXMin(), PlotGroup::setXMax() and PlotGroup::setXMin()
- Added new colors to default theme in Pie
- Removed methods Drawer::setBackground*()
- Tests have been removed from the archive
- Moved methods Component::addLabel() and Component::addAbsLabel() to class Graph
- Modes LinePlot::MIDDLE and LinePlot::BAR have been merged into LinePlot::MIDDLE (break backward compatibility)
- Fixed a bug in Artichow.cfg.php (unable to use some ttf fonts)
- Fixed a bug in Legend (position of marks was sometimes broken)
- Fixed a bug in Pie (pies can now take only a single value)
- Fixed some bugs in Plot / LinePlot
- Fixed a bug in Font::draw() (call to undefined function trigger__error)
Artichow 1.0.3 (beta)
- Added EXPERIMENTAL support for PHP 4
- Changed class BarPlot so it now uses class Border instead of setBorderThickness() and setBorderColor()
- Changed class Legend so it now uses class Border instead of setBorderSize() and setBorderColor()
- Changed class Mark so it now uses class Border instead of setBorderSize() and setBorderColor()
- Changed class Text so it now uses class Border instead of setBorderColor()
- Changed class Label so it now uses class Border instead of setBorderColor()
- Drawer::drawRectangle() and Drawer::drawFilledRectangle() now take a line as second argument
- Added styles to rectangles and polygons
- BarPlot::setBarPadding() takes now values in per-cent instead of pixels
- Merged drawFilledRectangleColor() and drawFilledRectangleGradient() into drawFilledRectangle() in class Drawer
- Merged drawFilledPolygonColor() and drawFilledPolygonGradient() into drawFilledPolygon() in class Drawer
- Merged drawFilledEllipseColor() and drawFilledEllipseGradient() into drawFilledEllipse() in class Drawer
- Added method BarPlot::setBarWidth()
- Added an optional border to the class Image
- Added a new class Border
- Added support for MathPlot
- LinePlot::STEP has been removed
- Merged classes Paragraph and Label (no changes in the API)
- Method Plot::setLabelCenter() is obsolete and has been removed
- Rewrited Axis (add a new class Tick) (break backward compatibility)
- Removed draw*Triangle* from class Drawer (use polygons instead)
- Removed prefix draw in each method of class Drawer
- Renamed LinePlot::setLineType() into LinePlot::setStyle()
- Renamed LinePlot::setLineThickness() into LinePlot::setThickness()
- Renamed LinePlot::setLineColor() into LinePlot::setColor()
- Renamed LinePlot::setLineBackgroundColor() to LinePlot::setFillColor()
- Renamed LinePlot::setLineBackgroundGradient() to LinePlot::setFillGradient()
- Renamed Line::setType() to Line::setStyle()
- Added methods Label::get(), Label::setFormat() and change method Label::setFont()
- Added a parameter $smooth in Shadow::setSize();
- Added filled areas in LinePlot
- Added lots of new features in Math.class.php
- Fixed a bug in Math::isVertical() and Math::isHorizontal()
- Fixed a bug in Legend (shadow is now well-positioned is there is no border on the legend)
- Lots of minor changes
Artichow 1.0.2 (beta)
- Added support for pies (2D & 3D)
- Moved shadow from class Component to class Image
- X Axis are now centered on 0 by default on bar and line plots
- Added title to Graphs
- Added 4 named fonts
- Added 50 named colors
- Added shadow to legends
- Added method Image::setBackgroundGradient()
- Added methods Label::setCallbackFunction() and Label::hide()
- Added method Legend::hide()
- Added methods Drawer::copyResizeImage(), Drawer::drawArc() and Drawer::drawFilledArcColor()
- Renamed Positionable::setHorizontalAlign() and Positionable::setVerticalAlign() to Positionable::setAlign()
- API for ellipses has changed
- Title is now a property instead of a method in Component
- Removed old code, that fixes a bug in the grid
- Fixed a bug that affects position of bars in some cases
- Fixed wrong size of shadow
- Fixed a bug in Plot::setYMin() and Plot::setYMax()
Artichow 1.0.1 (alpha)
- Added anti-spam images
Artichow 1.0.0 (alpha)
- Initial release

View file

@ -0,0 +1,415 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Graph.class.php";
/**
* A graph can contain some groups of components
*
* @package Artichow
*/
abstract class awComponentGroup extends awComponent {
/**
* Components of this group
*
* @var array
*/
protected $components;
/**
* Build the component group
*/
public function __construct() {
parent::__construct();
$this->components = array();
}
/**
* Add a component to the group
*
* @param awComponent $component A component
*/
public function add(awComponent $component) {
$this->components[] = $component;
}
}
registerClass('ComponentGroup', TRUE);
abstract class awComponent {
/**
* Component driver
*
* @var Driver
*/
protected $driver;
/**
* Component width
*
* @var float
*/
public $width = 1.0;
/**
* Component height
*
* @var float
*/
public $height = 1.0;
/**
* Position X of the center the graph (from 0 to 1)
*
* @var float
*/
public $x = 0.5;
/**
* Position Y of the center the graph (from 0 to 1)
*
* @var float
*/
public $y = 0.5;
/**
* Component absolute width (in pixels)
*
*
* @var int
*/
public $w;
/**
* Component absolute height (in pixels)
*
*
* @var int
*/
public $h;
/**
* Left-top corner Y position
*
* @var float
*/
public $top;
/**
* Left-top corner X position
*
* @var float
*/
public $left;
/**
* Component background color
*
* @var Color
*/
protected $background;
/**
* Component padding
*
* @var Side
*/
protected $padding;
/**
* Component space
*
* @var Side
*/
protected $space;
/**
* Component title
*
* @var Label
*/
public $title;
/**
* Adjust automatically the component ?
*
* @var bool
*/
protected $auto = TRUE;
/**
* Legend
*
* @var Legend
*/
public $legend;
/**
* Build the component
*/
public function __construct() {
// Component legend
$this->legend = new awLegend();
$this->padding = new awSide(25, 25, 25, 25);
$this->space = new awSide(0, 0, 0, 0);
// Component title
$this->title = new awLabel(
NULL,
new awTuffy(10),
NULL,
0
);
$this->title->setAlign(awLabel::CENTER, awLabel::TOP);
}
/**
* Adjust automatically the component ?
*
* @param bool $auto
*/
public function auto($auto) {
$this->auto = (bool)$auto;
}
/**
* Change the size of the component
*
* @param int $width Component width (from 0 to 1)
* @param int $height Component height (from 0 to 1)
*/
public function setSize($width, $height) {
$this->width = (float)$width;
$this->height = (float)$height;
}
/**
* Change the absolute size of the component
*
* @param int $w Component width (in pixels)
* @param int $h Component height (in pixels)
*/
public function setAbsSize($w, $h) {
$this->w = (int)$w;
$this->h = (int)$h;
}
/**
* Change component background color
*
* @param awColor $color (can be null)
*/
public function setBackgroundColor($color) {
if($color === NULL or $color instanceof awColor) {
$this->background = $color;
}
}
/**
* Change component background gradient
*
* @param awGradient $gradient (can be null)
*/
public function setBackgroundGradient($gradient) {
if($gradient === NULL or $gradient instanceof awGradient) {
$this->background = $gradient;
}
}
/**
* Change component background image
*
* @param awImage $image (can be null)
*/
public function setBackgroundImage($image) {
if($image === NULL or $image instanceof awImage) {
$this->background = $image;
}
}
/**
* Return the component background
*
* @return Color, Gradient
*/
public function getBackground() {
return $this->background;
}
/**
* Change component padding
*
* @param int $left Padding in pixels (NULL to keep old value)
* @param int $right Padding in pixels (NULL to keep old value)
* @param int $top Padding in pixels (NULL to keep old value)
* @param int $bottom Padding in pixels (NULL to keep old value)
*/
public function setPadding($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) {
$this->padding->set($left, $right, $top, $bottom);
}
/**
* Change component space
*
* @param float $left Space in % (NULL to keep old value)
* @param float $right Space in % (NULL to keep old value)
* @param float $bottom Space in % (NULL to keep old value)
* @param float $top Space in % (NULL to keep old value)
*/
public function setSpace($left = NULL, $right = NULL, $bottom = NULL, $top = NULL) {
$this->space->set($left, $right, $bottom, $top);
}
/**
* Change the absolute position of the component on the graph
*
* @var int $x Left-top corner X position
* @var int $y Left-top corner Y position
*/
public function setAbsPosition($left, $top) {
$this->left = (int)$left;
$this->top = (int)$top;
}
/**
* Set the center of the component
*
* @param int $x Position X of the center of the component
* @param int $y Position Y of the center of the component
*/
public function setCenter($x, $y) {
$this->x = (float)$x;
$this->y = (float)$y;
}
/**
* Get component coords with its padding
*
* @return array Coords of the component
*/
public function getPosition() {
// Get component coords
$x1 = $this->padding->left;
$y1 = $this->padding->top;
$x2 = $this->w - $this->padding->right;
$y2 = $this->h - $this->padding->bottom;
return array($x1, $y1, $x2, $y2);
}
/**
* Init the drawing of the component
*/
public function init(awDriver $driver) {
// Set component background
$background = $this->getBackground();
if($background !== NULL) {
$p1 = new awPoint(0, 0);
$p2 = new awPoint($this->w - 1, $this->h - 1);
if($background instanceof awImage) {
$driver->copyImage(
$background,
$p1,
$p2
);
} else {
$driver->filledRectangle(
$background,
new awLine($p1, $p2)
);
}
}
}
/**
* Finalize the drawing of the component
*/
public function finalize(awDriver $driver) {
// Draw component title
$point = new awPoint(
$this->w / 2,
$this->padding->top - 8
);
$this->title->draw($driver, $point);
// Draw legend
$this->legend->draw($driver);
}
/**
* Draw the grid around your component
*
* @param Driver A driver
* @return array Coords for the component
*/
abstract public function drawEnvelope(awDriver $driver);
/**
* Draw the component on the graph
* Component should be drawed into specified coords
*
* @param Driver A driver
* @param int $x1
* @param int $y1
* @param int $x2
* @param int $y2
* @param bool $aliasing Use anti-aliasing to draw the component ?
*/
abstract public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing);
/**
* Get space width in pixels
*
* @param int $width Component width
* @param int $height Component height
* @return array
*/
protected function getSpace($width, $height) {
$left = (int)($width * $this->space->left / 100);
$right = (int)($width * $this->space->right / 100);
$top = (int)($height * $this->space->top / 100);
$bottom = (int)($height * $this->space->bottom / 100);
return array($left, $right, $top, $bottom);
}
}
registerClass('Component', TRUE);
?>

3
artichow/DEPRECATED Normal file
View file

@ -0,0 +1,3 @@
Artichow 1.0.9
- Pie::setBorder(): replaced by Pie::setBorderColor()

412
artichow/Graph.class.php Normal file
View file

@ -0,0 +1,412 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Image.class.php";
/**
* A graph
*
* @package Artichow
*/
class awGraph extends awImage {
/**
* Graph name
*
* @var string
*/
protected $name;
/**
* Cache timeout
*
* @var int
*/
protected $timeout = 0;
/**
* Graph timing ?
*
* @var bool
*/
protected $timing;
/**
* Components
*
* @var array
*/
private $components = array();
/**
* Some labels to add to the component
*
* @var array
*/
protected $labels = array();
/**
* Graph title
*
* @var Label
*/
public $title;
/**
* File cache location
*
* @var string
*/
private $fileCache;
/**
* Time file cache location
*
* @var string
*/
private $fileCacheTime;
/**
* Drawing mode to return the graph
*
* @var int
*/
const DRAW_RETURN = 1;
/**
* Drawing mode to display the graph
*
* @var int
*/
const DRAW_DISPLAY = 2;
/**
* Construct a new graph
*
* @param int $width Graph width
* @param int $height Graph height
* @param string $name Graph name for the cache (must be unique). Let it null to not use the cache.
* @param int $timeout Cache timeout (unix timestamp)
*/
public function __construct($width = NULL, $height = NULL, $name = NULL, $timeout = 0) {
parent::__construct();
$this->setSize($width, $height);
if(ARTICHOW_CACHE) {
$this->name = $name;
$this->timeout = $timeout;
// Clean sometimes all the cache
if(mt_rand(0, 5000) === 0) {
awGraph::cleanCache();
}
// Take the graph from the cache if possible
if($this->name !== NULL) {
$this->fileCache = ARTICHOW_CACHE_DIRECTORY."/".$this->name;
$this->fileCacheTime = $this->fileCache."-time";
if(is_file($this->fileCache)) {
$type = awGraph::cleanGraphCache($this->fileCacheTime);
if($type === NULL) {
awGraph::deleteFromCache($this->name);
} else {
header("Content-Type: image/".$type);
echo file_get_contents($this->fileCache);
exit;
}
}
}
}
$this->title = new awLabel(
NULL,
new awTuffy(16),
NULL,
0
);
$this->title->setAlign(awLabel::CENTER, awLabel::BOTTOM);
}
/**
* Delete a graph from the cache
*
* @param string $name Graph name
* @return bool TRUE on success, FALSE on failure
*/
public static function deleteFromCache($name) {
if(ARTICHOW_CACHE) {
if(is_file(ARTICHOW_CACHE_DIRECTORY."/".$name."-time")) {
unlink(ARTICHOW_CACHE_DIRECTORY."/".$name."");
unlink(ARTICHOW_CACHE_DIRECTORY."/".$name."-time");
}
}
}
/**
* Delete all graphs from the cache
*/
public static function deleteAllCache() {
if(ARTICHOW_CACHE) {
$dp = opendir(ARTICHOW_CACHE_DIRECTORY);
while($file = readdir($dp)) {
if($file !== '.' and $file != '..') {
unlink(ARTICHOW_CACHE_DIRECTORY."/".$file);
}
}
}
}
/**
* Clean cache
*/
public static function cleanCache() {
if(ARTICHOW_CACHE) {
$glob = glob(ARTICHOW_CACHE_DIRECTORY."/*-time");
foreach($glob as $file) {
$type = awGraph::cleanGraphCache($file);
if($type === NULL) {
$name = ereg_replace(".*/(.*)\-time", "\\1", $file);
awGraph::deleteFromCache($name);
}
}
}
}
/**
* Enable/Disable Graph timing
*
* @param bool $timing
*/
public function setTiming($timing) {
$this->timing = (bool)$timing;
}
/**
* Add a component to the graph
*
* @param awComponent $component
*/
public function add(awComponent $component) {
$this->components[] = $component;
}
/**
* Add a label to the component
*
* @param awLabel $label
* @param int $x Position on X axis of the center of the text
* @param int $y Position on Y axis of the center of the text
*/
public function addLabel(awLabel $label, $x, $y) {
$this->labels[] = array(
$label, $x, $y
);
}
/**
* Add a label to the component with absolute position
*
* @param awLabel $label
* @param awPoint $point Text position
*/
public function addAbsLabel(awLabel $label, awPoint $point) {
$this->labels[] = array(
$label, $point
);
}
/**
* Build the graph and draw component on it
*
* @param string $mode Display mode (can be a file name)
*/
public function draw($mode = Graph::DRAW_DISPLAY) {
if($this->timing) {
$time = microtimeFloat();
}
$this->create();
foreach($this->components as $component) {
$this->drawComponent($component);
}
$this->drawTitle();
$this->drawShadow();
$this->drawLabels();
if($this->timing) {
$this->drawTiming(microtimeFloat() - $time);
}
// Create graph
$data = $this->get();
// Put the graph in the cache if needed
$this->cache($data);
switch($mode) {
case Graph::DRAW_DISPLAY :
$this->sendHeaders();
echo $data;
break;
case Graph::DRAW_RETURN :
return $data;
default :
if(is_string($mode)) {
file_put_contents($mode, $data);
} else {
awImage::drawError("Class Graph: Unable to draw the graph.");
}
}
}
private function drawLabels() {
$driver = $this->getDriver();
foreach($this->labels as $array) {
if(count($array) === 3) {
// Text in relative position
list($label, $x, $y) = $array;
$point = new awPoint(
$x * $this->width,
$y * $this->height
);
} else {
// Text in absolute position
list($label, $point) = $array;
}
$label->draw($driver, $point);
}
}
private function drawTitle() {
$driver = $this->getDriver();
$point = new awPoint(
$this->width / 2,
10
);
$this->title->draw($driver, $point);
}
private function drawTiming($time) {
$driver = $this->getDriver();
$label = new awLabel;
$label->set("(".sprintf("%.3f", $time)." s)");
$label->setAlign(awLabel::LEFT, awLabel::TOP);
$label->border->show();
$label->setPadding(1, 0, 0, 0);
$label->setBackgroundColor(new awColor(230, 230, 230, 25));
$label->draw($driver, new awPoint(5, $driver->imageHeight - 5));
}
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());
}
}
private static function cleanGraphCache($file) {
list(
$time,
$type
) = explode("\n", file_get_contents($file));
$time = (int)$time;
if($time !== 0 and $time < time()) {
return NULL;
} else {
return $type;
}
}
}
registerClass('Graph');
/*
* To preserve PHP 4 compatibility
*/
function microtimeFloat() {
list($usec, $sec) = explode(" ", microtime());
return (float)$usec + (float)$sec;
}
?>

606
artichow/Image.class.php Normal file
View file

@ -0,0 +1,606 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
if(is_file(dirname(__FILE__)."/Artichow.cfg.php")) { // For PHP 4+5 version
require_once dirname(__FILE__)."/Artichow.cfg.php";
}
/*
* Register a class with the prefix in configuration file
*/
function registerClass($class, $abstract = FALSE) {
if(ARTICHOW_PREFIX === 'aw') {
return;
}
if($abstract) {
$abstract = 'abstract';
} else {
$abstract = '';
}
eval($abstract." class ".ARTICHOW_PREFIX.$class." extends aw".$class." { }");
}
/*
* Register an interface with the prefix in configuration file
*/
function registerInterface($interface) {
if(ARTICHOW_PREFIX === 'aw') {
return;
}
eval("interface ".ARTICHOW_PREFIX.$interface." extends aw".$interface." { }");
}
// Some useful files
require_once ARTICHOW."/Component.class.php";
require_once ARTICHOW."/inc/Grid.class.php";
require_once ARTICHOW."/inc/Tools.class.php";
require_once ARTICHOW."/inc/Driver.class.php";
require_once ARTICHOW."/inc/Math.class.php";
require_once ARTICHOW."/inc/Tick.class.php";
require_once ARTICHOW."/inc/Axis.class.php";
require_once ARTICHOW."/inc/Legend.class.php";
require_once ARTICHOW."/inc/Mark.class.php";
require_once ARTICHOW."/inc/Label.class.php";
require_once ARTICHOW."/inc/Text.class.php";
require_once ARTICHOW."/inc/Color.class.php";
require_once ARTICHOW."/inc/Font.class.php";
require_once ARTICHOW."/inc/Gradient.class.php";
require_once ARTICHOW."/inc/Shadow.class.php";
require_once ARTICHOW."/inc/Border.class.php";
require_once ARTICHOW."/common.php";
/**
* An image for a graph
*
* @package Artichow
*/
class awImage {
/**
* Graph width
*
* @var int
*/
public $width;
/**
* Graph height
*
* @var int
*/
public $height;
/**
* Use anti-aliasing ?
*
* @var bool
*/
protected $antiAliasing = FALSE;
/**
* Image format
*
* @var int
*/
protected $format = awImage::PNG;
/**
* Image background color
*
* @var Color
*/
protected $background;
/**
* GD resource
*
* @var resource
*/
protected $resource;
/**
* A Driver object
*
* @var Driver
*/
protected $driver;
/**
* Driver string
*
* @var string
*/
protected $driverString;
/**
* Shadow
*
* @var Shadow
*/
public $shadow;
/**
* Image border
*
* @var Border
*/
public $border;
/**
* Use JPEG for image
*
* @var int
*/
const JPEG = IMG_JPG;
/**
* Use PNG for image
*
* @var int
*/
const PNG = IMG_PNG;
/**
* Use GIF for image
*
* @var int
*/
const GIF = IMG_GIF;
/**
* Build the image
*/
public function __construct() {
$this->background = new awColor(255, 255, 255);
$this->shadow = new awShadow(awShadow::RIGHT_BOTTOM);
$this->border = new awBorder;
}
/**
* Get driver of the image
*
* @param int $w Driver width (from 0 to 1) (default to 1)
* @param int $h Driver height (from 0 to 1) (default to 1)
* @param float $x Position on X axis of the center of the driver (default to 0.5)
* @param float $y Position on Y axis of the center of the driver (default to 0.5)
* @return Driver
*/
public function getDriver($w = 1, $h = 1, $x = 0.5, $y = 0.5) {
$this->create();
$this->driver->setSize($w, $h);
$this->driver->setPosition($x, $y);
return $this->driver;
}
/**
* Sets the driver that will be used to draw the graph
*
* @param string $driverString
*/
public function setDriver($driverString) {
$this->driver = $this->selectDriver($driverString);
$this->driver->init($this);
}
/**
* Change the image size
*
* @var int $width Image width
* @var int $height Image height
*/
public function setSize($width, $height) {
if($width !== NULL) {
$this->width = (int)$width;
}
if($height !== NULL) {
$this->height = (int)$height;
}
}
/**
* Change image background
*
* @param mixed $background
*/
public function setBackground($background) {
if($background instanceof awColor) {
$this->setBackgroundColor($background);
} elseif($background instanceof awGradient) {
$this->setBackgroundGradient($background);
}
}
/**
* Change image background color
*
* @param awColor $color
*/
public function setBackgroundColor(awColor $color) {
$this->background = $color;
}
/**
* Change image background gradient
*
* @param awGradient $gradient
*/
public function setBackgroundGradient(awGradient $gradient) {
$this->background = $gradient;
}
/**
* Return image background, whether a Color or a Gradient
*
* @return mixed
*/
public function getBackground() {
return $this->background;
}
/**
* Turn antialiasing on or off
*
* @var bool $bool
*/
public function setAntiAliasing($bool) {
$this->antiAliasing = (bool)$bool;
}
/**
* Return the antialiasing setting
*
* @return bool
*/
public function getAntiAliasing() {
return $this->antiAliasing;
}
/**
* Change image format
*
* @var int $format New image format
*/
public function setFormat($format) {
if($format === awImage::JPEG or $format === awImage::PNG or $format === awImage::GIF) {
$this->format = $format;
}
}
/**
* Returns the image format as an integer
*
* @return unknown
*/
public function getFormat() {
return $this->format;
}
/**
* Returns the image format as a string
*
* @return string
*/
public function getFormatString() {
switch($this->format) {
case awImage::JPEG :
return 'jpeg';
case awImage::PNG :
return 'png';
case awImage::GIF :
return 'gif';
}
}
/**
* Create a new awimage
*/
public function create() {
if($this->driver === NULL) {
$driver = $this->selectDriver($this->driverString);
$driver->init($this);
$this->driver = $driver;
}
}
/**
* Select the correct driver
*
* @param string $driver The desired driver
* @return mixed
*/
protected 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;
}
}
/**
* Draw a component on the image
*
* @var awComponent $component A component
*/
public function drawComponent(awComponent $component) {
$shadow = $this->shadow->getSpace(); // Image shadow
$border = $this->border->visible() ? 1 : 0; // Image border size
$driver = clone $this->driver;
$driver->setImageSize(
$this->width - $shadow->left - $shadow->right - $border * 2,
$this->height - $shadow->top - $shadow->bottom - $border * 2
);
// No absolute size specified
if($component->w === NULL and $component->h === NULL) {
list($width, $height) = $driver->setSize($component->width, $component->height);
// Set component size in pixels
$component->setAbsSize($width, $height);
} else {
$driver->setAbsSize($component->w, $component->h);
}
if($component->top !== NULL and $component->left !== NULL) {
$driver->setAbsPosition(
$border + $shadow->left + $component->left,
$border + $shadow->top + $component->top
);
} else {
$driver->setPosition($component->x, $component->y);
}
$driver->movePosition($border + $shadow->left, $border + $shadow->top);
list($x1, $y1, $x2, $y2) = $component->getPosition();
$component->init($driver);
$component->drawComponent($driver, $x1, $y1, $x2, $y2, $this->antiAliasing);
$component->drawEnvelope($driver, $x1, $y1, $x2, $y2);
$component->finalize($driver);
}
protected function drawShadow() {
$driver = $this->getDriver();
$this->shadow->draw(
$driver,
new awPoint(0, 0),
new awPoint($this->width, $this->height),
awShadow::IN
);
}
/**
* Send the image into a file or to the user browser
*
*/
public function send() {
$this->driver->send($this);
}
/**
* Return the image content as binary data
*
*/
public function get() {
return $this->driver->get($this);
}
/**
* Send the correct HTTP header according to the image type
*
*/
public function sendHeaders() {
if(headers_sent() === FALSE) {
switch ($this->driverString) {
case 'gd' :
header('Content-type: image/'.$this->getFormatString());
break;
}
}
}
private static $errorWriting = FALSE;
/*
* Display an error image and exit
*
* @param string $message Error message
*/
public static function drawError($message) {
if(self::$errorWriting) {
return;
}
self::$errorWriting = TRUE;
$message = wordwrap($message, 40, "\n", TRUE);
$width = 400;
$height = max(100, 40 + 22.5 * (substr_count($message, "\n") + 1));
$image = new awImage();
$image->setSize($width, $height);
$image->setDriver('gd');
$driver = $image->getDriver();
$driver->init($image);
// Display title
$driver->filledRectangle(
new awWhite,
new awLine(
new awPoint(0, 0),
new awPoint($width, $height)
)
);
$driver->filledRectangle(
new awRed,
new awLine(
new awPoint(0, 0),
new awPoint(110, 25)
)
);
$text = new awText(
"Artichow error",
new awFont3,
new awWhite,
0
);
$driver->string($text, new awPoint(5, 6));
// Display red box
$driver->rectangle(
new awRed,
new awLine(
new awPoint(0, 25),
new awPoint($width - 90, $height - 1)
)
);
// Display error image
$file = ARTICHOW_IMAGE.DIRECTORY_SEPARATOR.'error.png';
$imageError = new awFileImage($file);
$driver->copyImage(
$imageError,
new awPoint($width - 81, $height - 81),
new awPoint($width - 1, $height - 1)
);
// Draw message
$text = new awText(
strip_tags($message),
new awFont2,
new awBlack,
0
);
$driver->string($text, new awPoint(10, 40));
$image->send();
exit;
}
/*
* Display an error image located in a file and exit
*
* @param string $error Error name
*/
public static function drawErrorFile($error) {
$file = ARTICHOW_IMAGE.DIRECTORY_SEPARATOR.'errors'.DIRECTORY_SEPARATOR.$error.'.png';
header("Content-Type: image/png");
readfile($file);
exit;
}
}
registerClass('Image');
/**
* Load an image from a file
*
* @package Artichow
*/
class awFileImage extends awImage {
/**
* Build a new awimage
*
* @param string $file Image file name
*/
public function __construct($file) {
$driver = $this->selectDriver($this->driverString);
$driver->initFromFile($this, $file);
$this->driver = $driver;
}
}
registerClass('FileImage');
?>

585
artichow/LinePlot.class.php Normal file
View file

@ -0,0 +1,585 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Plot.class.php";
/**
* LinePlot
*
* @package Artichow
*/
class awLinePlot extends awPlot implements awLegendable {
/**
* Add marks to your line plot
*
* @var Mark
*/
public $mark;
/**
* Labels on your line plot
*
* @var Label
*/
public $label;
/**
* Filled areas
*
* @var bool
*/
protected $areas = array();
/**
* Is the line hidden
*
* @var bool
*/
protected $lineHide = FALSE;
/**
* Line color
*
* @var Color
*/
protected $lineColor;
/**
* Line mode
*
* @var int
*/
protected $lineMode = awLinePlot::LINE;
/**
* Line type
*
* @var int
*/
protected $lineStyle = awLine::SOLID;
/**
* Line thickness
*
* @var int
*/
protected $lineThickness = 1;
/**
* Line background
*
* @var Color, Gradient
*/
protected $lineBackground;
/**
* Line mode
*
* @var int
*/
const LINE = 0;
/**
* Line in the middle
*
* @var int
*/
const MIDDLE = 1;
/**
* Construct a new awLinePlot
*
* @param array $values Some numeric values for Y axis
* @param int $mode
*/
public function __construct($values, $mode = awLinePlot::LINE) {
parent::__construct();
$this->mark = new awMark;
$this->label = new awLabel;
$this->lineMode = (int)$mode;
$this->setValues($values);
}
/**
* Hide line
*
* @param bool $hide
*/
public function hideLine($hide) {
$this->lineHide = (bool)$hide;
}
/**
* 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);
}
/**
* Change line color
*
* @param awColor $color
*/
public function setColor(awColor $color) {
$this->lineColor = $color;
}
/**
* Change line style
*
* @param int $style
*/
public function setStyle($style) {
$this->lineStyle = (int)$style;
}
/**
* Change line tickness
*
* @param int $tickness
*/
public function setThickness($tickness) {
$this->lineThickness = (int)$tickness;
}
/**
* Change line background color
*
* @param awColor $color
*/
public function setFillColor(awColor $color) {
$this->lineBackground = $color;
}
/**
* Change line background gradient
*
* @param awGradient $gradient
*/
public function setFillGradient(awGradient $gradient) {
$this->lineBackground = $gradient;
}
/**
* Get the line thickness
*
* @return int
*/
public function getLegendLineThickness() {
return $this->lineThickness;
}
/**
* Get the line type
*
* @return int
*/
public function getLegendLineStyle() {
return $this->lineStyle;
}
/**
* Get the color of line
*
* @return Color
*/
public function getLegendLineColor() {
return $this->lineColor;
}
/**
* Get the background color or gradient of an element of the component
*
* @return Color, Gradient
*/
public function getLegendBackground() {
return $this->lineBackground;
}
/**
* Get a mark object
*
* @return Mark
*/
public function getLegendMark() {
return $this->mark;
}
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
$max = $this->getRealYMax();
$min = $this->getRealYMin();
// Get start and stop values
list($start, $stop) = $this->getLimit();
if($this->lineMode === awLinePlot::MIDDLE) {
$inc = $this->xAxis->getDistance(0, 1) / 2;
} else {
$inc = 0;
}
// Build the polygon
$polygon = new awPolygon;
for($key = $start; $key <= $stop; $key++) {
$value = $this->datay[$key];
if($value !== NULL) {
$p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $value));
$p = $p->move($inc, 0);
$polygon->set($key, $p);
}
}
// Draw backgrounds
if($this->lineBackground instanceof awColor or $this->lineBackground instanceof awGradient) {
$backgroundPolygon = new awPolygon;
$p = $this->xAxisPoint($start);
$p = $p->move($inc, 0);
$backgroundPolygon->append($p);
// Add others points
foreach($polygon->all() as $point) {
$backgroundPolygon->append(clone $point);
}
$p = $this->xAxisPoint($stop);
$p = $p->move($inc, 0);
$backgroundPolygon->append($p);
// Draw polygon background
$driver->filledPolygon($this->lineBackground, $backgroundPolygon);
}
$this->drawArea($driver, $polygon);
// Draw line
$prev = NULL;
// Line color
if($this->lineHide === FALSE) {
if($this->lineColor === NULL) {
$this->lineColor = new awColor(0, 0, 0);
}
foreach($polygon->all() as $point) {
if($prev !== NULL) {
$driver->line(
$this->lineColor,
new awLine(
$prev,
$point,
$this->lineStyle,
$this->lineThickness
)
);
}
$prev = $point;
}
}
// Draw marks and labels
foreach($polygon->all() as $key => $point) {
$this->mark->draw($driver, $point);
$this->label->draw($driver, $point, $key);
}
}
protected function drawArea(awDriver $driver, awPolygon $polygon) {
$starts = array();
foreach($this->areas as $area) {
list($start) = $area;
$starts[$start] = TRUE;
}
// Draw filled areas
foreach($this->areas as $area) {
list($start, $stop, $background) = $area;
$polygonArea = new awPolygon;
$p = $this->xAxisPoint($start);
$polygonArea->append($p);
for($i = $start; $i <= $stop; $i++) {
$p = clone $polygon->get($i);
if($i === $stop and array_key_exists($stop, $starts)) {
$p = $p->move(-1, 0);
}
$polygonArea->append($p);
}
$p = $this->xAxisPoint($stop);
if(array_key_exists($stop, $starts)) {
$p = $p->move(-1, 0);
}
$polygonArea->append($p);
// Draw area
$driver->filledPolygon($background, $polygonArea);
}
}
public function getXAxisNumber() {
if($this->lineMode === awLinePlot::MIDDLE) {
return count($this->datay) + 1;
} else {
return count($this->datay);
}
}
protected function xAxisPoint($position) {
$y = $this->xAxisZero ? 0 : $this->getRealYMin();
return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y));
}
public function getXCenter() {
return ($this->lineMode === awLinePlot::MIDDLE);
}
}
registerClass('LinePlot');
/**
* Simple LinePlot
* Useful to draw simple horizontal lines
*
* @package Artichow
*/
class awSimpleLinePlot extends awPlot implements awLegendable {
/**
* Line color
*
* @var Color
*/
protected $lineColor;
/**
* Line start
*
* @var int
*/
protected $lineStart;
/**
* Line stop
*
* @var int
*/
protected $lineStop;
/**
* Line value
*
* @var flaot
*/
protected $lineValue;
/**
* Line mode
*
* @var int
*/
protected $lineMode = awLinePlot::LINE;
/**
* Line type
*
* @var int
*/
protected $lineStyle = awLine::SOLID;
/**
* Line thickness
*
* @var int
*/
protected $lineThickness = 1;
/**
* Line mode
*
* @var int
*/
const LINE = 0;
/**
* Line in the middle
*
* @var int
*/
const MIDDLE = 1;
/**
* Construct a new awLinePlot
*
* @param float $value A Y value
* @param int $start Line start index
* @param int $stop Line stop index
* @param int $mode Line mode
*/
public function __construct($value, $start, $stop, $mode = awLinePlot::LINE) {
parent::__construct();
$this->lineMode = (int)$mode;
$this->lineStart = (int)$start;
$this->lineStop = (int)$stop;
$this->lineValue = (float)$value;
$this->lineColor = new awColor(0, 0, 0);
}
/**
* Change line color
*
* @param awColor $color
*/
public function setColor(awColor $color) {
$this->lineColor = $color;
}
/**
* Change line style
*
* @param int $style
*/
public function setStyle($style) {
$this->lineStyle = (int)$style;
}
/**
* Change line tickness
*
* @param int $tickness
*/
public function setThickness($tickness) {
$this->lineThickness = (int)$tickness;
}
/**
* Get the line thickness
*
* @return int
*/
public function getLegendLineThickness() {
return $this->lineThickness;
}
/**
* Get the line type
*
* @return int
*/
public function getLegendLineStyle() {
return $this->lineStyle;
}
/**
* Get the color of line
*
* @return Color
*/
public function getLegendLineColor() {
return $this->lineColor;
}
public function getLegendBackground() {
return NULL;
}
public function getLegendMark() {
return NULL;
}
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
if($this->lineMode === awLinePlot::MIDDLE) {
$inc = $this->xAxis->getDistance(0, 1) / 2;
} else {
$inc = 0;
}
$p1 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($this->lineStart, $this->lineValue));
$p2 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($this->lineStop, $this->lineValue));
$driver->line(
$this->lineColor,
new awLine(
$p1->move($inc, 0),
$p2->move($inc, 0),
$this->lineStyle,
$this->lineThickness
)
);
}
public function getXAxisNumber() {
if($this->lineMode === awLinePlot::MIDDLE) {
return count($this->datay) + 1;
} else {
return count($this->datay);
}
}
protected function xAxisPoint($position) {
$y = $this->xAxisZero ? 0 : $this->getRealYMin();
return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y));
}
public function getXCenter() {
return ($this->lineMode === awLinePlot::MIDDLE);
}
}
registerClass('SimpleLinePlot');
?>

439
artichow/MathPlot.class.php Normal file
View file

@ -0,0 +1,439 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Component.class.php";
/**
* A mathematic function
*
* @package Artichow
*/
class awMathFunction implements awLegendable {
/**
* Function line
*
* @var Line
*/
public $line;
/**
* Marks for your plot
*
* @var Mark
*/
public $mark;
/**
* Callback function
*
* @var string
*/
public $f;
/**
* Start the drawing from this value
*
* @var float
*/
public $fromX;
/**
* Stop the drawing at this value
*
* @var float
*/
public $toX;
/**
* Line color
*
* @var Color
*/
protected $color;
/**
* Construct the function
*
* @param string $f Callback function
* @param float $fromX
* @param float $toX
*/
public function __construct($f, $fromX = NULL, $toX = NULL) {
$this->f = (string)$f;
$this->fromX = is_null($fromX) ? NULL : (float)$fromX;
$this->toX = is_null($toX) ? NULL : (float)$toX;
$this->line = new awLine;
$this->mark = new awMark;
$this->color = new awBlack;
}
/**
* Change line color
*
* @param awColor $color A new awcolor
*/
public function setColor(awColor $color) {
$this->color = $color;
}
/**
* Get line color
*
* @return Color
*/
public function getColor() {
return $this->color;
}
/**
* Get the background color or gradient of an element of the component
*
* @return Color, Gradient
*/
public function getLegendBackground() {
}
/**
* Get the line thickness
*
* @return NULL
*/
public function getLegendLineThickness() {
return $this->line->getThickness();
}
/**
* Get the line type
*
* @return NULL
*/
public function getLegendLineStyle() {
return $this->line->getStyle();
}
/**
* Get the color of line
*
* @return NULL
*/
public function getLegendLineColor() {
return $this->color;
}
/**
* Get a mark object
*
* @return NULL
*/
public function getLegendMark() {
return $this->mark;
}
}
registerClass('MathFunction');
/**
* For mathematics functions
*
* @package Artichow
*/
class awMathPlot extends awComponent {
/**
* Functions
*
* @var array
*/
protected $functions = array();
/**
* Grid properties
*
* @var Grid
*/
public $grid;
/**
* X axis
*
* @var Axis
*/
public $xAxis;
/**
* Y axis
*
* @var Axis
*/
public $yAxis;
/**
* Extremum
*
* @var Side
*/
private $extremum = NULL;
/**
* Interval
*
* @var float
*/
private $interval = 1;
/**
* Build the plot
*
* @param int $xMin Minimum X value
* @param int $xMax Maximum X value
* @param int $yMax Maximum Y value
* @param int $yMin Minimum Y value
*/
public function __construct($xMin, $xMax, $yMax, $yMin) {
parent::__construct();
$this->setPadding(8, 8, 8, 8);
$this->grid = new awGrid;
// Hide grid by default
$this->grid->hide(TRUE);
// Set extremum
$this->extremum = new awSide($xMin, $xMax, $yMax, $yMin);
// Create axis
$this->xAxis = new awAxis;
$this->xAxis->setTickStyle(awTick::IN);
$this->xAxis->label->hideValue(0);
$this->initAxis($this->xAxis);
$this->yAxis = new awAxis;
$this->yAxis->setTickStyle(awTick::IN);
$this->yAxis->label->hideValue(0);
$this->initAxis($this->yAxis);
}
protected function initAxis(awAxis $axis) {
$axis->setLabelPrecision(1);
$axis->addTick('major', new awTick(0, 5));
$axis->addTick('minor', new awTick(0, 3));
$axis->addTick('micro', new awTick(0, 1));
$axis->setNumberByTick('minor', 'major', 1);
$axis->setNumberByTick('micro', 'minor', 4);
$axis->label->setFont(new awTuffy(7));
}
/**
* Interval to calculate values
*
* @param float $interval
*/
public function setInterval($interval) {
$this->interval = (float)$interval;
}
/**
* Add a formula f(x)
*
* @param awMathFunction $function
* @param string $name Name for the legend (can be NULL if you don't want to set a legend)
* @param int $type Type for the legend
*/
public function add(awMathFunction $function, $name = NULL, $type = awLegend::LINE) {
$this->functions[] = $function;
if($name !== NULL) {
$this->legend->add($function, $name, $type);
}
}
public function init(awDriver $driver) {
list($x1, $y1, $x2, $y2) = $this->getPosition();
$this->xAxis->line->setX($x1, $x2);
$this->xAxis->label->setAlign(NULL, awLabel::BOTTOM);
$this->xAxis->label->move(0, 3);
$this->xAxis->setRange($this->extremum->left, $this->extremum->right);
$this->yAxis->line->setY($y2, $y1);
$this->yAxis->label->setAlign(awLabel::RIGHT);
$this->yAxis->label->move(-6, 0);
$this->yAxis->reverseTickStyle();
$this->yAxis->setRange($this->extremum->bottom, $this->extremum->top);
$this->xAxis->setYCenter($this->yAxis, 0);
$this->yAxis->setXCenter($this->xAxis, 0);
if($this->yAxis->getLabelNumber() === NULL) {
$number = $this->extremum->top - $this->extremum->bottom + 1;
$this->yAxis->setLabelNumber($number);
}
if($this->xAxis->getLabelNumber() === NULL) {
$number = $this->extremum->right - $this->extremum->left + 1;
$this->xAxis->setLabelNumber($number);
}
// Set ticks
$this->xAxis->tick('major')->setNumber($this->xAxis->getLabelNumber());
$this->yAxis->tick('major')->setNumber($this->yAxis->getLabelNumber());
// Set axis labels
$labels = array();
for($i = 0, $count = $this->xAxis->getLabelNumber(); $i < $count; $i++) {
$labels[] = $i;
}
$this->xAxis->label->set($labels);
$labels = array();
for($i = 0, $count = $this->yAxis->getLabelNumber(); $i < $count; $i++) {
$labels[] = $i;
}
$this->yAxis->label->set($labels);
parent::init($driver);
// Create the grid
$this->createGrid();
// Draw the grid
$this->grid->draw($driver, $x1, $y1, $x2, $y2);
}
public function drawEnvelope(awDriver $driver) {
// Draw axis
$this->xAxis->draw($driver);
$this->yAxis->draw($driver);
}
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
foreach($this->functions as $function) {
$f = $function->f;
$fromX = is_null($function->fromX) ? $this->extremum->left : $function->fromX;
$toX = is_null($function->toX) ? $this->extremum->right : $function->toX;
$old = NULL;
for($i = $fromX; $i <= $toX; $i += $this->interval) {
$p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($i, $f($i)));
if($p->y >= $y1 and $p->y <= $y2) {
$function->mark->draw($driver, $p);
}
if($old !== NULL) {
$line = $function->line;
$line->setLocation($old, $p);
if(
($line->p1->y >= $y1 and $line->p1->y <= $y2) or
($line->p2->y >= $y1 and $line->p2->y <= $y2)
) {
$driver->line(
$function->getColor(),
$line
);
}
}
$old = $p;
}
// Draw last point if needed
if($old !== NULL and $i - $this->interval != $toX) {
$p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($toX, $f($toX)));
if($p->y >= $y1 and $p->y <= $y2) {
$function->mark->draw($driver, $p);
}
$line = $function->line;
$line->setLocation($old, $p);
if(
($line->p1->y >= $y1 and $line->p1->y <= $y2) or
($line->p2->y >= $y1 and $line->p2->y <= $y2)
) {
$driver->line(
$function->getColor(),
$line
);
}
}
}
}
protected function createGrid() {
// Horizontal lines of the grid
$major = $this->yAxis->tick('major');
$interval = $major->getInterval();
$number = $this->yAxis->getLabelNumber() - 1;
$h = array();
if($number > 0) {
for($i = 0; $i <= $number; $i++) {
$h[] = $i / $number;
}
}
// Vertical lines
$major = $this->xAxis->tick('major');
$interval = $major->getInterval();
$number = $this->xAxis->getLabelNumber() - 1;
$w = array();
if($number > 0) {
for($i = 0; $i <= $number; $i++) {
if($i%$interval === 0) {
$w[] = $i / $number;
}
}
}
$this->grid->setGrid($w, $h);
}
}
registerClass('MathPlot');
?>

View file

@ -0,0 +1,97 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Graph.class.php";
/**
* All patterns must derivate from this class
*
* @package Artichow
*/
abstract class awPattern {
/**
* Pattern arguments
*
* @var array
*/
protected $args = array();
/**
* 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.");
}
}
/**
* Change pattern argument
*
* @param string $name Argument name
* @param mixed $value Argument value
*/
public function setArg($name, $value) {
if(is_string($name)) {
$this->args[$name] = $value;
}
}
/**
* Get an argument
*
* @param string $name
* @param mixed $default Default value if the argument does not exist (default to NULL)
* @return mixed Argument value
*/
protected function getArg($name, $default = NULL) {
if(array_key_exists($name, $this->args)) {
return $this->args[$name];
} else {
return $default;
}
}
/**
* Change several arguments
*
* @param array $args New arguments
*/
public function setArgs($args) {
if(is_array($args)) {
foreach($args as $name => $value) {
$this->setArg($name, $value);
}
}
}
}
registerClass('Pattern', TRUE);
?>

695
artichow/Pie.class.php Normal file
View file

@ -0,0 +1,695 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Component.class.php";
/**
* Pie
*
* @package Artichow
*/
class awPie extends awComponent {
/**
* A dark theme for pies
*
*
* @var int
*/
const DARK = 1;
/**
* A colored theme for pies
*
* @var int
*/
const COLORED = 2;
/**
* A water theme for pies
*
* @var int
*/
const AQUA = 3;
/**
* A earth theme for pies
*
* @var int
*/
const EARTH = 4;
/**
* Pie values
*
* @var array
*/
protected $values;
/**
* Pie colors
*
* @var array
*/
protected $colors;
/**
* Pie legend
*
* @var array
*/
protected $legendValues = array();
/**
* Intensity of the 3D effect
*
* @var int
*/
protected $size;
/**
* Border color
*
* @var Color
*/
protected $border;
/**
* Pie explode
*
* @var array
*/
protected $explode = array();
/**
* Initial angle
*
* @var int
*/
protected $angle = 0;
/**
* Labels precision
*
* @var int
*/
protected $precision;
/**
* Labels number
*
* @var int
*/
protected $number;
/**
* Labels minimum
*
* @var int
*/
protected $minimum;
/**
* Labels position
*
* @var int
*/
protected $position = 15;
/**
* Labels of your pie
*
* @var Label
*/
public $label;
/**
* Build the plot
*
* @param array $values Pie values
*/
public function __construct($values, $colors = awPie::COLORED) {
$this->setValues($values);
if(is_array($colors)) {
$this->colors = $colors;
} else {
switch($colors) {
case awPie::AQUA :
$this->colors = array(
new awColor(131, 220, 215),
new awColor(131, 190, 215),
new awColor(131, 160, 215),
new awColor(160, 140, 215),
new awColor(190, 131, 215),
new awColor(220, 131, 215)
);
break;
case awPie::EARTH :
$this->colors = array(
new awColor(97, 179, 110),
new awColor(130, 179, 97),
new awColor(168, 179, 97),
new awColor(179, 147, 97),
new awColor(179, 108, 97),
new awColor(99, 107, 189),
new awColor(99, 165, 189)
);
break;
case awPie::DARK :
$this->colors = array(
new awColor(140, 100, 170),
new awColor(130, 170, 100),
new awColor(160, 160, 120),
new awColor(150, 110, 140),
new awColor(130, 150, 160),
new awColor(90, 170, 140)
);
break;
default :
$this->colors = array(
new awColor(187, 213, 151),
new awColor(223, 177, 151),
new awColor(111, 186, 132),
new awColor(197, 160, 230),
new awColor(165, 169, 63),
new awColor(218, 177, 89),
new awColor(116, 205, 121),
new awColor(200, 201, 78),
new awColor(127, 205, 177),
new awColor(205, 160, 160),
new awColor(190, 190, 190)
);
break;
}
}
parent::__construct();
$this->label = new awLabel;
$this->label->setCallbackFunction('callbackPerCent');
}
/**
* Change legend values
*
* @param array $legend An array of values for each part of the pie
*/
public function setLegend($legend) {
$this->legendValues = (array)$legend;
}
/**
* Set a border all around the pie
*
* @param awColor $color A color for the border
*/
public function setBorderColor(awColor $color) {
$this->border = $color;
}
/**
* Set a border all around the pie
*
* @param awColor $color A color for the border
*/
public function setBorder(awColor $color) {
if(ARTICHOW_DEPRECATED === TRUE) {
awImage::drawError('Class Pie: Method setBorder() has been deprecated since Artichow 1.0.9. Please use setBorderColor() instead.');
} else {
$this->setBorderColor($color);
}
}
/**
* Change 3D effect intensity
*
* @param int $size Effect size
*/
public function set3D($size) {
$this->size = (int)$size;
}
/**
* Change initial angle
*
* @param int $angle New angle in degrees
*/
public function setStartAngle($angle) {
$this->angle = (int)$angle;
}
/**
* Change label precision
*
* @param int $precision New precision
*/
public function setLabelPrecision($precision) {
$this->precision = (int)$precision;
}
/**
* Change label position
*
* @param int $position New position in pixels
*/
public function setLabelPosition($position) {
$this->position = (int)$position;
}
/**
* Change label number
*
* @param int $number New number
*/
public function setLabelNumber($number) {
$this->number = is_null($number) ? $number : (int)$number;
}
/**
* Change label minimum
*
* @param int $minimum New minimum
*/
public function setLabelMinimum($minimum) {
$this->minimum = is_null($minimum) ? $minimum : (int)$minimum;
}
/**
* Change Pie explode
*
* @param array $explode
*/
public function explode($explode) {
$this->explode = (array)$explode;
}
public function drawEnvelope(awDriver $driver) {
}
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
$count = count($this->values);
$sum = array_sum($this->values);
$width = $x2 - $x1;
$height = $y2 - $y1;
if($aliasing) {
$x = $width / 2;
$y = $height / 2;
} else {
$x = $width / 2 + $x1;
$y = $height / 2 + $y1;
}
$position = $this->angle;
$values = array();
$parts = array();
$angles = 0;
if($aliasing) {
$side = new awSide(0, 0, 0, 0);
}
foreach($this->values as $key => $value) {
$angle = ($value / $sum * 360);
if($key === $count - 1) {
$angle = 360 - $angles;
}
$angles += $angle;
if(array_key_exists($key, $this->explode)) {
$middle = 360 - ($position + $angle / 2);
$posX = $this->explode[$key] * cos($middle * M_PI / 180);
$posY = $this->explode[$key] * sin($middle * M_PI / 180) * -1;
if($aliasing) {
$explode = new awPoint(
$posX * 2,
$posY * 2
);
$side->set(
max($side->left, $posX * -2),
max($side->right, $posX * 2),
max($side->top, $posY * -2),
max($side->bottom, $posY * 2)
);
} else {
$explode = new awPoint(
$posX,
$posY
);
}
} else {
$explode = new awPoint(0, 0);
}
$values[$key] = array(
$position, ($position + $angle), $explode
);
$color = $this->colors[$key % count($this->colors)];
$parts[$key] = new awPiePart($color);
// Add part to the legend
$legend = array_key_exists($key, $this->legendValues) ? $this->legendValues[$key] : $key;
$this->legend->add($parts[$key], $legend, awLegend::BACKGROUND);
$position += $angle;
}
if($aliasing) {
$mainDriver = $driver;
$x *= 2;
$y *= 2;
$width *= 2;
$height *= 2;
$this->size *= 2;
$image = new awImage;
$image->border->hide();
// Adds support for antialiased pies on non-white background
$background = $this->getBackground();
if($background instanceof awColor) {
$image->setBackgroundColor($background);
}
// elseif($background instanceof awGradient) {
// $image->setBackgroundColor(new White(100));
// }
$image->setSize(
$width + $side->left + $side->right,
$height + $side->top + $side->bottom + $this->size + 1 /* bugs.php.net ! */
);
$driver = $image->getDriver(
$width / $image->width,
$height / $image->height,
($width / 2 + $side->left) / $image->width,
($height / 2 + $side->top) / $image->height
);
}
// Draw 3D effect
for($i = $this->size; $i > 0; $i--) {
foreach($values as $key => $value) {
$color = clone $this->colors[$key % count($this->colors)];
$color->brightness(-50);
list($from, $to, $explode) = $value;
$driver->filledArc($color, $explode->move($x, $y + $i), $width, $height, $from, $to);
unset($color);
if($this->border instanceof awColor) {
$point = $explode->move($x, $y);
if($i === $this->size) {
$driver->arc($this->border, $point->move(0, $this->size), $width, $height, $from, $to);
}
}
}
}
foreach($values as $key => $value) {
$color = $this->colors[$key % count($this->colors)];
list($from, $to, $explode) = $value;
$driver->filledArc($color, $explode->move($x, $y), $width, $height, $from, $to);
if($this->border instanceof awColor) {
$point = $explode->move($x, $y);
$driver->arc($this->border, $point, $width, $height, $from, $to);
}
}
if($aliasing) {
$x = $x / 2 + $x1;
$y = $y / 2 + $y1;
$width /= 2;
$height /= 2;
$this->size /= 2;
foreach($values as $key => $value) {
$old = $values[$key][2];
$values[$key][2] = new awPoint(
$old->x / 2, $old->y / 2
);
}
$mainDriver->copyResizeImage(
$image,
new awPoint($x1 - $side->left / 2, $y1 - $side->top / 2),
new awPoint($x1 - $side->left / 2 + $image->width / 2, $y1 - $side->top / 2 + $image->height/ 2),
new awPoint(0, 0),
new awPoint($image->width, $image->height),
TRUE
);
$driver = $mainDriver;
}
// Get labels values
$pc = array();
foreach($this->values as $key => $value) {
$pc[$key] = round($value / $sum * 100, $this->precision);
}
if($this->label->count() === 0) { // Check that there is no user defined values
$this->label->set($pc);
}
$position = 0;
foreach($pc as $key => $value) {
// Limit number of labels to display
if($position === $this->number) {
break;
}
if(is_null($this->minimum) === FALSE and $value < $this->minimum) {
continue;
}
$position++;
list($from, $to, $explode) = $values[$key];
$angle = $from + ($to - $from) / 2;
$angleRad = (360 - $angle) * M_PI / 180;
$point = new awPoint(
$x + $explode->x + cos($angleRad) * ($width / 2 + $this->position),
$y + $explode->y - sin($angleRad) * ($height / 2 + $this->position)
);
$angle %= 360;
// We don't display labels on the 3D effect
if($angle > 0 and $angle < 180) {
$point = $point->move(0, -1 * sin($angleRad) * $this->size);
}
if($angle >= 45 and $angle < 135) {
$this->label->setAlign(awLabel::CENTER, awLabel::BOTTOM);
} else if($angle >= 135 and $angle < 225) {
$this->label->setAlign(awLabel::RIGHT, awLabel::MIDDLE);
} else if($angle >= 225 and $angle < 315) {
$this->label->setAlign(awLabel::CENTER, awLabel::TOP);
} else {
$this->label->setAlign(awLabel::LEFT, awLabel::MIDDLE);
}
$this->label->draw(
$driver,
$point,
$key
);
}
}
/**
* Return margins around the component
*
* @return array Left, right, top and bottom margins
*/
public function getMargin() {
// Get axis informations
$leftAxis = $this->padding->left;
$rightAxis = $this->padding->right;
$topAxis = $this->padding->top;
$bottomAxis = $this->padding->bottom;
return array($leftAxis, $rightAxis, $topAxis, $bottomAxis);
}
/**
* Change values of Y axis
* This method ignores not numeric values
*
* @param array $values
*/
public function setValues($values) {
$this->checkArray($values);
$this->values = $values;
}
/**
* Return values of Y axis
*
* @return array
*/
public function getValues() {
return $this->values;
}
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.");
}
}
}
registerClass('Pie');
/**
* Pie
*
* @package Artichow
*/
class awPiePart implements awLegendable {
/**
* Pie part color
*
* @var Color
*/
protected $color;
/**
* Build a new awPiePart
*
* @param awColor $color Pie part color
*/
public function __construct(awColor $color) {
$this->color = $color;
}
/**
* Get the background color or gradient of an element of the component
*
* @return Color, Gradient
*/
public function getLegendBackground() {
return $this->color;
}
/**
* Get the line thickness
*
* @return NULL
*/
public function getLegendLineThickness() {
}
/**
* Get the line type
*
* @return NULL
*/
public function getLegendLineStyle() {
}
/**
* Get the color of line
*
* @return NULL
*/
public function getLegendLineColor() {
}
/**
* Get a mark object
*
* @return NULL
*/
public function getLegendMark() {
}
}
registerClass('PiePart');
function callbackPerCent($value) {
return $value.'%';
}
?>

1464
artichow/Plot.class.php Normal file

File diff suppressed because it is too large Load diff

120
artichow/README Normal file
View file

@ -0,0 +1,120 @@
I. Installation
II. Configuration
III. Utilisation
IV. Divers
I. Installation
------------
*** Première installation ***
L'installation de Artichow se résume à décompresser l'archive dans le dossier
de votre choix sur votre serveur. Veillez simplement à télécharger l'archive
dont vous avez vraiment besoin (PHP 5 ou PHP 4 & 5).
Notez que Artichow requiert GD 2 et PHP 4.3.0 au minimum pour fonctionner.
*** Mise à jour ***
Lorsque vous souhaitez mettre à jour Artichow avec la dernière version,
essayez de suivre pas à pas ces étapes :
1) Décompressez la dernière version de Artichow dans un dossier
2) Ecrasez le fichier Artichow.cfg.php avec votre ancien fichier
3) Copiez vos patterns dans le dossier patterns/ de la nouvelle version
4) Supprimez l'ancienne version de Artichow de votre disque
5) Copiez la nouvelle version là où était l'ancienne
Une fois ces cinq étapes effectuées, vous n'aurez plus qu'à mettre
éventuellement à jour vos graphiques, en fonction des dernières évolutions de
l'API de Artichow. Pour cela, voyez le titre "Migrer d'une version à l'autre"
sur la page :
http://www.artichow.org/documentation
II. Configuration
-------------
Même si une utilisation normale de Artichow ne nécessite pas de configuration
particulière, il existe un fichier Artichow.cfg.php qui permet de modifier
quelques paramètres de la librairie.
Vous pouvez notamment configurer le répertoire vers les polices de caractère
en modifiant la constante ARTICHOW_FONT (par exemple en choisissant
'c:\Windows\font' si vous êtes sous Windows).
Vous pouvez également redéfinir la variable $fonts. Cette variable contient une
liste de polices TTF (sans l'extension) présentes dans votre répertoire
ARTICHOW_FONT. Pour toutes les polices de cette liste, une classe du même nom
est créée. Les polices ainsi définies peuvent ensuite être utilisées de cette
manière :
<?php
$font = new Verdana(12); // 12 représente la taille en points
?>
Il existe également une constante ARTICHOW_DEPRECATED. Si cette constante vaut
TRUE, alors un message d'erreur sera affiché lorsque vous utiliserez une
fonctionnalité dépréciée de Artichow. A l'inverse, avec la valeur FALSE,
vous pourrez continuer à utiliser les fonctions dépréciées sans soucis.
Cependant, dans un souci de compatibilité, il est préférable de mettre à
jour vos graphiques dès lors qu'un message de ce type apparaît (et donc de
laisser la constante à TRUE). Les fonctionnalités dépréciées sont toujours
potentiellement susceptibles de disparaître d'une version à l'autre de la
librairie.
La constante ARTICHOW_PREFIX est vide par défaut et correspond à un préfixe qui
est ajouté au nom de chaque classe utilisée sur Artichow. Certains noms de
classe (Graph, Image, Text, Font, etc.) sont utilisés par d'autres librairies
et cela peut aboutir à des conflits. Pour résoudre ce problème, choisissez par
exemple 'xyz' comme préfixe et toutes les classes de Artichow s'appèleront
désormais xyz[Nom normal]. Exemple d'utilisation de Artichow avec
ARTICHOW_PREFIX à 'xyz' :
<?php
require_once "Artichow/LinePlot.class.php";
$plot = new xyzLinePlot(array(1, 2, 3));
$plot->title->set('Mon graphique');
$plot->title->setFont(new xyzFont4);
$graph = new xyzGraph(400, 300);
$graph->add($plot);
$graph->draw();
?>
III. Utilisation
-----------
Si vous utilisez la version conçue exclusivement pour PHP 5, vous pouvez vous
référer aux exemples et aux tutoriels afin de bien prendre en main la
librairie.
Si vous utilisez la version pour PHP 4 & 5, référez vous également aux exemples
et tutoriels mais faîtes attention lors de l'inclusion des fichiers de
Artichow. N'incluez pas les fichiers de cette manière :
<?php
// Ceci ne fonctionnera pas
require_once "Artichow/php5/LinePlot.class.php";
// Cela non plus
require_once "Artichow/php4/LinePlot.class.php";
?>
Préférez plutôt :
<?php
// Fonctionnera correctement
require_once "Artichow/LinePlot.class.php";
?>
C'est la librairie qui se charge de sélectionner les bons fichiers en fonction
de la version de PHP dont vous disposez.
IV. Divers
------
La documentation de Artichow est disponible sur :
http://www.artichow.org/documentation
Des tutoriels sont accessibles sur :
http://www.artichow.org/tutorial
Un forum de support peut être trouvé sur :
http://www.artichow.org/forum/
N'oubliez pas que Artichow est dans le domaine public. Vous pouvez donc faire
CE QUE VOUS SOUHAITEZ avec cette librairie, y compris ajouter votre nom dans
chaque fichier, et la redistribuer ainsi.
Si vous souhaitez aider et participer au développement de Artichow, n'hésitez
pas à consulter cette page :
http://www.artichow.org/help

View file

@ -0,0 +1,300 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once dirname(__FILE__)."/Plot.class.php";
/**
* ScatterPlot
*
* @package Artichow
*/
class awScatterPlot extends awPlot implements awLegendable {
/**
* Add marks to the scatter plot
*
* @var Mark
*/
public $mark;
/**
* Labels on the plot
*
* @var Label
*/
public $label;
/**
* Link points ?
*
* @var bool
*/
protected $link = FALSE;
/**
* Display impulses
*
* @var bool
*/
protected $impulse = NULL;
/**
* Link NULL points ?
*
* @var bool
*/
protected $linkNull = FALSE;
/**
* Line color
*
* @var Color
*/
protected $lineColor;
/**
* Line type
*
* @var int
*/
protected $lineStyle = awLine::SOLID;
/**
* Line thickness
*
* @var int
*/
protected $lineThickness = 1;
/**
* Construct a new awScatterPlot
*
* @param array $datay Numeric values for Y axis
* @param array $datax Numeric values for X axis
* @param int $mode
*/
public function __construct($datay, $datax = NULL) {
parent::__construct();
// Defaults marks
$this->mark = new awMark;
$this->mark->setType(awMark::CIRCLE);
$this->mark->setSize(7);
$this->mark->border->show();
$this->label = new awLabel;
$this->setValues($datay, $datax);
$this->setColor(new awBlack);
}
/**
* Display plot as impulses
*
* @param awColor $impulse Impulses color (or NULL to disable impulses)
*/
public function setImpulse($color) {
$this->impulse = $color;
}
/**
* Link scatter plot points
*
* @param bool $link
* @param awColor $color Line color (default to black)
*/
public function link($link, $color = NULL) {
$this->link = (bool)$link;
if($color instanceof awColor) {
$this->setColor($color);
}
}
/**
* Ignore null values for Y data and continue linking
*
* @param bool $link
*/
public function linkNull($link) {
$this->linkNull = (bool)$link;
}
/**
* Change line color
*
* @param awColor $color
*/
public function setColor(awColor $color) {
$this->lineColor = $color;
}
/**
* Change line style
*
* @param int $style
*/
public function setStyle($style) {
$this->lineStyle = (int)$style;
}
/**
* Change line tickness
*
* @param int $tickness
*/
public function setThickness($tickness) {
$this->lineThickness = (int)$tickness;
}
/**
* Get the line thickness
*
* @return int
*/
public function getLegendLineThickness() {
return $this->lineThickness;
}
/**
* Get the line type
*
* @return int
*/
public function getLegendLineStyle() {
return $this->lineStyle;
}
/**
* Get the color of line
*
* @return Color
*/
public function getLegendLineColor() {
return $this->lineColor;
}
/**
* Get the background color or gradient of an element of the component
*
* @return Color, Gradient
*/
public function getLegendBackground() {
return NULL;
}
/**
* Get a mark object
*
* @return Mark
*/
public function getLegendMark() {
return $this->mark;
}
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
$count = count($this->datay);
// Get start and stop values
list($start, $stop) = $this->getLimit();
// Build the polygon
$polygon = new awPolygon;
for($key = 0; $key < $count; $key++) {
$x = $this->datax[$key];
$y = $this->datay[$key];
if($y !== NULL) {
$p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($x, $y));
$polygon->set($key, $p);
} else if($this->linkNull === FALSE) {
$polygon->set($key, NULL);
}
}
// Link points if needed
if($this->link) {
$prev = NULL;
foreach($polygon->all() as $point) {
if($prev !== NULL and $point !== NULL) {
$driver->line(
$this->lineColor,
new awLine(
$prev,
$point,
$this->lineStyle,
$this->lineThickness
)
);
}
$prev = $point;
}
}
// Draw impulses
if($this->impulse instanceof awColor) {
foreach($polygon->all() as $key => $point) {
if($point !== NULL) {
$zero = awAxis::toPosition(
$this->xAxis,
$this->yAxis,
new awPoint($key, 0)
);
$driver->line(
$this->impulse,
new awLine(
$zero,
$point,
awLine::SOLID,
1
)
);
}
}
}
// Draw marks and labels
foreach($polygon->all() as $key => $point) {
$this->mark->draw($driver, $point);
$this->label->draw($driver, $point, $key);
}
}
protected function xAxisPoint($position) {
$y = $this->xAxisZero ? 0 : $this->getRealYMin();
return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y));
}
public function getXCenter() {
return FALSE;
}
}
registerClass('ScatterPlot');
?>

13
artichow/TODO Normal file
View file

@ -0,0 +1,13 @@
- message d'erreur si MING n'est pas installé
- setLabelPrecision a un booleen pour déterminer s'il faut remplir avec des zéros ou non
- Label => TextBox
- Excel/Spider/Splines/Bezier
- doc de Pattern
- bug de la grille
- pouvoir tracer des lignes verticales et horizontales à n'importe quel endroit sur les Plots
- avant de parler de SimpleLinePlot, ajouter une classe CommonLinePlot, dont dérivent tous les LinePlot
- faire un mode auto pour les Pie (au delà d'un certain nombre de parts, grouper le reste sous l'étiquette 'Divers' (choisie par le user))

96
artichow/common.php Normal file
View file

@ -0,0 +1,96 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
/*
* Get the minimum of an array and ignore non numeric values
*/
function array_min($array) {
if(is_array($array) and count($array) > 0) {
do {
$min = array_pop($array);
if(is_numeric($min) === FALSE) {
$min = NULL;
}
} while(count($array) > 0 and $min === NULL);
if($min !== NULL) {
$min = (float)$min;
}
foreach($array as $value) {
if(is_numeric($value) and (float)$value < $min) {
$min = (float)$value;
}
}
return $min;
}
return NULL;
}
/*
* Get the maximum of an array and ignore non numeric values
*/
function array_max($array) {
if(is_array($array) and count($array) > 0) {
do {
$max = array_pop($array);
if(is_numeric($max) === FALSE) {
$max = NULL;
}
} while(count($array) > 0 and $max === NULL);
if($max !== NULL) {
$max = (float)$max;
}
foreach($array as $value) {
if(is_numeric($value) and (float)$value > $max) {
$max = (float)$value;
}
}
return $max;
}
return NULL;
}
/*
* Define file_put_contents() if needed
*/
if(function_exists('file_put_contents') === FALSE) {
function file_put_contents($file, $content) {
$fp = fopen($file, 'w');
if($fp) {
fwrite($fp, $content);
fclose($fp);
}
}
}
/*
* Change error handler
*/
set_error_handler('errorHandlerArtichow');
function errorHandlerArtichow($level, $message, $file, $line) {
awImage::drawError($message.' in '.$file.' on line '.$line.'.');
}
?>

137
artichow/doc/AntiSpam.html Normal file
View file

@ -0,0 +1,137 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class AntiSpam</h2><div class="extends"><ul>
<li><a href="Image.html">Image</a></li>
<ul><li>AntiSpam</li></ul>
</ul></div><div class="description">
<p>
La classe <a href="AntiSpam.html">AntiSpam</a> permet de créer des images pour interdire des requêtes automatisées sur certaines pages.
</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">protected</span> <span class="type">string</span> <a href="AntiSpam.html#property.string"><span class="argument">$string</span></a>
</li>
<li>
<span class="access">protected</span> <span class="type">int</span> <a href="AntiSpam.html#property.noise"><span class="argument">$noise</span></a> := <span class="default">0</span>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="AntiSpam.html#method.__construct">__construct</a>(<span class="type">string</span> <span class="argument">$string</span> := <span class="default">''</span>)
</li>
<li>
<span class="access">public</span> <span class="type">string</span> <a href="AntiSpam.html#method.setRand">setRand</a>(<span class="type">int</span> <span class="argument">$length</span>)
</li>
<li>
<span class="access">public</span> <a href="AntiSpam.html#method.setNoise">setNoise</a>(<span class="type">int</span> <span class="argument">$noise</span>)
</li>
<li>
<span class="access">public</span> <a href="AntiSpam.html#method.save">save</a>(<span class="type">string</span> <span class="argument">$qName</span>)
</li>
<li>
<span class="access">public</span> <a href="AntiSpam.html#method.check">check</a>(<span class="type">string</span> <span class="argument">$qName</span>, <span class="type">string</span> <span class="argument">$value</span>, <span class="type">bool</span> <span class="argument">$case</span> := <span class="default">TRUE</span>)
</li>
<li>
<span class="access">public</span> <a href="AntiSpam.html#method.draw">draw</a>()
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.string"></a><span class="access">protected</span> <span class="type">string</span> <a href="AntiSpam.html#property.string"><span class="argument">$string</span></a><div class="description">
La chaîne de caractère que devra retaper l'utilisateur.
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.noise"></a><span class="access">protected</span> <span class="type">int</span> <a href="AntiSpam.html#property.noise"><span class="argument">$noise</span></a> := <span class="default">0</span><div class="description">
Degré de bruit à afficher sur l'image (entre 0 et 10).
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="AntiSpam.html#method.__construct">__construct</a>(<span class="type">string</span> <span class="argument">$string</span> := <span class="default">''</span>)
<div class="description">
Construit une image anti-spam. Vous pouvez définir la chaîne de caractères à afficher sur l'image avec $string.
Si vous ne donnez aucune chaîne de caractères, voyez <a href="AntiSpam.html#method.setRand">AntiSpam::setRand()</a> pour générer une valeur aléatoire.
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setRand"></a><span class="access">public</span> <span class="type">string</span> <a href="AntiSpam.html#method.setRand">setRand</a>(<span class="type">int</span> <span class="argument">$length</span>)
<div class="description">
Génère une chaîne de caractère aléatoire de taille $length pour l'image anti-spam.
La chaîne de caractère ainsi créée est ensuite retournée.
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setNoise"></a><span class="access">public</span> <a href="AntiSpam.html#method.setNoise">setNoise</a>(<span class="type">int</span> <span class="argument">$noise</span>)
<div class="description">
Ajoute du bruit sur l'image.
Les valeurs possibles sont de 0 à 10, avec 0 pour ne pas afficher de bruit et 10 pour afficher un bruit maximal.
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.save"></a><span class="access">public</span> <a href="AntiSpam.html#method.save">save</a>(<span class="type">string</span> <span class="argument">$qName</span>)
<div class="description">
Enregistre la valeur de l'image anti-spam dans la session de l'utilisateur sous le nom $qName.
Cette méthode doit être utilisée en combinaison avec <a href="AntiSpam.html#method.check">AntiSpam::check()</a>.
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.check"></a><span class="access">public</span> <a href="AntiSpam.html#method.check">check</a>(<span class="type">string</span> <span class="argument">$qName</span>, <span class="type">string</span> <span class="argument">$value</span>, <span class="type">bool</span> <span class="argument">$case</span> := <span class="default">TRUE</span>)
<div class="description">
Vérifie que la valeur $value correspond à la valeur enregistrée sous le nom $qName avec <a href="AntiSpam.html#method.save">AntiSpam::save()</a>.
Si $case est mis à TRUE, alors la vérification NE sera PAS sensible à la casse, elle le sera à FALSE.
Cette méthode doit être utilisée en combinaison avec <a href="AntiSpam.html#method.save">AntiSpam::save()</a>.
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.draw"></a><span class="access">public</span> <a href="AntiSpam.html#method.draw">draw</a>()
<div class="description">
Affiche l'image anti-spam à l'écran.
<pre>
&lt;?php
require_once "AntiSpam.class.php";
$object = new <a href="AntiSpam.html">AntiSpam</a>();
$object-&gt;<a href="AntiSpam.html#method.setRand">setRand</a>(5);
$object-&gt;<a href="AntiSpam.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="AntiSpam.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

385
artichow/doc/Axis.html Normal file
View file

@ -0,0 +1,385 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class Axis</h2><div class="description">
<p>
La classe <a href="Axis.html">Axis</a> permet de manipuler des axes.
Un axe permet à un utilisateur de répérer les points et leurs valeurs sur un graphique.
</p>
<p>
De nombreuses méthodes de la classe <a href="Axis.html">Axis</a> ne sont pas documentées,
car elles ne sont utilisées qu'en interne par Artichow.
Néanmoins, si vous développez Artichow, vous aurez besoin de ces méthodes.
N'hésitez donc pas à parcourir le code source de cette classe.
</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="Axis.html#property.title"><span class="argument">$title</span></a>
</li>
<li>
<span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="Axis.html#property.label"><span class="argument">$label</span></a>
</li>
<li>
<span class="access">public</span> <a href="Line.html"><span class="type">Line</span></a> <a href="Axis.html#property.line"><span class="argument">$line</span></a>
</li>
<li>
<span class="access">protected</span> <span class="type">bool</span> <a href="Axis.html#property.auto"><span class="argument">$auto</span></a>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="Axis.html#method.__construct">__construct</a>(<span class="type">float</span> <span class="argument">$min</span>, <span class="type">float</span> <span class="argument">$max</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.auto">auto</a>(<span class="type">bool</span> <span class="argument">$auto</span>)
</li>
<li>
<span class="access">public</span> <a href="true.html"><span class="type">true</span></a> <a href="Axis.html#method.isAuto">isAuto</a>()
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.hide">hide</a>(<span class="type">bool</span> <span class="argument">$hide</span> := <span class="default">TRUE</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.addTick">addTick</a>(<span class="type">string</span> <span class="argument">$name</span>, <a href="Tick.html"><span class="type">Tick</span></a> <span class="argument">$tick</span>)
</li>
<li>
<span class="access">public</span> <a href="Tick.html"><span class="type">Tick</span></a> <a href="Axis.html#method.tick">tick</a>(<span class="type">string</span> <span class="argument">$name</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.deleteTick">deleteTick</a>(<span class="type">string</span> <span class="argument">$name</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.hideTicks">hideTicks</a>(<span class="type">bool</span> <span class="argument">$hide</span> := <span class="default">TRUE</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setTickStyle">setTickStyle</a>(<span class="type">int</span> <span class="argument">$style</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.reverseTickStyle">reverseTickStyle</a>()
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setTickInterval">setTickInterval</a>(<span class="type">int</span> <span class="argument">$interval</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setNumberByTick">setNumberByTick</a>(<span class="type">string</span> <span class="argument">$to</span>, <span class="type">string</span> <span class="argument">$from</span>, <span class="type">float</span> <span class="argument">$number</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setLabelInterval">setLabelInterval</a>(<span class="type">int</span> <span class="argument">$interval</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setLabelNumber">setLabelNumber</a>(<span class="type">int</span> <span class="argument">$number</span>)
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Axis.html#method.getLabelNumber">getLabelNumber</a>()
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setLabelPrecision">setLabelPrecision</a>(<span class="type">int</span> <span class="argument">$precision</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setLabelText">setLabelText</a>(<span class="type">array</span> <span class="argument">$texts</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setTitleAlignment">setTitleAlignment</a>(<span class="type">int</span> <span class="argument">$alignment</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setTitlePosition">setTitlePosition</a>(<span class="type">float</span> <span class="argument">$postion</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setColor">setColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
</li>
<li>
<span class="access">public</span> <a href="Axis.html#method.setPadding">setPadding</a>(<span class="type">int</span> <span class="argument">$left</span>, <span class="type">int</span> <span class="argument">$right</span>)
</li>
<li>
<span class="access">public</span> <a href="Side.html"><span class="type">Side</span></a> <a href="Axis.html#method.getPadding">getPadding</a>()
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.title"></a><span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="Axis.html#property.title"><span class="argument">$title</span></a><div class="description">
Représente le titre de l'axe.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.label"></a><span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="Axis.html#property.label"><span class="argument">$label</span></a><div class="description">
Représente les étiquettes qui portent les valeurs affichées sur l'axe.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.line"></a><span class="access">public</span> <a href="Line.html"><span class="type">Line</span></a> <a href="Axis.html#property.line"><span class="argument">$line</span></a><div class="description">
Représente la ligne de l'axe.
Vous pouvez modifier le style et l'épaisseur de cette ligne, pas ses coordonnées.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.auto"></a><span class="access">protected</span> <span class="type">bool</span> <a href="Axis.html#property.auto"><span class="argument">$auto</span></a><div class="description">
Précise si la gestion de l'axe doit être automatique ou non.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="Axis.html#method.__construct">__construct</a>(<span class="type">float</span> <span class="argument">$min</span>, <span class="type">float</span> <span class="argument">$max</span>)
<div class="description">
Déclare un nouvel axe.
Les variables $min et $max représentent respectivement la valeurs minimales et maximales associées à l'axe.
Par exemple, choisir $min = -12 et $max = 42 signifie tout simplement que l'axe ira de -12 à 42.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.auto"></a><span class="access">public</span> <a href="Axis.html#method.auto">auto</a>(<span class="type">bool</span> <span class="argument">$auto</span>)
<div class="description">
Active/désactive la gestion automatique de l'axe.
La gestion automatique est automatiquement désactivée en cas d'appel aux méthodes suivantes : <a href="Axis.html#method.setLabelNumber">Axis::setLabelNumber()</a>, <a href="Axis.html#method.setLabelInterval">Axis::setLabelInterval()</a>, <a href="Axis.html#method.setLabelPrecision">Axis::setLabelPrecision()</a> et <a href="Axis.html#method.setLabelText">Axis::setLabelText()</a>.
Lorsqu'un axe est sous gestion automatique, l'échelle est le nombre de valeurs à afficher sur l'axe sont automatiquement calculés.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.isAuto"></a><span class="access">public</span> <a href="true.html"><span class="type">true</span></a> <a href="Axis.html#method.isAuto">isAuto</a>()
<div class="description">
Retourne TRUE si l'axe est gérée automatiquement, FALSE sinon.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.hide"></a><span class="access">public</span> <a href="Axis.html#method.hide">hide</a>(<span class="type">bool</span> <span class="argument">$hide</span> := <span class="default">TRUE</span>)
<div class="description">
Cache ou non l'axe. Le paramètre $hide est par défaut à TRUE (ce qui signifie que l'axe ne sera pas dessiné).
S'il est mis à FALSE, l'axe sera dessiné.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.addTick"></a><span class="access">public</span> <a href="Axis.html#method.addTick">addTick</a>(<span class="type">string</span> <span class="argument">$name</span>, <a href="Tick.html"><span class="type">Tick</span></a> <span class="argument">$tick</span>)
<div class="description">
Associe un objet <a href="Tick.html">Tick</a> $tick à l'axe.
Cet objet sera reconnu par le nom $name au sein de la classe <a href="Axis.html">Axis</a>.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.tick"></a><span class="access">public</span> <a href="Tick.html"><span class="type">Tick</span></a> <a href="Axis.html#method.tick">tick</a>(<span class="type">string</span> <span class="argument">$name</span>)
<div class="description">
Récupère un objet <a href="Tick.html">Tick</a> en fonction de son nom.
Cet objet doit avoir été précédemment ajouté avec la méthode <a href="Axis.html#method.addTick">Axis::addTick()</a>.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.deleteTick"></a><span class="access">public</span> <a href="Axis.html#method.deleteTick">deleteTick</a>(<span class="type">string</span> <span class="argument">$name</span>)
<div class="description">
Supprime l'objet <a href="Tick.html">Tick</a> de nom $name associé à l'axe.
Pour pouvoir être supprimé, cet objet doit avoir été précédemment ajouté avec la méthode <a href="Axis.html#method.addTick">Axis::addTick()</a>.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.hideTicks"></a><span class="access">public</span> <a href="Axis.html#method.hideTicks">hideTicks</a>(<span class="type">bool</span> <span class="argument">$hide</span> := <span class="default">TRUE</span>)
<div class="description">
Cache ou non tous les ticks qui ont été associés à cet axe.
<div class="see">
Voir aussi :
<ul><li><a href="Axis.html#method.addTick">Axis::addTick()</a></li></ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setTickStyle"></a><span class="access">public</span> <a href="Axis.html#method.setTickStyle">setTickStyle</a>(<span class="type">int</span> <span class="argument">$style</span>)
<div class="description">
Change le style de tous les ticks associés à l'axe pour $style.
<div class="see">
Voir aussi :
<ul><li><a href="Tick.html#method.setStyle">Tick::setStyle()</a></li></ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.reverseTickStyle"></a><span class="access">public</span> <a href="Axis.html#method.reverseTickStyle">reverseTickStyle</a>()
<div class="description">
Inverse le style de tous les ticks associés à l'axe pour $style.
Si les ticks étaient tournés vers l'extérieur, ils seront désormais tournés vers l'intérieur.
Et vice-versa.
<div class="see">
Voir aussi :
<ul><li><a href="Tick.html#method.setStyle">Tick::setStyle()</a></li></ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setTickInterval"></a><span class="access">public</span> <a href="Axis.html#method.setTickInterval">setTickInterval</a>(<span class="type">int</span> <span class="argument">$interval</span>)
<div class="description">
Change l'intervalle d'affichage de tous les ticks associés à l'axe pour $interval.
Cette méthode permet d'espacer l'affichage des ticks par rapport aux valeurs de l'axe.
<div class="see">
Voir aussi :
<ul><li><a href="Tick.html#method.setStyle">Tick::setStyle()</a></li></ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setNumberByTick"></a><span class="access">public</span> <a href="Axis.html#method.setNumberByTick">setNumberByTick</a>(<span class="type">string</span> <span class="argument">$to</span>, <span class="type">string</span> <span class="argument">$from</span>, <span class="type">float</span> <span class="argument">$number</span>)
<div class="description">
Cette méthode permet de modifier la fréquence d'affichage d'un objet <a href="Tick.html">Tick</a> par rapport à un autre.
$to représente l'objet dont la fréquence d'affichage doit être modifiée et $from l'objet auquel on se réfère.
A chaque fois qu'un tick $from sera affiché, on affichera $number ticks $to.
Si $number vaut 2, cela signifie que deux ticks $to seront affichés pour un tick $from.
Cette méthode prend tout son sens donc le cadre des <a href="Plot.html">Plot</a> par exemple :
<pre>
&lt;?php
require_once 'LinePlot.class.php';
$graph = new <a href="Graph.html">Graph</a>(400, 400);
$plot = new <a href="LinePlot.html">LinePlot</a>(array(1, 2, 3));
// Pour chaque tick major affiché,
// on affichera 10 ticks minor
$plot-&gt;xAxis-&gt;setNumberByTick('minor', 'major', 10);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
Cela donne 10 ticks mineurs par tick majeur :
<div class="image">
<img src="doc/image/ticks.png" alt="10 ticks mineurs par tick majeur">
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setLabelInterval"></a><span class="access">public</span> <a href="Axis.html#method.setLabelInterval">setLabelInterval</a>(<span class="type">int</span> <span class="argument">$interval</span>)
<div class="description">
Change l'intervalle d'affichage des étiquettes sur l'axe pour $interval.
Par défaut, cet intervalle est égal à 1.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setLabelNumber"></a><span class="access">public</span> <a href="Axis.html#method.setLabelNumber">setLabelNumber</a>(<span class="type">int</span> <span class="argument">$number</span>)
<div class="description">
Change le nombre d'étiquettes à afficher sur l'axe pour $number.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.getLabelNumber"></a><span class="access">public</span> <span class="type">int</span> <a href="Axis.html#method.getLabelNumber">getLabelNumber</a>()
<div class="description">
Retourne le nombre d'étiquettes qui seront affichées sur l'axe.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setLabelPrecision"></a><span class="access">public</span> <a href="Axis.html#method.setLabelPrecision">setLabelPrecision</a>(<span class="type">int</span> <span class="argument">$precision</span>)
<div class="description">
Change la précision des valeurs affichées sur chaque étiquette de l'axe.
$number représente le nombre de chiffres après la virgule qui doivent être affiché.
Par défaut, $precision vaut 0.
<div class="see">
Voir aussi :
<ul>
<li><a href="Axis.html#method.setLabelText">Axis::setLabelText()</a></li>
<li><a href="Label.html#method.setCallbackFunction">Label::setCallbackFunction()</a></li>
</ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setLabelText"></a><span class="access">public</span> <a href="Axis.html#method.setLabelText">setLabelText</a>(<span class="type">array</span> <span class="argument">$texts</span>)
<div class="description">
Cette méthode permet d'afficher des valeurs arbitraires plutôt que des valeurs numériques sur les étiquettes de l'axe.
$texts est un tableau comportant autant d'entrées que d'étiquettes et qui contient les nouvelles valeurs à afficher.
<div class="see">
Voir aussi :
<ul>
<li><a href="Axis.html#method.setLabelPrecision">Axis::setLabelPrecision()</a></li>
<li><a href="Label.html#method.setCallbackFunction">Label::setCallbackFunction()</a></li>
</ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setTitleAlignment"></a><span class="access">public</span> <a href="Axis.html#method.setTitleAlignment">setTitleAlignment</a>(<span class="type">int</span> <span class="argument">$alignment</span>)
<div class="description">
Change l'alignement du titre de l'axe sur l'axe.
Les valeurs possibles sont <a href="Label.html#constant.LEFT">Label::LEFT</a>, <a href="Label.html#constant.RIGHT">Label::RIGHT</a>, <a href="Label.html#constant.TOP">Label::TOP</a> et <a href="Label.html#constant.BOTTOM">Label::BOTTOM</a>.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setTitlePosition"></a><span class="access">public</span> <a href="Axis.html#method.setTitlePosition">setTitlePosition</a>(<span class="type">float</span> <span class="argument">$postion</span>)
<div class="description">
Change la position du titre sur l'axe.
$position est une fraction de la taille de l'axe.
Par exemple, si $position est placé à 0.5, le titre sera affiché au milieu de l'axe.
Si $position vaut 0.25, alors le titre sera affiché sur le premier quart de l'axe.
Pour aligner le titre par rapport à cette position, utilisez la méthode <a href="Axis.html#method.setTitleAlignment">Axis::setTitleAlignment()</a>.
<div class="see">
Voir aussi :
<ul><li><a href="Axis.html#method.setTitleAlignment">Axis::setTitleAlignment()</a></li></ul>
</div>
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setColor"></a><span class="access">public</span> <a href="Axis.html#method.setColor">setColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
<div class="description">
Change la couleur de l'axe et de son titre pour $color.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setPadding"></a><span class="access">public</span> <a href="Axis.html#method.setPadding">setPadding</a>(<span class="type">int</span> <span class="argument">$left</span>, <span class="type">int</span> <span class="argument">$right</span>)
<div class="description">
Change l'espace interne à gauche et à droite de l'axe.
Gauche et droite n'ont de sens que pour les axes verticaux.
Pour les axes plus horizontaux, préférez haut à gauche et bas à droite.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.getPadding"></a><span class="access">public</span> <a href="Side.html"><span class="type">Side</span></a> <a href="Axis.html#method.getPadding">getPadding</a>()
<div class="description">
Retourne l'espace interne associé à l'axe.
</div>
<div class="description-bottom"><a href="Axis.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

199
artichow/doc/BarPlot.html Normal file
View file

@ -0,0 +1,199 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class BarPlot</h2><div class="extends"><ul>
<li><a href="Component.html">Component</a></li>
<ul>
<li><a href="Plot.html">Plot</a></li>
<ul><li>BarPlot <span class="interface">implements</span> <a href="Legendable.html">Legendable</a>
</li></ul>
</ul>
</ul></div><div class="description">
<p>
Cette classe permet de dessiner des histogrammes.
</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="BarPlot.html#property.label"><span class="argument">$label</span></a>
</li>
<li>
<span class="access">public</span> <a href="Shadow.html"><span class="type">Shadow</span></a> <a href="BarPlot.html#property.barShadow"><span class="argument">$barShadow</span></a>
</li>
<li>
<span class="access">public</span> <a href="Border.html"><span class="type">Border</span></a> <a href="BarPlot.html#property.barBorder"><span class="argument">$barBorder</span></a>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="BarPlot.html#method.__construct">__construct</a>(<span class="type">array</span> <span class="argument">$values</span>, <span class="type">int</span> <span class="argument">$identifier</span> := <span class="default">1</span>, <span class="type">int</span> <span class="argument">$number</span> := <span class="default">1</span>, <span class="type">int</span> <span class="argument">$depth</span> := <span class="default">0</span>)
</li>
<li>
<span class="access">public</span> <a href="BarPlot.html#method.setBarPadding">setBarPadding</a>(<span class="type">float</span> <span class="argument">$left</span> := <span class="default">NULL</span>, <span class="type">float</span> <span class="argument">$right</span> := <span class="default">NULL</span>)
</li>
<li>
<span class="access">public</span> <a href="BarPlot.html#method.setBarSize">setBarSize</a>(<span class="type">float</span> <span class="argument">$size</span>)
</li>
<li>
<span class="access">public</span> <a href="BarPlot.html#method.setBarSpace">setBarSpace</a>(<span class="type">int</span> <span class="argument">$space</span>)
</li>
<li>
<span class="access">public</span> <a href="BarPlot.html#method.setBarColor">setBarColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
</li>
<li>
<span class="access">public</span> <a href="BarPlot.html#method.setBarGradient">setBarGradient</a>(<a href="Gradient.html"><span class="type">Gradient</span></a> <span class="argument">$gradient</span>)
</li>
<li>
<span class="access">public</span> <a href="BarPlot.html#method.move">move</a>(<span class="type">int</span> <span class="argument">$x</span>, <span class="type">int</span> <span class="argument">$y</span>)
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.label"></a><span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="BarPlot.html#property.label"><span class="argument">$label</span></a><div class="description">
Représente les étiquettes affichées au-dessus de chaque barre de l'histogramme.
Ces étiquettes contiennent la valeur de chaque barre.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.barShadow"></a><span class="access">public</span> <a href="Shadow.html"><span class="type">Shadow</span></a> <a href="BarPlot.html#property.barShadow"><span class="argument">$barShadow</span></a><div class="description">
Représente l'ombre associée à chaque barre de l'histogramme.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.barBorder"></a><span class="access">public</span> <a href="Border.html"><span class="type">Border</span></a> <a href="BarPlot.html#property.barBorder"><span class="argument">$barBorder</span></a><div class="description">
La bordure à afficher autour de chaque barre de l'histogramme.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="BarPlot.html#method.__construct">__construct</a>(<span class="type">array</span> <span class="argument">$values</span>, <span class="type">int</span> <span class="argument">$identifier</span> := <span class="default">1</span>, <span class="type">int</span> <span class="argument">$number</span> := <span class="default">1</span>, <span class="type">int</span> <span class="argument">$depth</span> := <span class="default">0</span>)
<div class="description">
Créé un nouvel histogramme avec les valeurs présentes dans $values.
$number représente le nombre d'histogrammes affichés en parallèle tandis que $identifier permet de spécifier où se situe l'histogramme courant.
$depth représente la profondeur de l'histogramme en pixels.
Le tableau $values doit être une liste de valeurs dans un tableau incrémental, c'est-à-dire dont les clés valent de 0 à n - 1 (où n est la taille du tableau).
<pre>
&lt;?php
require_once "BarPlot.class.php";
$graph = new <a href="Graph.html">Graph</a>(400, 400);
// Tableau de valeurs
$x = array(-19, 42, 31);
$plot = new <a href="BarPlot.html">BarPlot</a>($x);
$plot-&gt;<a href="Plot.html#method.setXAxisZero">setXAxisZero</a>(TRUE);
$plot-&gt;<a href="BarPlot.html#method.setBarColor">setBarColor</a>(
new <a href="Color.html">Color</a>(240, 185, 130, 20)
);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBarPadding"></a><span class="access">public</span> <a href="BarPlot.html#method.setBarPadding">setBarPadding</a>(<span class="type">float</span> <span class="argument">$left</span> := <span class="default">NULL</span>, <span class="type">float</span> <span class="argument">$right</span> := <span class="default">NULL</span>)
<div class="description">
Change l'espace interne de gauche et de droite sur chaque barre.
Laisser $left ou $right à NULL permet de ne pas modifier l'ancienne valeur.
Les valeurs données doivent être comprises entre 0 et 1 et représentent une fraction de l'espace réservé à chaque barre.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBarSize"></a><span class="access">public</span> <a href="BarPlot.html#method.setBarSize">setBarSize</a>(<span class="type">float</span> <span class="argument">$size</span>)
<div class="description">
Change la taille de chaque barre pour $size.
Les valeurs données doivent être comprises entre 0 et 1 et représentent une fraction de l'espace réservé à chaque barre.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBarSpace"></a><span class="access">public</span> <a href="BarPlot.html#method.setBarSpace">setBarSpace</a>(<span class="type">int</span> <span class="argument">$space</span>)
<div class="description">
Change l'espace entre les histogrammes affichés en parallèle pour $space.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBarColor"></a><span class="access">public</span> <a href="BarPlot.html#method.setBarColor">setBarColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
<div class="description">
Change la couleur des barres de l'histogrammes.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBarGradient"></a><span class="access">public</span> <a href="BarPlot.html#method.setBarGradient">setBarGradient</a>(<a href="Gradient.html"><span class="type">Gradient</span></a> <span class="argument">$gradient</span>)
<div class="description">
Change le dégradé de fond des barres de l'histogramme.
Le dégradé de fond remplit le polygone définit par tous les points de la ligne additionés des points extrêmes de l'axe des abscisses.
<pre>
&lt;?php
require_once "BarPlot.class.php";
$graph = new <a href="Graph.html">Graph</a>(400, 400);
$x = array(19, 30, 31, -42, 11);
$plot = new <a href="BarPlot.html">BarPlot</a>($x);
$plot-&gt;<a href="BarPlot.html#method.setBarGradient">setBarGradient</a>(
new <a href="LinearGradient.html">LinearGradient</a>(
new <a href="Color.html">Color</a>(255, 20, 20, 30),
new <a href="Color.html">Color</a>(20, 255, 20, 30),
90
)
);
$plot-&gt;<a href="Plot.html#method.setYMin">setYMin</a>(-100);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.move"></a><span class="access">public</span> <a href="BarPlot.html#method.move">move</a>(<span class="type">int</span> <span class="argument">$x</span>, <span class="type">int</span> <span class="argument">$y</span>)
<div class="description">
Déplace chaque barre de $x pixels sur l'horizontale et $y pixels sur la vertical avant le dessin.
</div>
<div class="description-bottom"><a href="BarPlot.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

View file

@ -0,0 +1,61 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class BilinearGradient</h2><div class="extends"><ul>
<li><a href="Gradient.html">Gradient</a></li>
<ul>
<li><a href="LinearGradient.html">LinearGradient</a></li>
<ul><li>BilinearGradient</li></ul>
</ul>
</ul></div><div class="description">
<p>
Cette classe permet de décrire un dégradé bilinéaire. Un dégradé bilinéaire à ceci de particulier par rapport au dégradé linéaire que son centre peut être décalé.
</p>
<p style="font-weight: bold">
ATTENTION, les dégradés bilinéaires sont en cours de développement et ne sont pas encore disponibles sur Artichow.
</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties"><li>
<span class="access">public</span> <span class="type">int</span> <a href="BilinearGradient.html#property.center"><span class="argument">$center</span></a>
</li></ul><ul class="methods"><li>
<span class="access">public</span> <a href="BilinearGradient.html#method.__construct">__construct</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$from</span>, <a href="Color.html"><span class="type">Color</span></a> <span class="argument">$to</span>, <span class="type">int</span> <span class="argument">$angle</span>, <span class="type">float</span> <span class="argument">$center</span> := <span class="default">0.5</span>)
</li></ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.center"></a><span class="access">public</span> <span class="type">int</span> <a href="BilinearGradient.html#property.center"><span class="argument">$center</span></a><div class="description">
Décrit la position du centre du dégradé. Cette valeur doit être comprise entre 0 et 1.
</div>
<div class="description-bottom"><a href="BilinearGradient.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="BilinearGradient.html#method.__construct">__construct</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$from</span>, <a href="Color.html"><span class="type">Color</span></a> <span class="argument">$to</span>, <span class="type">int</span> <span class="argument">$angle</span>, <span class="type">float</span> <span class="argument">$center</span> := <span class="default">0.5</span>)
<div class="description">
Construit une nouveu dégradé. Cette méthode doit être appelée par toutes les classes qui dérivent de celle-ci. Le paramètre $from décrit la couleur de départ du dégradé et le paramètre $to celle de fin. Le troisième paramètre $angle décrit l'angle du dégradé. Ce peut être un dégradé horizontal (angle de 0°) ou un dégradé vertical (angle de 90°). Le dernier paramètre doit être compris entre 0 et 1 permet de spécifier le centre du dégradé. Une valeur de 0.5 signifie que le dégradé sera symétrique.
</div>
<div class="description-bottom"><a href="BilinearGradient.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

154
artichow/doc/Border.html Normal file
View file

@ -0,0 +1,154 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class Border</h2><div class="description">
<p>La classe <a href="Border.html">Border</a> permet de centraliser la gestion des bordures sur Artichow.</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">protected</span> <a href="Color.html"><span class="type">Color</span></a> <a href="Border.html#property.color"><span class="argument">$color</span></a> := <span class="default">new Black</span>
</li>
<li>
<span class="access">protected</span> <span class="type">int</span> <a href="Border.html#property.style"><span class="argument">$style</span></a> := <span class="default">Line::SOLID</span>
</li>
<li>
<span class="access">protected</span> <span class="type">bool</span> <a href="Border.html#property.hide"><span class="argument">$hide</span></a> := <span class="default">FALSE</span>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="Border.html#method.__construct">__construct</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span> := <span class="default">new Black</span>, <span class="type">int</span> <span class="argument">$style</span> := <span class="default">Line::SOLID</span>)
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.setColor">setColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.setStyle">setStyle</a>(<span class="type">int</span> <span class="argument">$style</span>)
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.hide">hide</a>(<span class="type">bool</span> <span class="argument">$hide</span> := <span class="default">TRUE</span>)
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.show">show</a>(<span class="type">bool</span> <span class="argument">$show</span> := <span class="default">TRUE</span>)
</li>
<li>
<span class="access">public</span> <span class="type">bool</span> <a href="Border.html#method.visible">visible</a>()
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.rectangle">rectangle</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <a href="Point.html"><span class="type">Point</span></a> <span class="argument">$p1</span>, <a href="Point.html"><span class="type">Point</span></a> <span class="argument">$p2</span>)
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.ellipse">ellipse</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <a href="Point.html"><span class="type">Point</span></a> <span class="argument">$center</span>, <span class="type">int</span> <span class="argument">$width</span>, <span class="type">int</span> <span class="argument">$height</span>)
</li>
<li>
<span class="access">public</span> <a href="Border.html#method.polygon">polygon</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <a href="Polygon.html"><span class="type">Polygon</span></a> <span class="argument">$polygon</span>)
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.color"></a><span class="access">protected</span> <a href="Color.html"><span class="type">Color</span></a> <a href="Border.html#property.color"><span class="argument">$color</span></a> := <span class="default">new Black</span><div class="description">
La couleur de la bordure
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.style"></a><span class="access">protected</span> <span class="type">int</span> <a href="Border.html#property.style"><span class="argument">$style</span></a> := <span class="default">Line::SOLID</span><div class="description">
Style de la ligne qui compose la bordure.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.hide"></a><span class="access">protected</span> <span class="type">bool</span> <a href="Border.html#property.hide"><span class="argument">$hide</span></a> := <span class="default">FALSE</span><div class="description">
Est-ce que la bordure doit être cachée ?
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="Border.html#method.__construct">__construct</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span> := <span class="default">new Black</span>, <span class="type">int</span> <span class="argument">$style</span> := <span class="default">Line::SOLID</span>)
<div class="description">
Déclare une nouvelle bordure de couleur $color et avec pour style $style.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setColor"></a><span class="access">public</span> <a href="Border.html#method.setColor">setColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
<div class="description">
Change la couleur de la bordure pour $color.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setStyle"></a><span class="access">public</span> <a href="Border.html#method.setStyle">setStyle</a>(<span class="type">int</span> <span class="argument">$style</span>)
<div class="description">
Change le style de la bordure pour $style.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.hide"></a><span class="access">public</span> <a href="Border.html#method.hide">hide</a>(<span class="type">bool</span> <span class="argument">$hide</span> := <span class="default">TRUE</span>)
<div class="description">
Détermine si la bordure doit être cachée ou non.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.show"></a><span class="access">public</span> <a href="Border.html#method.show">show</a>(<span class="type">bool</span> <span class="argument">$show</span> := <span class="default">TRUE</span>)
<div class="description">
Détermine si la bordure doit être affichée ou non.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.visible"></a><span class="access">public</span> <span class="type">bool</span> <a href="Border.html#method.visible">visible</a>()
<div class="description">
Retourne TRUE si la bordure doit être affichée, FALSE sinon.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.rectangle"></a><span class="access">public</span> <a href="Border.html#method.rectangle">rectangle</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <a href="Point.html"><span class="type">Point</span></a> <span class="argument">$p1</span>, <a href="Point.html"><span class="type">Point</span></a> <span class="argument">$p2</span>)
<div class="description">
Dessine la bordure sous la forme d'un rectangle dont la diagonale s'étend des points $p1 à $p2.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.ellipse"></a><span class="access">public</span> <a href="Border.html#method.ellipse">ellipse</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <a href="Point.html"><span class="type">Point</span></a> <span class="argument">$center</span>, <span class="type">int</span> <span class="argument">$width</span>, <span class="type">int</span> <span class="argument">$height</span>)
<div class="description">
Dessine la bordure sous la forme d'une ellipse de centre $center et de largeur et hauteur respectives $width et $height.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.polygon"></a><span class="access">public</span> <a href="Border.html#method.polygon">polygon</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <a href="Polygon.html"><span class="type">Polygon</span></a> <span class="argument">$polygon</span>)
<ul class="version"><li>
Disponible depuis Artichow 1.0.9</li></ul>
<div class="description">
Dessine la bordure comme un polygone entourant celui passé en argument.
</div>
<div class="description-bottom"><a href="Border.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

168
artichow/doc/Color.html Normal file
View file

@ -0,0 +1,168 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class Color</h2><div class="description">
<p>
La classe <a href="Color.html">Color</a> permet de gérer les couleurs de manière uniforme sur Artichow.
</p>
<p>
Afin de simplifier l'utilisation de cette classe, plusieurs couleurs sont déjà prédéfinies sur Artichow.
Chacune de ces couleurs est une classe qui dérive de <a href="Color.html">Color</a> et dont le constructeur ne prend qu'un paramètre, le degré de transparence. Voici les couleurs prédéfinies triées par ton :
</p>
<ul>
<li>
<em>Gris :</em> Black, AlmostBlack, VeryDarkGray, DarkGray, MidGray, LightGray, VeryLightGray, White</li>
<li>
<em>Rouge :</em> VeryDarkRed, DarkRed, MidRed, Red, LightRed</li>
<li>
<em>Vert :</em> VeryDarkGreen, DarkGreen, MidGreen, Green, LightGreen</li>
<li>
<em>Bleu :</em> VeryDarkBlue, DarkBlue, MidBlue, Blue, LightBlue</li>
<li>
<em>Jaune :</em> VeryDarkYellow, DarkYellow, MidYellow, Yellow, LightYellow</li>
<li>
<em>Cyan :</em> VeryDarkCyan, DarkCyan, MidCyan, Cyan, LightCyan</li>
<li>
<em>Magenta :</em> VeryDarkMagenta, DarkMagenta, MidMagenta, Magenta, LightMagenta</li>
<li>
<em>Orange :</em> DarkOrange, Orange, LightOrange, VeryLightOrange</li>
<li>
<em>Rose :</em> DarkPink, Pink, LightPink, VeryLightPink</li>
<li>
<em>Violet :</em> DarkPurple, Purple, LightPurple, VeryLightPurple</li>
</ul>
<p>
Voici un exemple d'utilisation pour les couleurs prédéfinies :
<pre>
&lt;?php
// On créé un bleu foncé
$blue = new DarkBlue; // Equivalent à new <a href="Color.html">Color</a>(0, 0, 128);
// On créé de l'orange transparent à 50 %
$orange = new Orange(50); // Equivalent à new <a href="Color.html">Color</a>(255, 128, 0, 50);
?&gt;
</pre>
</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.red"><span class="argument">$red</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.green"><span class="argument">$green</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.blue"><span class="argument">$blue</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.alpha"><span class="argument">$alpha</span></a>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="Color.html#method.__construct">__construct</a>(<span class="type">int</span> <span class="argument">$red</span>, <span class="type">int</span> <span class="argument">$green</span>, <span class="type">int</span> <span class="argument">$blue</span>, <span class="type">int</span> <span class="argument">$alpha</span> := <span class="default">0</span>)
</li>
<li>
<span class="access">public</span> <a href="Color.html#method.brightness">brightness</a>(<span class="type">int</span> <span class="argument">$brightness</span>)
</li>
<li>
<span class="access">public</span> <span class="type">array</span> <a href="Color.html#method.getColor">getColor</a>()
</li>
<li>
<span class="access">public</span> <span class="type">array</span> <a href="Color.html#method.rgba">rgba</a>()
</li>
<li>
<span class="access">public</span> <a href="Color.html#method.free">free</a>()
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.red"></a><span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.red"><span class="argument">$red</span></a><div class="description">
Intensité en rouge de la couleur (entre 0 et 255)
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.green"></a><span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.green"><span class="argument">$green</span></a><div class="description">
Intensité en vert de la couleur (entre 0 et 255)
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.blue"></a><span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.blue"><span class="argument">$blue</span></a><div class="description">
Intensité en blue de la couleur (entre 0 et 255)
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.alpha"></a><span class="access">public</span> <span class="type">int</span> <a href="Color.html#property.alpha"><span class="argument">$alpha</span></a><div class="description">
Degré de transparence de la couleur (entre 0 et 100)
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="Color.html#method.__construct">__construct</a>(<span class="type">int</span> <span class="argument">$red</span>, <span class="type">int</span> <span class="argument">$green</span>, <span class="type">int</span> <span class="argument">$blue</span>, <span class="type">int</span> <span class="argument">$alpha</span> := <span class="default">0</span>)
<div class="description">
Construit une nouvelle couleur. Les trois premiers paramètres représentent l'intensité en rouge, vert et bleu pour cette couleur. L'intensité de chaque couleur est un nombre compris entre 0 et 255 (du foncé vers le clair). Le paramètre $alpha représente le dégré de transparence de la couleur, et doit être compris entre 0 et 100.
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.brightness"></a><span class="access">public</span> <a href="Color.html#method.brightness">brightness</a>(<span class="type">int</span> <span class="argument">$brightness</span>)
<div class="description">
Change la luminosité de la couleur, en ajoutant la valeur $brightness à chaque composante (rouge, vert, bleu) de cette couleur.
$brightness peut prendre des valeurs comprises entre -255 et +255.
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.getColor"></a><span class="access">public</span> <span class="type">array</span> <a href="Color.html#method.getColor">getColor</a>()
<div class="description">
Retourne un tableau de quatre valeurs qui représentent l'intensité en rouge, vert et bleu ainsi que le degré de transparence de la couleur.
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.rgba"></a><span class="access">public</span> <span class="type">array</span> <a href="Color.html#method.rgba">rgba</a>()
<div class="description">
Retourne un tableau de quatre valeurs qui représentent l'intensité en rouge, vert et bleu ainsi que le degré de transparence de la couleur.
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.free"></a><span class="access">public</span> <a href="Color.html#method.free">free</a>()
<ul class="version"><li>
Supprimé à partir d'Artichow 1.1.0</li></ul>
<div class="description">
Libère les ressources allouées lors de l'appel à <a href="Color.html#method.getColor">getColor()</a>.
</div>
<div class="description-bottom"><a href="Color.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

464
artichow/doc/Component.html Normal file
View file

@ -0,0 +1,464 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2>
<small>abstract</small> Class Component</h2><div class="description">
<p>
Un composant est un objet qui peut être ajouté à une <a href="Image.html">Image</a>. Les composants sont indépendants les uns des autres. La classe <a href="Component.html">Component</a> est une classe abstraite, dont doivent dériver tous les objets qui vont pouvoir être ajoutés sur une image.
</p>
<p>
Sur un composant, l'axe des abscisses rejoint l'axe des ordonnées sur le coin haut-gauche. Le coin haut-gauche du composant a donc pour coordonnées (0, 0) et le coin bas-droite (largeur, hauteur). Par exemple, sur une image de largeur 100 et de hauteur 50, un point à 50 sur l'axe des abscisses et 25 sur l'axe des ordonnées sera au centre de l'image.
</p>
</div><div class="inherit">
Les classes suivantes dérivent de Component :
<ul>
<li><a href="ComponentGroup.html">ComponentGroup</a></li>
<li><a href="MathPlot.html">MathPlot</a></li>
<li><a href="Pie.html">Pie</a></li>
<li><a href="Plot.html">Plot</a></li>
</ul>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">protected</span> <a href="Driver.html"><span class="type">Driver</span></a> <a href="Component.html#property.driver"><span class="argument">$driver</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.width"><span class="argument">$width</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.height"><span class="argument">$height</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.x"><span class="argument">$x</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.y"><span class="argument">$y</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.w"><span class="argument">$w</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.h"><span class="argument">$h</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.top"><span class="argument">$top</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.left"><span class="argument">$left</span></a>
</li>
<li>
<span class="access">protected</span> <span class="type">mixed</span> <a href="Component.html#property.background"><span class="argument">$background</span></a>
</li>
<li>
<span class="access">public</span> <a href="Side.html"><span class="type">Side</span></a> <a href="Component.html#property.padding"><span class="argument">$padding</span></a>
</li>
<li>
<span class="access">public</span> <a href="Side.html"><span class="type">Side</span></a> <a href="Component.html#property.space"><span class="argument">$space</span></a>
</li>
<li>
<span class="access">protected</span> <span class="type">bool</span> <a href="Component.html#property.auto"><span class="argument">$auto</span></a>
</li>
<li>
<span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="Component.html#property.title"><span class="argument">$title</span></a>
</li>
<li>
<span class="access">public</span> <a href="Legend.html"><span class="type">Legend</span></a> <a href="Component.html#property.legend"><span class="argument">$legend</span></a>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="Component.html#method.__construct">__construct</a>()
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.auto">auto</a>(<span class="type">bool</span> <span class="argument">$auto</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setSize">setSize</a>(<span class="type">float</span> <span class="argument">$width</span>, <span class="type">float</span> <span class="argument">$height</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setAbsSize">setAbsSize</a>(<span class="type">int</span> <span class="argument">$w</span>, <span class="type">int</span> <span class="argument">$h</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setBackgroundColor">setBackgroundColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setBackgroundGradient">setBackgroundGradient</a>(<a href="Gradient.html"><span class="type">Gradient</span></a> <span class="argument">$gradient</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setBackgroundImage">setBackgroundImage</a>(<a href="Image.html"><span class="type">Image</span></a> <span class="argument">$image</span>)
</li>
<li>
<span class="access">public</span> <span class="type">mixed</span> <a href="Component.html#method.getBackground">getBackground</a>(<span class="type">int</span> <span class="argument">$type</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setPadding">setPadding</a>(<span class="type">int</span> <span class="argument">$left</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$right</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$top</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$bottom</span> := <span class="default">NULL</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setSpace">setSpace</a>(<span class="type">int</span> <span class="argument">$left</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$right</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$top</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$bottom</span> := <span class="default">NULL</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setCenter">setCenter</a>(<span class="type">float</span> <span class="argument">$x</span>, <span class="type">float</span> <span class="argument">$y</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.setAbsPosition">setAbsPosition</a>(<span class="type">int</span> <span class="argument">$left</span>, <span class="type">int</span> <span class="argument">$top</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.init">init</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
</li>
<li>
<span class="access">public</span> <a href="Component.html#method.finalize">finalize</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
</li>
<li>
<span class="access">abstract public</span> <span class="type">array</span> <a href="Component.html#method.getPosition">getPosition</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
</li>
<li>
<span class="access">abstract public</span> <a href="Component.html#method.drawEnvelope">drawEnvelope</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
</li>
<li>
<span class="access">abstract public</span> <a href="Component.html#method.drawComponent">drawComponent</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <span class="type">int</span> <span class="argument">$x1</span>, <span class="type">int</span> <span class="argument">$y1</span>, <span class="type">int</span> <span class="argument">$x2</span>, <span class="type">int</span> <span class="argument">$y2</span>, <span class="type">bool</span> <span class="argument">$aliasing</span>)
</li>
<li>
<span class="access">protected</span> <a href="Component.html#method.getSpace">getSpace</a>(<span class="type">int</span> <span class="argument">$width</span>, <span class="type">int</span> <span class="argument">$height</span>)
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.driver"></a><span class="access">protected</span> <a href="Driver.html"><span class="type">Driver</span></a> <a href="Component.html#property.driver"><span class="argument">$driver</span></a><div class="description">
Un objet <a href="Driver.html">Driver</a> pour dessiner sur l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.width"></a><span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.width"><span class="argument">$width</span></a><div class="description">
Largeur du composant entre 0 et 1. Représente une fraction de la largeur de l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.height"></a><span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.height"><span class="argument">$height</span></a><div class="description">
Hauteur du composant entre 0 et 1. Représente une fraction de la hauteur de l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.x"></a><span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.x"><span class="argument">$x</span></a><div class="description">
Position du composant sur l'axe des abscisses entre 0 et 1. Représente une fraction de la largeur de l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.y"></a><span class="access">public</span> <span class="type">float</span> <a href="Component.html#property.y"><span class="argument">$y</span></a><div class="description">
Position du composant sur l'axe des ordonnées entre 0 et 1. Représente une fraction de la hauteur de l'image.
Attention, la position 0 correspond au haut de l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.w"></a><span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.w"><span class="argument">$w</span></a><div class="description">
Largeur du composant en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.h"></a><span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.h"><span class="argument">$h</span></a><div class="description">
Hauteur du composant en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.top"></a><span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.top"><span class="argument">$top</span></a><div class="description">
Position du composant sur l'axe des ordonnées en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.left"></a><span class="access">public</span> <span class="type">int</span> <a href="Component.html#property.left"><span class="argument">$left</span></a><div class="description">
Position du composant sur l'axe des abscisses en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.background"></a><span class="access">protected</span> <span class="type">mixed</span> <a href="Component.html#property.background"><span class="argument">$background</span></a><div class="description">
Fond du composant. Peut être une <a href="Color.html">couleur</a>, un <a href="Gradient.html">dégradé</a> ou peut être laissé à NULL pour ne spécifier aucune couleur de fond.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.padding"></a><span class="access">public</span> <a href="Side.html"><span class="type">Side</span></a> <a href="Component.html#property.padding"><span class="argument">$padding</span></a><div class="description">
Espace interne du composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.space"></a><span class="access">public</span> <a href="Side.html"><span class="type">Side</span></a> <a href="Component.html#property.space"><span class="argument">$space</span></a><div class="description">
Espace interne dans la zone de dessin effective du composant. Les valeurs doivent être données en pourcentage de la taille de la zone de dessin.
Le zone de dessin est la zone dans laquelle est dessiné le composant, c'est-à-dire la zone du composant amputée des axes et de l'<a href="Component.html#property.padding">espace interne</a>.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.auto"></a><span class="access">protected</span> <span class="type">bool</span> <a href="Component.html#property.auto"><span class="argument">$auto</span></a><div class="description">
Doit-on ajuster automatiquement le composant ?
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.title"></a><span class="access">public</span> <a href="Label.html"><span class="type">Label</span></a> <a href="Component.html#property.title"><span class="argument">$title</span></a><div class="description">
Le titre du composant.
Si un titre est spécifié, il sera affiché sur l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="property">
<a id="property.legend"></a><span class="access">public</span> <a href="Legend.html"><span class="type">Legend</span></a> <a href="Component.html#property.legend"><span class="argument">$legend</span></a><div class="description">
La légende associée au composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="Component.html#method.__construct">__construct</a>()
<div class="description">
Construit le composant en lui affectant une taille égale à celle de l'image et en le positionnant au centre de cette image.
Le composant remplit donc toute la surface de l'image.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.auto"></a><span class="access">public</span> <a href="Component.html#method.auto">auto</a>(<span class="type">bool</span> <span class="argument">$auto</span>)
<div class="description">
TRUE si le composant doit être automatiquement ajusté, FALSE sinon.
La notion d'ajustage automatique est propre à chaque classe qui dérive de celle-ci.
Par exemple, sur les histogrammes, si le composant n'est pas automatiquement ajusté, alors les barres ne seront pas centrées sur zéro mais sur leur valeur minimum.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setSize"></a><span class="access">public</span> <a href="Component.html#method.setSize">setSize</a>(<span class="type">float</span> <span class="argument">$width</span>, <span class="type">float</span> <span class="argument">$height</span>)
<div class="description">
Change la largeur $width et la hauteur $height du composant.
Les nouvelles valeurs doivent être comprises entre 0 et 1 et correspondent à une fraction des largeur et hauteur de l'image à laquelle le composant appartient.
<pre>
&lt;?php
require_once "LinePlot.class.php";
$graph = new <a href="Graph.html">Graph</a>(400, 400);
// LinePLot dérive de Component
$plot = new <a href="LinePlot.html">LinePlot</a>(array(1, 2, 3));
// Le taille du composant sera 1 / 3 de celle de l'image, soit 133x133 pixels
$plot-&gt;<a href="Component.html#method.setSize">setSize</a>(1 / 3, 1 / 3);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setAbsSize"></a><span class="access">public</span> <a href="Component.html#method.setAbsSize">setAbsSize</a>(<span class="type">int</span> <span class="argument">$w</span>, <span class="type">int</span> <span class="argument">$h</span>)
<div class="description">
Donne une taille absolue au composant.
La largeur $width et la hauteur $height doivent être données en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBackgroundColor"></a><span class="access">public</span> <a href="Component.html#method.setBackgroundColor">setBackgroundColor</a>(<a href="Color.html"><span class="type">Color</span></a> <span class="argument">$color</span>)
<div class="description">
Change la couleur de fond du composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBackgroundGradient"></a><span class="access">public</span> <a href="Component.html#method.setBackgroundGradient">setBackgroundGradient</a>(<a href="Gradient.html"><span class="type">Gradient</span></a> <span class="argument">$gradient</span>)
<div class="description">
Change le dégradé de fond du composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setBackgroundImage"></a><span class="access">public</span> <a href="Component.html#method.setBackgroundImage">setBackgroundImage</a>(<a href="Image.html"><span class="type">Image</span></a> <span class="argument">$image</span>)
<div class="description">
Change l'image de fond du composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.getBackground"></a><span class="access">public</span> <span class="type">mixed</span> <a href="Component.html#method.getBackground">getBackground</a>(<span class="type">int</span> <span class="argument">$type</span>)
<div class="description">
Retourne le fond de l'image. Cela peut être une <a href="Color.html">couleur</a>, un <a href="Gradient.html">dégradé</a> ou encore une <a href="Image.html">image</a>. Si aucun fond n'a été spécifié, cette méthode retourne NULL.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setPadding"></a><span class="access">public</span> <a href="Component.html#method.setPadding">setPadding</a>(<span class="type">int</span> <span class="argument">$left</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$right</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$top</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$bottom</span> := <span class="default">NULL</span>)
<div class="description">
Change l'espace interne du composant.
Les valeurs doivent être données en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setSpace"></a><span class="access">public</span> <a href="Component.html#method.setSpace">setSpace</a>(<span class="type">int</span> <span class="argument">$left</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$right</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$top</span> := <span class="default">NULL</span>, <span class="type">int</span> <span class="argument">$bottom</span> := <span class="default">NULL</span>)
<div class="description">
Change l'espace interne dans la zone de dessin effective du composant. Les valeurs doivent être données en pourcentage de la taille de la zone de dessin.
Le zone de dessin est la zone dans laquelle est dessiné le composant, c'est-à-dire la zone du composant amputée des axes et de l'<a href="Component.html#property.padding">espace interne</a>.
<pre>
&lt;?php
require_once "LinePlot.class.php";
$graph = new <a href="Graph.html">Graph</a>(400, 400);
$plot = new <a href="LinePlot.html">LinePlot</a>(array(43, 23, 65, 37));
$plot-&gt;<a href="Component.html#method.setSpace">setSpace</a>(10, 10, 20, 20);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setCenter"></a><span class="access">public</span> <a href="Component.html#method.setCenter">setCenter</a>(<span class="type">float</span> <span class="argument">$x</span>, <span class="type">float</span> <span class="argument">$y</span>)
<div class="description">
Change la position du centre du composant sur l'image.
Les nouvelles positions $x et $y représentent une fraction des largeur et hauteur de l'image.
Attention, la position 0 pour $y place le centre du composant en haut de l'image. La position 1 le place en bas de l'image.
<pre>
&lt;?php
require_once "LinePlot.class.php";
$graph = new <a href="Graph.html">Graph</a>(400, 400);
// LinePLot dérive de Component
$plot = new <a href="LinePlot.html">LinePlot</a>(array(1, 2, 3));
// Le taille du composant sera 1 / 3 de celle de l'image, soit 133x133 pixels
$plot-&gt;<a href="Component.html#method.setSize">setSize</a>(1 / 3, 1 / 3);
// Place le composant en haut à gauche
$plot-&gt;<a href="Component.html#method.setCenter">setCenter</a>(1 / 6, 1 / 6);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.setAbsPosition"></a><span class="access">public</span> <a href="Component.html#method.setAbsPosition">setAbsPosition</a>(<span class="type">int</span> <span class="argument">$left</span>, <span class="type">int</span> <span class="argument">$top</span>)
<div class="description">
Change la position du composant sur l'image.
Contrairement à <a href="Component.html#method.setCenter">setCenter()</a>, cette méthode ne place pas le composant par rapport à son centre, mais par rapport à son coin haut-gauche. Les positions $left à gauche et $top pour la hauteur doivent être données en pixels.
Attention, la position 0 pour $top place le composant en haut de l'image.
<pre>
&lt;?php
require_once "LinePlot.class.php";
$graph = new <a href="Graph.html">Graph</a>(400, 400);
// LinePLot dérive de Component
$plot = new <a href="LinePlot.html">LinePlot</a>(array(1, 2, 3));
// Le taille du composant sera 1 / 3 de celle de l'image, soit 133x133 pixels
$plot-&gt;<a href="Component.html#method.setSize">setSize</a>(1 / 3, 1 / 3);
// Place le composant en haut à gauche
$plot-&gt;<a href="Component.html#method.setAbsPosition">setAbsPosition</a>(0, 0);
$graph-&gt;<a href="Graph.html#method.add">add</a>($plot);
$graph-&gt;<a href="Graph.html#method.draw">draw</a>();
?&gt;
</pre>
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.init"></a><span class="access">public</span> <a href="Component.html#method.init">init</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
<div class="description">
Initialise le composant avant son affichage.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.finalize"></a><span class="access">public</span> <a href="Component.html#method.finalize">finalize</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
<div class="description">
Finalize l'affichage du composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.getPosition"></a><span class="access">abstract public</span> <span class="type">array</span> <a href="Component.html#method.getPosition">getPosition</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
<div class="description">
Retourne la position de la zone de dessin effective du composant.
Les coordonnées doivent être retournées sous la forme d'un tableau de quatre valeurs.
Les première et deuxième valeurs sont les positions en abscisse et en ordonnée du coin haut-gauche de la zone de dessin.
Les troisième et quatrième valeurs sont les positions en abscisse et en ordonnée du coin bas-droit de la zone de dessin.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.drawEnvelope"></a><span class="access">abstract public</span> <a href="Component.html#method.drawEnvelope">drawEnvelope</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>)
<div class="description">
Dessine l'enveloppe autour de la zone de dessin effective du composant.
Cette enveloppe comprend généralement les axes et la grille du composant.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.drawComponent"></a><span class="access">abstract public</span> <a href="Component.html#method.drawComponent">drawComponent</a>(<a href="Driver.html"><span class="type">Driver</span></a> <span class="argument">$driver</span>, <span class="type">int</span> <span class="argument">$x1</span>, <span class="type">int</span> <span class="argument">$y1</span>, <span class="type">int</span> <span class="argument">$x2</span>, <span class="type">int</span> <span class="argument">$y2</span>, <span class="type">bool</span> <span class="argument">$aliasing</span>)
<div class="description">
Dessine effectivement le composant, c'est-à-dire le graphique.
Le paramètre $aliasing est à TRUE si l'anti-aliasing est activé, FALSE sinon.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.getSpace"></a><span class="access">protected</span> <a href="Component.html#method.getSpace">getSpace</a>(<span class="type">int</span> <span class="argument">$width</span>, <span class="type">int</span> <span class="argument">$height</span>)
<div class="description">
Convertit l'espace interne du composant de pourcentages en pixels, en fonction de la taille $width et de la hauteur $height, exprimées en pixels.
</div>
<div class="description-bottom"><a href="Component.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

View file

@ -0,0 +1,72 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2>
<small>abstract</small> Class ComponentGroup</h2><div class="extends"><ul>
<li><a href="Component.html">Component</a></li>
<ul><li>ComponentGroup</li></ul>
</ul></div><div class="description">
<p>
Un groupe de composant permet de gérer plusieurs <a href="Component.html">composants</a>.
Cette classe est abstraite et doit être redéfinit pour être utilisée avec les composants que vous aurez choisis.
</p>
</div><div class="inherit">
Les classes suivantes dérivent de ComponentGroup :
<ul><li><a href="PlotGroup.html">PlotGroup</a></li></ul>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties"><li>
<span class="access">protected</span> <span class="type">array</span> <a href="ComponentGroup.html#property.components"><span class="argument">$components</span></a>
</li></ul><ul class="methods">
<li>
<span class="access">public</span> <a href="ComponentGroup.html#method.__construct">__construct</a>()
</li>
<li>
<span class="access">public</span> <a href="ComponentGroup.html#method.add">add</a>(<a href="Component.html"><span class="type">Component</span></a> <span class="argument">$component</span>)
</li>
</ul><h2>Documentation</h2><ul class="doc">
<li class="property">
<a id="property.components"></a><span class="access">protected</span> <span class="type">array</span> <a href="ComponentGroup.html#property.components"><span class="argument">$components</span></a><div class="description">
Les <a href="Component.html">composants</a> gérés par ce groupe de composants.
</div>
<div class="description-bottom"><a href="ComponentGroup.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.__construct"></a><span class="access">public</span> <a href="ComponentGroup.html#method.__construct">__construct</a>()
<div class="description">
Construit le groupe de composants.
</div>
<div class="description-bottom"><a href="ComponentGroup.html#top">Remonter</a></div>
</li>
<li class="method">
<a id="method.add"></a><span class="access">public</span> <a href="ComponentGroup.html#method.add">add</a>(<a href="Component.html"><span class="type">Component</span></a> <span class="argument">$component</span>)
<div class="description">
Ajoute le composant $component au groupe.
</div>
<div class="description-bottom"><a href="ComponentGroup.html#top">Remonter</a></div>
</li>
</ul>
</td>
<td class='borderd'>&nbsp;</td>
</tr>
<tr>
<td class='cornerbg'></td>
<td class='borderb'>&nbsp;</td>
<td class='cornerbd'></td>
</tr>
</table>
</div>
</body>
</html>

425
artichow/doc/Drawer.html Normal file
View file

@ -0,0 +1,425 @@
<html>
<head>
<title>Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='style.css' />
</head>
<body>
<div align='center'>
<table cellpadding='0' cellspacing='0' id='contenu' class='round' style='width: 80%; margin-bottom: 20px'>
<tr>
<td class='borderhg'>&nbsp;</td>
<td class='borderh'>&nbsp;</td>
<td class='cornerhd'></td>
</tr>
<tr>
<td class='borderg'>&nbsp;</td>
<td><a id="top"></a><h2> Class Driver</h2><div class="description">
<p>
La classe <a href="Driver.html">Driver</a> est une couche d'abstraction à GD et permet de dessiner toutes sortes de formes géométriques sur une <a href="Image.html">Image</a>.
</p>
<p>
Sur une image, l'axe des abscisses rejoint l'axe des ordonnées sur le coin haut-gauche. Le coin haut-gauche de l'image a donc pour coordonnées (0, 0) et le coin bas-droite (largeur, hauteur). Par exemple, sur une image de largeur 100 et de hauteur 50, un point à 50 sur l'axe des abscisses et 25 sur l'axe des ordonnées sera au centre de l'image.
</p>
</div><ul class="links"><li><a href="index.html">Retourner voir la liste de toutes les classes</a></li></ul><h2>Méthodes et propriétés</h2><ul class="properties">
<li>
<span class="access">public</span> <span class="type">resource</span> <a href="Driver.html#property.resource"><span class="argument">$resource</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Driver.html#property.imageWidth"><span class="argument">$imageWidth</span></a>
</li>
<li>
<span class="access">public</span> <span class="type">int</span> <a href="Driver.html#property.imageHeight"><span class="argument">$imageHeight</span></a>
</li>
<li>
<span class="access">protected</span> <span class="type">bool</span> <a href="Driver.html#property.antiAliasing"><span class="argument">$antiAliasing</span></a> := <span class="default">FALSE</span>
</li>
</ul><ul class="methods">
<li>
<span class="access">public</span> <a href="Driver.html#method.__construct">__construct</a>()
</li>
<li>
<span class="access">public</span> <a href="Driver.html#method.init">init</a>(<a href="Image.html"><span class="type">Image</span></a> <span class="argument">$image</span>)
</li>
<li>
<span class="access">public</span> <a href="Driver.html#method.initFromFile">initFromFile</a>(<a href="FileImage.html"><span class="type">FileImage</span></a> <span class="argument">$fileImage</span>, <span class="type">string</span> <span class="argument">$file</span>)
</li>