Source for file Grid.class.php
Documentation is available at Grid.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";
* @package linea21.externals
* Vertical lines of the grid
* Horizontal lines of the grid
* Is the component grid hidden ?
* Are horizontal lines hidden ?
var $hideHorizontal = FALSE;
* Are vertical lines hidden ?
var $hideVertical = FALSE;
var $interval = array(1, 1);
// Set a grid default color
$this->color = new awColor(210, 210, 210);
$this->background = new awColor(255, 255, 255, 100);
function hide($hide = TRUE) {
$this->hide = (bool) $hide;
* Hide horizontal lines ?
* @param bool $hideHorizontal
$this->hideHorizontal = (bool) $hide;
* @param bool $hideVertical
$this->hideVertical = (bool) $hide;
$this->background = NULL;
* Change grid background color
$this->background = $color;
$this->type = (int) $type;
$this->interval = array((int) $hInterval, (int) $vInterval);
* @param int $left Left space in pixels
* @param int $right Right space in pixels
* @param int $top Top space in pixels
* @param int $bottom Bottom space in pixels
function setSpace($left, $right, $top, $bottom) {
$this->space = array((int) $left, (int) $right, (int) $top, (int) $bottom);
* Change the current grid
* @param array $xgrid Vertical lines
* @param array $ygrid Horizontal lines
if(empty($this->xgrid)) {
if(empty($this->ygrid)) {
* @param $driver A driver object
function draw($driver, $x1, $y1, $x2, $y2) {
if(is_a($this->background, 'awColor')) {
$driver->filledRectangle(
if($this->hide === FALSE) {
$this->hideVertical ? array() : $this->xgrid,
$this->hideHorizontal ? array() : $this->ygrid,
$nx, $ny, $x1, $y1, $x2, $y2,
$type, $space, $hInterval, $vInterval
list ($left, $right, $top, $bottom) = $space;
$width = $x2 - $x1 - $left - $right;
$height = $y2 - $y1 - $top - $bottom;
foreach($nx as $key => $n) {
if(($key % $vInterval) === 0) {
$pos = (int) round($x1 + $left + $n * $width);
foreach($ny as $key => $n) {
if(($key % $hInterval) === 0) {
$pos = (int) round($y1 + $top + $n * $height);
|