Initial Commit of AgileBill Open Source
This commit is contained in:
147
includes/pear/Image/Graph/Dataset/Function.php
Normal file
147
includes/pear/Image/Graph/Dataset/Function.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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 Dataset
|
||||
* @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: Function.php,v 1.7 2005/08/24 20:35:57 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include file Image/Graph/Dataset.php
|
||||
*/
|
||||
require_once 'Image/Graph/Dataset.php';
|
||||
|
||||
/**
|
||||
* Function data set, points are generated by calling an external function.
|
||||
*
|
||||
* The function must be a single variable function and return a the result,
|
||||
* builtin functions that are fx sin() or cos(). User defined function can be
|
||||
* used if they are such, i.e: function myFunction($variable)
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Dataset
|
||||
* @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_Dataset_Function extends Image_Graph_Dataset
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the function
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_dataFunction;
|
||||
|
||||
/**
|
||||
* Image_Graph_FunctionDataset [Constructor]
|
||||
*
|
||||
* @param double $minimumX The minimum X value
|
||||
* @param double $maximumX The maximum X value
|
||||
* @param string $function The name of the function, if must be a single
|
||||
* parameter function like fx sin(x) or cos(x)
|
||||
* @param int $points The number of points to create
|
||||
*/
|
||||
function Image_Graph_Dataset_Function($minimumX, $maximumX, $function, $points)
|
||||
{
|
||||
parent::Image_Graph_Dataset();
|
||||
$this->_minimumX = $minimumX;
|
||||
$this->_maximumX = $maximumX;
|
||||
$this->_dataFunction = $function;
|
||||
$this->_count = $points;
|
||||
$this->_calculateMaxima();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point to the dataset.
|
||||
*
|
||||
* You can't add points to a function dataset
|
||||
*
|
||||
* @param int $x The X value to add
|
||||
* @param int $y The Y value to add, can be omited
|
||||
* @param var $ID The ID of the point
|
||||
*/
|
||||
function addPoint($x, $y = false, $ID = false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Y point from the dataset
|
||||
*
|
||||
* @param var $x The variable to apply the function to
|
||||
* @return var The function applied to the X value
|
||||
* @access private
|
||||
*/
|
||||
function _getPointY($x)
|
||||
{
|
||||
$function = $this->_dataFunction;
|
||||
return $function ($x);
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of values in the dataset
|
||||
*
|
||||
* @return int The number of values in the dataset
|
||||
* @access private
|
||||
*/
|
||||
function _count()
|
||||
{
|
||||
return $this->_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interval between 2 adjacent Y values
|
||||
*
|
||||
* @return var The interval
|
||||
* @access private
|
||||
*/
|
||||
function _stepX()
|
||||
{
|
||||
return ($this->_maximumX - $this->_minimumX) / $this->_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the Y extrema of the function
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _calculateMaxima()
|
||||
{
|
||||
$x = $this->_minimumX;
|
||||
while ($x <= $this->_maximumX) {
|
||||
$y = $this->_getPointY($x);
|
||||
$this->_minimumY = min($y, $this->_minimumY);
|
||||
$this->_maximumY = max($y, $this->_maximumY);
|
||||
$x += $this->_stepX();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
77
includes/pear/Image/Graph/Dataset/Random.php
Normal file
77
includes/pear/Image/Graph/Dataset/Random.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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 Dataset
|
||||
* @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: Random.php,v 1.6 2005/08/24 20:35:57 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include file Image/Graph/Dataset/Trivial.php
|
||||
*/
|
||||
require_once 'Image/Graph/Dataset/Trivial.php';
|
||||
|
||||
/**
|
||||
* Random data set, points are generated by random.
|
||||
*
|
||||
* This dataset is mostly (if not solely) used for demo-purposes.
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Dataset
|
||||
* @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_Dataset_Random extends Image_Graph_Dataset_Trivial
|
||||
{
|
||||
|
||||
/**
|
||||
* RandomDataset [Constructor]
|
||||
*
|
||||
* @param int $count The number of points to create
|
||||
* @param double $minimum The minimum value the random set can be
|
||||
* @param double $maximum The maximum value the random set can be
|
||||
* @param bool $includeZero Whether 0 should be included or not as an X
|
||||
* value, may be omitted, default: false</false>
|
||||
*/
|
||||
function Image_Graph_Dataset_Random($count, $minimum, $maximum, $includeZero = false)
|
||||
{
|
||||
parent::Image_Graph_Dataset_Trivial();
|
||||
$i = 0;
|
||||
while ($i < $count) {
|
||||
$this->addPoint(
|
||||
$ixc = ($includeZero ? $i : $i +1),
|
||||
rand($minimum, $maximum)
|
||||
);
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
114
includes/pear/Image/Graph/Dataset/Sequential.php
Normal file
114
includes/pear/Image/Graph/Dataset/Sequential.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?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 Dataset
|
||||
* @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: Sequential.php,v 1.7 2005/08/24 20:35:58 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include file Image/Graph/Dataset/Trivial.php
|
||||
*/
|
||||
require_once 'Image/Graph/Dataset/Trivial.php';
|
||||
|
||||
/**
|
||||
* Sequential data set, simply add points (y) 1 by 1.
|
||||
*
|
||||
* This is a single point (1D) dataset, all points are of the type (0, y1), (1,
|
||||
* y2), (2, y3)... Where the X-value is implicitly incremented. This is useful
|
||||
* for example for barcharts, where you could fx. use an {@link
|
||||
* Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values.
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Dataset
|
||||
* @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_Dataset_Sequential extends Image_Graph_Dataset_Trivial
|
||||
{
|
||||
|
||||
/**
|
||||
* Image_Graph_SequentialDataset [Constructor]
|
||||
*/
|
||||
function Image_Graph_Dataset_Sequential($dataArray = false)
|
||||
{
|
||||
parent::Image_Graph_Dataset_Trivial();
|
||||
if (is_array($dataArray)) {
|
||||
reset($dataArray);
|
||||
foreach ($dataArray as $value) {
|
||||
$this->addPoint($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point to the dataset
|
||||
*
|
||||
* @param int $y The Y value to add, can be omited
|
||||
* @param var $ID The ID of the point
|
||||
*/
|
||||
function addPoint($y, $ID = false)
|
||||
{
|
||||
parent::addPoint($this->count(), $y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a X point from the dataset
|
||||
*
|
||||
* @param var $x The variable to return an X value from, fx in a
|
||||
* vector function data set
|
||||
* @return var The X value of the variable
|
||||
* @access private
|
||||
*/
|
||||
function _getPointX($x)
|
||||
{
|
||||
return ((int) $x);
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum X value
|
||||
* @return var The minimum X value
|
||||
*/
|
||||
function minimumX()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum X value
|
||||
* @return var The maximum X value
|
||||
*/
|
||||
function maximumX()
|
||||
{
|
||||
return $this->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
260
includes/pear/Image/Graph/Dataset/Trivial.php
Normal file
260
includes/pear/Image/Graph/Dataset/Trivial.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?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 Dataset
|
||||
* @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: Trivial.php,v 1.10 2005/09/25 18:08:56 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include file Image/Graph/Dataset.php
|
||||
*/
|
||||
require_once 'Image/Graph/Dataset.php';
|
||||
|
||||
/**
|
||||
* Trivial data set, simply add points (x, y) 1 by 1
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Dataset
|
||||
* @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_Dataset_Trivial extends Image_Graph_Dataset
|
||||
{
|
||||
|
||||
/**
|
||||
* Data storage
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_data;
|
||||
|
||||
/**
|
||||
* Image_Graph_Dataset_Trivial [Constructor]
|
||||
*
|
||||
* Pass an associated array ($data[$x] = $y) to the constructor for easy
|
||||
* data addition. Alternatively (if multiple entries with same x value is
|
||||
* required) pass an array with (x, y) values: $data[$id] = array('x' => $x,
|
||||
* 'y' => $y);
|
||||
*
|
||||
* NB! If passing the 1st type array at this point, the x-values will also
|
||||
* be used for ID tags, i.e. when using {@link Image_Graph_Fill_Array}. In
|
||||
* the 2nd type the key/index of the "outermost" array will be the id tag
|
||||
* (i.e. $id in the example)
|
||||
*
|
||||
* @param array $dataArray An associated array with values to the dataset
|
||||
*/
|
||||
function Image_Graph_Dataset_Trivial($dataArray = false)
|
||||
{
|
||||
parent::Image_Graph_Dataset();
|
||||
$this->_data = array ();
|
||||
if (is_array($dataArray)) {
|
||||
reset($dataArray);
|
||||
$keys = array_keys($dataArray);
|
||||
foreach ($keys as $x) {
|
||||
$y =& $dataArray[$x];
|
||||
if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) {
|
||||
$this->addPoint($y['x'], $y['y'], (isset($y['id']) ? $y['id'] : $x));
|
||||
} else {
|
||||
$this->addPoint($x, $y, $x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point to the dataset
|
||||
*
|
||||
* $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain
|
||||
* values used for creation of the HTML image map. This is achieved using is an an associated array
|
||||
* with the following values:
|
||||
*
|
||||
* 'url' The URL to create the link to
|
||||
*
|
||||
* 'alt' [optional] The alt text on the link
|
||||
*
|
||||
* 'target' [optional] The target of the link
|
||||
*
|
||||
* 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink'
|
||||
*
|
||||
* @param int $x The X value to add
|
||||
* @param int $y The Y value to add, can be omited
|
||||
* @param var $ID The ID of the point
|
||||
*/
|
||||
function addPoint($x, $y = false, $ID = false)
|
||||
{
|
||||
parent::addPoint($x, $y, $ID);
|
||||
|
||||
if (is_array($ID)) {
|
||||
$data = $ID;
|
||||
$ID = (isset($data['id']) ? $data['id'] : false);
|
||||
} else {
|
||||
$data = false;
|
||||
}
|
||||
|
||||
$this->_data[] = array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
|
||||
if (!is_numeric($x)) {
|
||||
$this->_maximumX = count($this->_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The first point
|
||||
*
|
||||
* @return array The last point
|
||||
*/
|
||||
function first()
|
||||
{
|
||||
reset($this->_data);
|
||||
return current($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* The last point
|
||||
*
|
||||
* @return array The first point
|
||||
*/
|
||||
function last()
|
||||
{
|
||||
return end($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a X point from the dataset
|
||||
*
|
||||
* @param var $x The variable to return an X value from, fx in a
|
||||
* vector function data set
|
||||
* @return var The X value of the variable
|
||||
* @access private
|
||||
*/
|
||||
function _getPointX($x)
|
||||
{
|
||||
if (isset($this->_data[$x])) {
|
||||
return $this->_data[$x]['X'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Y point from the dataset
|
||||
*
|
||||
* @param var $x The variable to return an Y value from, fx in a
|
||||
* vector function data set
|
||||
* @return var The Y value of the variable
|
||||
* @access private
|
||||
*/
|
||||
function _getPointY($x)
|
||||
{
|
||||
if (isset($this->_data[$x])) {
|
||||
return $this->_data[$x]['Y'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a ID from the dataset
|
||||
*
|
||||
* @param var $x The variable to return an Y value from, fx in a
|
||||
* vector function data set
|
||||
* @return var The ID value of the variable
|
||||
* @access private
|
||||
*/
|
||||
function _getPointID($x)
|
||||
{
|
||||
if (isset($this->_data[$x])) {
|
||||
return $this->_data[$x]['ID'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets point data from the dataset
|
||||
*
|
||||
* @param var $x The variable to return an Y value from, fx in a vector
|
||||
* function data set
|
||||
* @return array The data for the point
|
||||
* @access private
|
||||
*/
|
||||
function _getPointData($x)
|
||||
{
|
||||
if (isset($this->_data[$x])) {
|
||||
return $this->_data[$x]['data'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of values in the dataset
|
||||
*
|
||||
* @return int The number of values in the dataset
|
||||
*/
|
||||
function count()
|
||||
{
|
||||
return count($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the intertal dataset pointer
|
||||
*
|
||||
* @return var The first X value
|
||||
* @access private
|
||||
*/
|
||||
function _reset()
|
||||
{
|
||||
$this->_posX = 0;
|
||||
return $this->_posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next point the internal pointer refers to and advance the pointer
|
||||
*
|
||||
* @return array The next point
|
||||
* @access private
|
||||
*/
|
||||
function _next()
|
||||
{
|
||||
if ($this->_posX >= $this->count()) {
|
||||
return false;
|
||||
}
|
||||
$x = $this->_getPointX($this->_posX);
|
||||
$y = $this->_getPointY($this->_posX);
|
||||
$ID = $this->_getPointID($this->_posX);
|
||||
$data = $this->_getPointData($this->_posX);
|
||||
$this->_posX += $this->_stepX();
|
||||
|
||||
return array('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
185
includes/pear/Image/Graph/Dataset/VectorFunction.php
Normal file
185
includes/pear/Image/Graph/Dataset/VectorFunction.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?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 Dataset
|
||||
* @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: VectorFunction.php,v 1.6 2005/08/24 20:35:57 nosey Exp $
|
||||
* @link http://pear.php.net/package/Image_Graph
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include file Image/Graph/Dataset.php
|
||||
*/
|
||||
require_once 'Image/Graph/Dataset.php';
|
||||
|
||||
/**
|
||||
* Vector Function data set.
|
||||
*
|
||||
* Points are generated by calling 2 external functions, fx. x = sin(t) and y =
|
||||
* cos(t)
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Graph
|
||||
* @subpackage Dataset
|
||||
* @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_Dataset_VectorFunction extends Image_Graph_Dataset
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the X function
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_functionX;
|
||||
|
||||
/**
|
||||
* The name of the Y function
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_functionY;
|
||||
|
||||
/**
|
||||
* The minimum of the vector function variable
|
||||
* @var double
|
||||
* @access private
|
||||
*/
|
||||
var $_minimumT;
|
||||
|
||||
/**
|
||||
* The maximum of the vector function variable
|
||||
* @var double
|
||||
* @access private
|
||||
*/
|
||||
var $_maximumT;
|
||||
|
||||
/**
|
||||
* Image_Graph_VectorFunctionDataset [Constructor]
|
||||
*
|
||||
* @param double $minimumT The minimum value of the vector function variable
|
||||
* @param double $maximumT The maximum value of the vector function variable
|
||||
* @param string $functionX The name of the X function, if must be a single
|
||||
* parameter function like fx sin(x) or cos(x)
|
||||
* @param string $functionY The name of the Y function, if must be a single
|
||||
* parameter function like fx sin(x) or cos(x)
|
||||
* @param int $points The number of points to create
|
||||
*/
|
||||
function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points)
|
||||
{
|
||||
parent::Image_Graph_Dataset();
|
||||
$this->_minimumT = $minimumT;
|
||||
$this->_maximumT = $maximumT;
|
||||
$this->_functionX = $functionX;
|
||||
$this->_functionY = $functionY;
|
||||
$this->_count = $points;
|
||||
$this->_calculateMaxima();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point to the dataset
|
||||
*
|
||||
* @param int $x The X value to add
|
||||
* @param int $y The Y value to add, can be omited
|
||||
* @param var $ID The ID of the point
|
||||
*/
|
||||
function addPoint($x, $y = false, $ID = false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a X point from the dataset
|
||||
*
|
||||
* @param var $x The variable to apply the X function to
|
||||
* @return var The X function applied to the X value
|
||||
* @access private
|
||||
*/
|
||||
function _getPointX($x)
|
||||
{
|
||||
$functionX = $this->_functionX;
|
||||
return $functionX ($x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Y point from the dataset
|
||||
*
|
||||
* @param var $x The variable to apply the Y function to
|
||||
* @return var The Y function applied to the X value
|
||||
* @access private
|
||||
*/
|
||||
function _getPointY($x)
|
||||
{
|
||||
$functionY = $this->_functionY;
|
||||
return $functionY ($x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the intertal dataset pointer
|
||||
*
|
||||
* @return var The first T value
|
||||
* @access private
|
||||
*/
|
||||
function _reset()
|
||||
{
|
||||
$this->_posX = $this->_minimumT;
|
||||
return $this->_posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interval between 2 adjacent T values
|
||||
*
|
||||
* @return var The interval
|
||||
* @access private
|
||||
*/
|
||||
function _stepX()
|
||||
{
|
||||
return ($this->_maximumT - $this->_minimumT) / $this->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the X and Y extrema of the functions
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _calculateMaxima()
|
||||
{
|
||||
$t = $this->_minimumT;
|
||||
while ($t <= $this->_maximumT) {
|
||||
$x = $this->_getPointX($t);
|
||||
$y = $this->_getPointY($t);
|
||||
$this->_minimumX = min($x, $this->_minimumX);
|
||||
$this->_maximumX = max($x, $this->_maximumX);
|
||||
$this->_minimumY = min($y, $this->_minimumY);
|
||||
$this->_maximumY = max($y, $this->_maximumY);
|
||||
$t += $this->_stepX();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user