Source for file Component.class.php
Documentation is available at Component.class.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 linea21.externals
* Components of this group
* Build the component group
function awComponentGroup() {
* Add a component to the group
* @param &$component A component
function add(&$component) {
* Position X of the center the graph (from 0 to 1)
* Position Y of the center the graph (from 0 to 1)
* Component absolute width (in pixels)
* Component absolute height (in pixels)
* Left-top corner Y position
* Left-top corner X position
* Component background color
* Adjust automatically the component ?
* Adjust automatically the component ?
$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)
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)
* Change component background color
* @param $color (can be null)
if($color === NULL or is_a($color, 'awColor')) {
* Change component background gradient
* @param $gradient (can be null)
if($gradient === NULL or is_a($gradient, 'awGradient')) {
* Change component background image
* @param &$image (can be null)
if($image === NULL or is_a($image, 'awImage')) {
* Return the component background
* @return Color, Gradient
* 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)
function setPadding($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) {
$this->padding->set($left, $right, $top, $bottom);
* @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)
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
$this->left = (int) $left;
* 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
* Get component coords with its padding
* @return array Coords of the component
$y2 = $this->h - $this->padding->bottom;
return array($x1, $y1, $x2, $y2);
* Init the drawing of the component
// Set component background
if($background !== NULL) {
$p2 = new awPoint($this->w - 1, $this->h - 1);
if(is_a($background, 'awImage')) {
$driver->filledRectangle(
* Finalize the drawing of the component
$this->title->draw($driver, $point);
* Draw the grid around your component
* @return array Coords for the component
* Draw the component on the graph
* Component should be drawed into specified coords
* @param bool $aliasing Use anti-aliasing to draw the component ?
* Get space width in pixels
* @param int $width Component width
* @param int $height Component 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);
|