Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.

Removed PHP_Compat, and references to it.
Removed ionCube/Zend/mmCache compatibility checks in test.php script.
Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
anubis
2009-01-04 19:22:54 -05:00
parent 60b674c776
commit fae6352bf2
384 changed files with 34150 additions and 44524 deletions

View File

@@ -1,87 +1,87 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Element.php,v 1.5 2005/02/21 20:50:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Representation of a element on a plotarea.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Plotarea_Element extends Image_Graph_Element
{
/**
* Get the X pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($point)
{
return $this->_parent->_pointX($point);
}
/**
* Get the Y pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($point)
{
return $this->_parent->_pointY($point);
}
/**
* Get the X and Y pixel position represented by a value
*
* @param array $point the values to get the pixel-point for
* @return array The (x, y) pixel position along the axis
* @access private
*/
function _pointXY($point)
{
return array ('X' => $this->_pointX($point), 'Y' => $this->_pointY($point));
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Element.php,v 1.5 2005/02/21 20:50:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Representation of a element on a plotarea.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Plotarea_Element extends Image_Graph_Element
{
/**
* Get the X pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($point)
{
return $this->_parent->_pointX($point);
}
/**
* Get the Y pixel position represented by a value
*
* @param double $point the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($point)
{
return $this->_parent->_pointY($point);
}
/**
* Get the X and Y pixel position represented by a value
*
* @param array $point the values to get the pixel-point for
* @return array The (x, y) pixel position along the axis
* @access private
*/
function _pointXY($point)
{
return array ('X' => $this->_pointX($point), 'Y' => $this->_pointY($point));
}
}
?>

View File

@@ -1,304 +1,304 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Map.php,v 1.9 2005/08/24 20:36:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea.php
*/
require_once 'Image/Graph/Plotarea.php';
/**
* Plot area used for map plots.
*
* A map plot is a chart that displays a map (fx. a world map) in the form of .
* png file. The maps must be located in the /Images/Maps folder and a
* corresponding .txt files mush also exist in this location where named
* locations are mapped to an (x, y) coordinate of the map picture (this text
* file is tab separated with 'Name' 'X' 'Y' values, fx 'Denmark 378 223'). The
* x-values in the dataset are then the named locations (fx 'Denmark') and the
* y-values are then the data to plot. Currently the best (if not only) use is
* to combine a map plot area with a {@link Image_Graph_Plot_Dot} using {@link
* Image_Graph_Marker_PercentageCircle} as marker.
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plotarea_Map extends Image_Graph_Plotarea
{
/**
* The GD image for the map
* @var string
* @access private
*/
var $_imageMap;
/**
* The value for scaling the width and height to fit into the layout boundaries
* @var int
* @access private
*/
var $_scale;
/**
* The (x,y)-points for the named point
* @var array
* @access private
*/
var $_mapPoints;
/**
* The original size of the image map
* @var array
* @access private
*/
var $_mapSize;
/**
* PlotareaMap [Constructor]
*
* @param string $map The name of the map, i.e. the [name].png and [name].
* txt files located in the Images/maps folder
*/
function Image_Graph_Plotarea_Map($map)
{
parent::Image_Graph_Plotarea();
$this->_imageMap = dirname(__FILE__)."/../Images/Maps/$map.png";
$points = file(dirname(__FILE__)."/../Images/Maps/$map.txt");
list($width, $height) = getimagesize($this->_imageMap);
$this->_mapSize['X'] = $width;
$this->_mapSize['Y'] = $height;
if (is_array($points)) {
unset($this->_mapPoints);
foreach ($points as $line) {
list($country, $x, $y) = explode("\t", $line);
$this->_mapPoints[$country] = array('X' => $x, 'Y' => $y);
}
}
}
/**
* Left boundary of the background fill area
*
* @return int Leftmost position on the canvas
* @access private
*/
function _fillLeft()
{
return $this->_left + $this->_padding;
}
/**
* Top boundary of the background fill area
*
* @return int Topmost position on the canvas
* @access private
*/
function _fillTop()
{
return $this->_top + $this->_padding;
}
/**
* Right boundary of the background fill area
*
* @return int Rightmost position on the canvas
* @access private
*/
function _fillRight()
{
return $this->_right - $this->_padding;
}
/**
* Bottom boundary of the background fill area
*
* @return int Bottommost position on the canvas
* @access private
*/
function _fillBottom()
{
return $this->_bottom - $this->_padding;
}
/**
* Set the extrema of the axis
*
* @param Image_Graph_Plot $plot The plot that 'hold' the values
* @access private
*/
function _setExtrema(& $plot)
{
}
/**
* Get the X pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($value)
{
$country = $value['X'];
return $this->_plotLeft+$this->_mapPoints[$country]['X']*$this->_scale;
}
/**
* Get the Y pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($value)
{
$country = $value['X'];
return $this->_plotTop+$this->_mapPoints[$country]['Y']*$this->_scale;
}
/**
* Hides the axis
*/
function hideAxis()
{
}
/**
* Add a point to the maps
*
* @param int $latitude The latitude of the point
* @param int $longiude The longitude of the point
* @param string $name The name of the plot
*/
function addMappoint($latitude, $longitude, $name)
{
$x = (($longitude + 180) * ($this->_mapSize['X'] / 360));
$y = ((($latitude * -1) + 90) * ($this->_mapSize['Y'] / 180));
$this->_mapPoints[$name] = array('X' => $x, 'Y' => $y);
}
/**
* Add a point to the maps
*
* @param int $x The latitude of the point
* @param int $y The longitude of the point
* @param string $name The name of the plot
*/
function addPoint($x, $y, $name)
{
$this->_mapPoints[$name] = array('X' => $x, 'Y' => $y);
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
parent::_updateCoords();
$mapAspectRatio = $this->_mapSize['X']/$this->_mapSize['Y'];
$plotAspectRatio = ($width = $this->_fillWidth())/($height = $this->_fillHeight());
$scaleFactorX = ($mapAspectRatio > $plotAspectRatio);
if ((($this->_mapSize['X'] <= $width) && ($this->_mapSize['Y'] <= $height)) ||
(($this->_mapSize['X'] >= $width) && ($this->_mapSize['Y'] >= $height)))
{
if ($scaleFactorX) {
$this->_scale = $width / $this->_mapSize['X'];
} else {
$this->_scale = $height / $this->_mapSize['Y'];
}
} elseif ($this->_mapSize['X'] < $width) {
$this->_scale = $height / $this->_mapSize['Y'];
} elseif ($this->_mapSize['Y'] < $height) {
$this->_scale = $width / $this->_mapSize['X'];
}
$this->_plotLeft = ($this->_fillLeft() + $this->_fillRight() -
$this->_mapSize['X']*$this->_scale)/2;
$this->_plotTop = ($this->_fillTop() + $this->_fillBottom() -
$this->_mapSize['Y']*$this->_scale)/2;
$this->_plotRight = ($this->_fillLeft() + $this->_fillRight() +
$this->_mapSize['X']*$this->_scale)/2;
$this->_plotBottom = ($this->_fillTop() + $this->_fillBottom() +
$this->_mapSize['Y']*$this->_scale)/2;
}
/**
* Output the plotarea to the canvas
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$this->_getFillStyle();
$this->_canvas->rectangle(
array(
'x0' => $this->_fillLeft(),
'y0' => $this->_fillTop(),
'x1' => $this->_fillRight(),
'y1' => $this->_fillBottom()
)
);
$scaledWidth = $this->_mapSize['X']*$this->_scale;
$scaledHeight = $this->_mapSize['Y']*$this->_scale;
$this->_canvas->image(
array(
'x' => $this->_plotLeft,
'y' => $this->_plotTop,
'filename' => $this->_imageMap,
'width' => $scaledWidth,
'height' => $scaledHeight
)
);
return Image_Graph_Layout::_done();
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Map.php,v 1.10 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea.php
*/
require_once 'Image/Graph/Plotarea.php';
/**
* Plot area used for map plots.
*
* A map plot is a chart that displays a map (fx. a world map) in the form of .
* png file. The maps must be located in the /Images/Maps folder and a
* corresponding .txt files mush also exist in this location where named
* locations are mapped to an (x, y) coordinate of the map picture (this text
* file is tab separated with 'Name' 'X' 'Y' values, fx 'Denmark 378 223'). The
* x-values in the dataset are then the named locations (fx 'Denmark') and the
* y-values are then the data to plot. Currently the best (if not only) use is
* to combine a map plot area with a {@link Image_Graph_Plot_Dot} using {@link
* Image_Graph_Marker_PercentageCircle} as marker.
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plotarea_Map extends Image_Graph_Plotarea
{
/**
* The GD image for the map
* @var string
* @access private
*/
var $_imageMap;
/**
* The value for scaling the width and height to fit into the layout boundaries
* @var int
* @access private
*/
var $_scale;
/**
* The (x,y)-points for the named point
* @var array
* @access private
*/
var $_mapPoints;
/**
* The original size of the image map
* @var array
* @access private
*/
var $_mapSize;
/**
* PlotareaMap [Constructor]
*
* @param string $map The name of the map, i.e. the [name].png and [name].
* txt files located in the Images/maps folder
*/
function Image_Graph_Plotarea_Map($map)
{
parent::Image_Graph_Plotarea();
$this->_imageMap = dirname(__FILE__)."/../Images/Maps/$map.png";
$points = file(dirname(__FILE__)."/../Images/Maps/$map.txt");
list($width, $height) = getimagesize($this->_imageMap);
$this->_mapSize['X'] = $width;
$this->_mapSize['Y'] = $height;
if (is_array($points)) {
unset($this->_mapPoints);
foreach ($points as $line) {
list($country, $x, $y) = explode("\t", $line);
$this->_mapPoints[$country] = array('X' => $x, 'Y' => $y);
}
}
}
/**
* Left boundary of the background fill area
*
* @return int Leftmost position on the canvas
* @access private
*/
function _fillLeft()
{
return $this->_left + $this->_padding['left'];
}
/**
* Top boundary of the background fill area
*
* @return int Topmost position on the canvas
* @access private
*/
function _fillTop()
{
return $this->_top + $this->_padding['top'];
}
/**
* Right boundary of the background fill area
*
* @return int Rightmost position on the canvas
* @access private
*/
function _fillRight()
{
return $this->_right - $this->_padding['right'];
}
/**
* Bottom boundary of the background fill area
*
* @return int Bottommost position on the canvas
* @access private
*/
function _fillBottom()
{
return $this->_bottom - $this->_padding['bottom'];
}
/**
* Set the extrema of the axis
*
* @param Image_Graph_Plot $plot The plot that 'hold' the values
* @access private
*/
function _setExtrema(& $plot)
{
}
/**
* Get the X pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($value)
{
$country = $value['X'];
return $this->_plotLeft+$this->_mapPoints[$country]['X']*$this->_scale;
}
/**
* Get the Y pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($value)
{
$country = $value['X'];
return $this->_plotTop+$this->_mapPoints[$country]['Y']*$this->_scale;
}
/**
* Hides the axis
*/
function hideAxis()
{
}
/**
* Add a point to the maps
*
* @param int $latitude The latitude of the point
* @param int $longiude The longitude of the point
* @param string $name The name of the plot
*/
function addMappoint($latitude, $longitude, $name)
{
$x = (($longitude + 180) * ($this->_mapSize['X'] / 360));
$y = ((($latitude * -1) + 90) * ($this->_mapSize['Y'] / 180));
$this->_mapPoints[$name] = array('X' => $x, 'Y' => $y);
}
/**
* Add a point to the maps
*
* @param int $x The latitude of the point
* @param int $y The longitude of the point
* @param string $name The name of the plot
*/
function addPoint($x, $y, $name)
{
$this->_mapPoints[$name] = array('X' => $x, 'Y' => $y);
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
parent::_updateCoords();
$mapAspectRatio = $this->_mapSize['X']/$this->_mapSize['Y'];
$plotAspectRatio = ($width = $this->_fillWidth())/($height = $this->_fillHeight());
$scaleFactorX = ($mapAspectRatio > $plotAspectRatio);
if ((($this->_mapSize['X'] <= $width) && ($this->_mapSize['Y'] <= $height)) ||
(($this->_mapSize['X'] >= $width) && ($this->_mapSize['Y'] >= $height)))
{
if ($scaleFactorX) {
$this->_scale = $width / $this->_mapSize['X'];
} else {
$this->_scale = $height / $this->_mapSize['Y'];
}
} elseif ($this->_mapSize['X'] < $width) {
$this->_scale = $height / $this->_mapSize['Y'];
} elseif ($this->_mapSize['Y'] < $height) {
$this->_scale = $width / $this->_mapSize['X'];
}
$this->_plotLeft = ($this->_fillLeft() + $this->_fillRight() -
$this->_mapSize['X']*$this->_scale)/2;
$this->_plotTop = ($this->_fillTop() + $this->_fillBottom() -
$this->_mapSize['Y']*$this->_scale)/2;
$this->_plotRight = ($this->_fillLeft() + $this->_fillRight() +
$this->_mapSize['X']*$this->_scale)/2;
$this->_plotBottom = ($this->_fillTop() + $this->_fillBottom() +
$this->_mapSize['Y']*$this->_scale)/2;
}
/**
* Output the plotarea to the canvas
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$this->_getFillStyle();
$this->_canvas->rectangle(
array(
'x0' => $this->_fillLeft(),
'y0' => $this->_fillTop(),
'x1' => $this->_fillRight(),
'y1' => $this->_fillBottom()
)
);
$scaledWidth = $this->_mapSize['X']*$this->_scale;
$scaledHeight = $this->_mapSize['Y']*$this->_scale;
$this->_canvas->image(
array(
'x' => $this->_plotLeft,
'y' => $this->_plotTop,
'filename' => $this->_imageMap,
'width' => $scaledWidth,
'height' => $scaledHeight
)
);
return Image_Graph_Layout::_done();
}
}
?>

View File

@@ -1,243 +1,243 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.7 2005/08/24 20:36:02 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea.php
*/
require_once 'Image/Graph/Plotarea.php';
/**
* Plot area used for radar plots.
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plotarea_Radar extends Image_Graph_Plotarea
{
/**
* Create the plotarea, implicitely creates 2 normal axis
*/
function Image_Graph_Plotarea_Radar()
{
parent::Image_Graph_Element();
$this->_padding = 10;
$this->_axisX =& Image_Graph::factory('Image_Graph_Axis_Radar');
$this->_axisX->_setParent($this);
$this->_axisY =& Image_Graph::factory('Image_Graph_Axis', IMAGE_GRAPH_AXIS_Y);
$this->_axisY->_setParent($this);
$this->_axisY->_setMinimum(0);
}
/**
* Get the width of the 'real' plotarea
*
* @return int The width of the 'real' plotarea, ie not including space occupied by padding and axis
* @access private
*/
function _plotWidth()
{
return (min($this->height(), $this->width())) * 0.80;
}
/**
* Get the height of the 'real' plotarea
*
* @return int The height of the 'real' plotarea, ie not including space occupied by padding and axis
* @access private
*/
function _plotHeight()
{
return (min($this->height(), $this->width())) * 0.80;
}
/**
* Left boundary of the background fill area
*
* @return int Leftmost position on the canvas
* @access private
*/
function _fillLeft()
{
return (int) (($this->_left + $this->_right - $this->_plotWidth()) / 2);
}
/**
* Top boundary of the background fill area
*
* @return int Topmost position on the canvas
* @access private
*/
function _fillTop()
{
return (int) (($this->_top + $this->_bottom - $this->_plotHeight()) / 2);
}
/**
* Right boundary of the background fill area
*
* @return int Rightmost position on the canvas
* @access private
*/
function _fillRight()
{
return (int) (($this->_left + $this->_right + $this->_plotWidth()) / 2);
}
/**
* Bottom boundary of the background fill area
*
* @return int Bottommost position on the canvas
* @access private
*/
function _fillBottom()
{
return (int) (($this->_top + $this->_bottom + $this->_plotHeight()) / 2);
}
/**
* Get the X pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($value)
{
if (is_array($value)) {
if ($value['Y'] == '#min#') {
$radius = 0;
} elseif (($value['Y'] == '#max#') || ($value['Y'] === false)) {
$radius = 1;
} else {
$radius = ($value['Y'] - $this->_axisY->_getMinimum()) /
($this->_axisY->_getMaximum() - $this->_axisY->_getMinimum());
}
$x = ($this->_left + $this->_right) / 2 -
$radius * ($this->_plotWidth() / 2) *
cos(deg2rad($this->_axisX->_point($value['X'])));
}
return max($this->_plotLeft, min($this->_plotRight, $x));
}
/**
* Get the Y pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($value)
{
if (is_array($value)) {
if ($value['Y'] == '#min#') {
$radius = 0;
} elseif (($value['Y'] == '#max#') || ($value['Y'] === false)) {
$radius = 1;
} else {
$radius = ($value['Y'] - $this->_axisY->_getMinimum()) /
($this->_axisY->_getMaximum() - $this->_axisY->_getMinimum());
}
$y = ($this->_top + $this->_bottom) / 2 -
$radius * ($this->_plotHeight() / 2) *
sin(deg2rad($this->_axisX->_point($value['X'])));
}
return max($this->_plotTop, min($this->_plotBottom, $y));
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
$element =& $this->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$this->_setExtrema($element);
}
}
unset($keys);
}
$this->_calcEdges();
$centerX = (int) (($this->_left + $this->_right) / 2);
$centerY = (int) (($this->_top + $this->_bottom) / 2);
$radius = min($this->_plotHeight(), $this->_plotWidth()) / 2;
if (is_object($this->_axisX)) {
$this->_axisX->_setCoords(
$centerX - $radius,
$centerY - $radius,
$centerX + $radius,
$centerY + $radius
);
}
if (is_object($this->_axisY)) {
$this->_axisY->_setCoords(
$centerX,
$centerY,
$centerX - $radius,
$centerY - $radius
);
}
$this->_plotLeft = $this->_fillLeft();
$this->_plotTop = $this->_fillTop();
$this->_plotRight = $this->_fillRight();
$this->_plotBottom = $this->_fillBottom();
Image_Graph_Element::_updateCoords();
if (is_object($this->_axisX)) {
$this->_axisX->_updateCoords();
}
if (is_object($this->_axisY)) {
$this->_axisY->_updateCoords();
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.8 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Plotarea.php
*/
require_once 'Image/Graph/Plotarea.php';
/**
* Plot area used for radar plots.
*
* @category Images
* @package Image_Graph
* @subpackage Plotarea
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Plotarea_Radar extends Image_Graph_Plotarea
{
/**
* Create the plotarea, implicitely creates 2 normal axis
*/
function Image_Graph_Plotarea_Radar()
{
parent::Image_Graph_Element();
$this->_padding = array('left' => 10, 'top' => 10, 'right' => 10, 'bottom' => 10);
$this->_axisX =& Image_Graph::factory('Image_Graph_Axis_Radar');
$this->_axisX->_setParent($this);
$this->_axisY =& Image_Graph::factory('Image_Graph_Axis', IMAGE_GRAPH_AXIS_Y);
$this->_axisY->_setParent($this);
$this->_axisY->_setMinimum(0);
}
/**
* Get the width of the 'real' plotarea
*
* @return int The width of the 'real' plotarea, ie not including space occupied by padding and axis
* @access private
*/
function _plotWidth()
{
return (min($this->height(), $this->width())) * 0.80;
}
/**
* Get the height of the 'real' plotarea
*
* @return int The height of the 'real' plotarea, ie not including space occupied by padding and axis
* @access private
*/
function _plotHeight()
{
return (min($this->height(), $this->width())) * 0.80;
}
/**
* Left boundary of the background fill area
*
* @return int Leftmost position on the canvas
* @access private
*/
function _fillLeft()
{
return (int) (($this->_left + $this->_right - $this->_plotWidth()) / 2);
}
/**
* Top boundary of the background fill area
*
* @return int Topmost position on the canvas
* @access private
*/
function _fillTop()
{
return (int) (($this->_top + $this->_bottom - $this->_plotHeight()) / 2);
}
/**
* Right boundary of the background fill area
*
* @return int Rightmost position on the canvas
* @access private
*/
function _fillRight()
{
return (int) (($this->_left + $this->_right + $this->_plotWidth()) / 2);
}
/**
* Bottom boundary of the background fill area
*
* @return int Bottommost position on the canvas
* @access private
*/
function _fillBottom()
{
return (int) (($this->_top + $this->_bottom + $this->_plotHeight()) / 2);
}
/**
* Get the X pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointX($value)
{
if (is_array($value)) {
if ($value['Y'] == '#min#') {
$radius = 0;
} elseif (($value['Y'] == '#max#') || ($value['Y'] === false)) {
$radius = 1;
} else {
$radius = ($value['Y'] - $this->_axisY->_getMinimum()) /
($this->_axisY->_getMaximum() - $this->_axisY->_getMinimum());
}
$x = ($this->_left + $this->_right) / 2 -
$radius * ($this->_plotWidth() / 2) *
cos(deg2rad($this->_axisX->_point($value['X'])));
}
return max($this->_plotLeft, min($this->_plotRight, $x));
}
/**
* Get the Y pixel position represented by a value
*
* @param double $value The value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _pointY($value)
{
if (is_array($value)) {
if ($value['Y'] == '#min#') {
$radius = 0;
} elseif (($value['Y'] == '#max#') || ($value['Y'] === false)) {
$radius = 1;
} else {
$radius = ($value['Y'] - $this->_axisY->_getMinimum()) /
($this->_axisY->_getMaximum() - $this->_axisY->_getMinimum());
}
$y = ($this->_top + $this->_bottom) / 2 -
$radius * ($this->_plotHeight() / 2) *
sin(deg2rad($this->_axisX->_point($value['X'])));
}
return max($this->_plotTop, min($this->_plotBottom, $y));
}
/**
* Update coordinates
*
* @access private
*/
function _updateCoords()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
$element =& $this->_elements[$key];
if (is_a($element, 'Image_Graph_Plot')) {
$this->_setExtrema($element);
}
}
unset($keys);
}
$this->_calcEdges();
$centerX = (int) (($this->_left + $this->_right) / 2);
$centerY = (int) (($this->_top + $this->_bottom) / 2);
$radius = min($this->_plotHeight(), $this->_plotWidth()) / 2;
if (is_object($this->_axisX)) {
$this->_axisX->_setCoords(
$centerX - $radius,
$centerY - $radius,
$centerX + $radius,
$centerY + $radius
);
}
if (is_object($this->_axisY)) {
$this->_axisY->_setCoords(
$centerX,
$centerY,
$centerX - $radius,
$centerY - $radius
);
}
$this->_plotLeft = $this->_fillLeft();
$this->_plotTop = $this->_fillTop();
$this->_plotRight = $this->_fillRight();
$this->_plotBottom = $this->_fillBottom();
Image_Graph_Element::_updateCoords();
if (is_object($this->_axisX)) {
$this->_axisX->_updateCoords();
}
if (is_object($this->_axisY)) {
$this->_axisY->_updateCoords();
}
}
}
?>