com.lokorin.lokorin.lib
[ class tree: com.lokorin.lokorin.lib ] [ index: com.lokorin.lokorin.lib ] [ all elements ]

Class: Graph

Source Location: /_includes/lib_graphs.php

Class Overview


Describes a graph that takes values and then transforms them into a graphical representation as a graph.


Author(s):

  • Andreas Launila

Variables

Methods



Class Details

[line 143]
Describes a graph that takes values and then transforms them into a graphical representation as a graph.



Tags:

author:  Andreas Launila


[ Top ]


Class Variables

$colors =

[line 149]

Holds all the colors that have been loaded into the graph. The name that identifies the color as key, the actual color (RGB array) as value.



Tags:

access:  private

Type:   array


[ Top ]

$functions =

[line 163]

Contains arrays for each function which contain a key 'func' which contains a GraphFunction instance, and a key 'color' which contains the color identifier to use when drawin the function.

displayed in the graph.




Tags:

access:  private

Type:   array


[ Top ]

$scale =

[line 155]

The number of units that each pixel should represent. The array has two keys, 'x' and 'y'.



Tags:

access:  private

Type:   array


[ Top ]

$size =

[line 168]

The size, in pixels, of the graph. The array has two keys, 'x' and 'y'.



Tags:

access:  private

Type:   array


[ Top ]



Class Methods


constructor __construct [line 176]

Graph __construct( [integer $width = 600], [integer $height = 300])

Constructor for Graph.



Tags:

access:  public


Parameters:

integer   $width   The width, in pixels, that the graph should have.
integer   $height   The height, in pixels, that the graph should have.

[ Top ]

method addColor [line 207]

void addColor( string $name, integer $red, integer $green, integer $blue)

Adds a specified color into the graph. Colors have to be loaded before they can be used.



Tags:

access:  public


Parameters:

string   $name   The name that should be connected to the color, any subsequent uses of this color will have to specify this name.
integer   $red   A byte [0-255] representing the amount of red in the color where 0 is none.
integer   $green   A byte [0-255] representing the amount of green in the color where 0 is none.
integer   $blue   A byte [0-255] representing the amount of blue in the color where 0 is none.

[ Top ]

method addFunction [line 220]

void addFunction( string $name, array $function, [string $color = 'black'])

Adds a function that should be displayed in the graph.



Tags:

access:  public


Parameters:

string   $name   The name of the function.
array   $function   A strict function where the key is the function's parameter and the corresponding value is the function's value for the parameter. Both the parameters and key have to be numerical.
string   $color   The identifier for the color that should be used when drawing the function.

[ Top ]

method getGraph [line 270]

image getGraph( [string $backgroundColor = 'white'], [string $axisColor = 'black'], [array $paramMarkers = array()], [array $valueMarkers = array()], [callback $paramNameCallback = ''], [callback $valueNameCallback = ''], [array $viewport = array()], [string $gridColor = 'black'], [boolean $xGrid = false], [boolean $yGrid = false])

Constructs and retrieves an image resource representing the graph.



Tags:

return:  An image resource with the graph on it.
access:  public


Parameters:

string   $backgroundColor   The identifier for the color that should be used for the background. The default is white.
string   $axisColor   The identifier for the color that should be used for the axis. The default is black.
array   $paramMarkers   The parameter values that should be marked and labeled on the axes.
array   $valueMarkers   The function values that should be marked and labeled on the axes.
callback   $paramNameCallback   An optional callback which is used when labeling the parameters.
callback   $valueNameCallback   An optional callback which is used when labeling the values.
array   $viewport   Specifies the viewport for graph. I.e. the minimum and maximum values and paramters that should be allowed in the graph. There are are four keys: 'valMin', 'valMax', 'paramMin', 'paramMax'. I.e. min value, max value, min param and max param.
string   $gridColor   The identifier for the color that should be used for the grids. The default is black.
boolean   $xGrid   True if the x axel should show a grid, false otherwise.
boolean   $yGrid   True if the y axel should show a grid, false otherwise.

[ Top ]

method getHighestParameter [line 407]

numeric getHighestParameter( )

Gets the highest parameter which has a connected value in the graph.



Tags:

return:  A parameter from one of the functions.
access:  private


[ Top ]

method getHighestValue [line 382]

numeric getHighestValue( )

Gets the highest value defined in the graph.



Tags:

return:  A value defined in the graph.
access:  private


[ Top ]

method getLowestParameter [line 395]

numeric getLowestParameter( )

Gets the lowest parameter which has a connected value in the graph.



Tags:

return:  A parameter from one of the functions.
access:  private


[ Top ]

method getLowestValue [line 370]

numeric getLowestValue( )

Gets the lowest value defined in the graph.



Tags:

return:  A value defined in the graph.
access:  private


[ Top ]

method removeFunction [line 231]

void removeFunction( string $name)

Removes all functions with a specified name.



Tags:

access:  public


Parameters:

string   $name   The name of the function(s) that should be removed,

[ Top ]


Documentation generated on Sun, 16 Apr 2006 21:03:33 +0200 by phpDocumentor 1.3.0RC4