Apache Zeta Components - high quality PHP components

Apache Zeta Components Manual :: Docs For Class ezcGraphDriver

Graph::ezcGraphDriver

Class ezcGraphDriver

Abstract class to be extended for ezcGraph output drivers.

Source for this file: /Graph/src/interfaces/driver.php

Version:   //autogentag//

Descendants

Child Class Description
ezcGraphFlashDriver Driver to create Flash4 (SWF) files as graph output. The options of this class are defined in The options of this class are defined in the option class ezcGraphFlashDriverOptions extending the basic ezcGraphDriverOptions.
ezcGraphCairoOODriver Extension of the basic driver package to utilize the cairo library.
ezcGraphSvgDriver Extension of the basic Driver package to utilize the SVGlib.
ezcGraphGdDriver Driver using PHPs ext/gd to draw images. The GD extension is available on nearly all PHP installations, but slow and produces slightly incorrect results.
ezcGraphCairoDriver Extension of the basic driver package to utilize the cairo library.

Member Variables

protected ezcDriverOptions $options
Driveroptions

Method Summary

public abstract void drawCircle( $center , $width , $height , $color , [ $filled = true] )
Draw circle
public abstract void drawCircleSector( $center , $width , $height , $startAngle , $endAngle , $color , [ $filled = true] )
Draws a sector of cirlce
public abstract void drawCircularArc( $center , $width , $height , $size , $startAngle , $endAngle , $color , [ $filled = true] )
Draws a circular arc
public abstract void drawImage( $file , $position , $width , $height )
Draw an image
public abstract void drawLine( $start , $end , $color , [ $thickness = 1.] )
Draws a line
public abstract void drawPolygon( $points , $color , [ $filled = true] , [ $thickness = 1.] )
Draws a single polygon.
public abstract void drawTextBox( $string , $position , $width , $height , $align , [ $rotation = null] )
Writes text in a box of desired size
public abstract string getMimeType( )
Return mime type for current image format
protected abstract ezcGraphBoundings getTextBoundings( $size , $font , $text )
Returns boundings of text depending on the available font extension
protected array reduceEllipseSize( $center , $width , $height , $startAngle , $endAngle , $size )
Reduce the size of an ellipse
protected array( reducePolygonSize( $points , $size )
Reduces the size of a polygon
public abstract void render( $file )
Finally save image
public void renderToOutput( )
Render image directly to output
protected mixed testFitStringInTextBox( $string , $position , $width , $height , $size )
Test if string fits in a box with given font size
protected void tryFitShortenedString( $string , $position , $width , $height , $size )
If it is allow to shortened the string, this method tries to extract as many chars as possible to display a decent amount of characters.

Methods

drawCircle

void drawCircle( ezcGraphCoordinate $center , mixed $width , mixed $height , ezcGraphColor $color , [mixed $filled = true] )

Draw circle

Parameters:
Name Type Description
$center ezcGraphCoordinate Center of ellipse
$width mixed Width of ellipse
$height mixed height of ellipse
$color ezcGraphColor Color
$filled mixed Filled
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawCircle() Draw circle 
ezcGraphCairoOODriver::drawCircle() Draw circle 
ezcGraphSvgDriver::drawCircle() Draw circle 
ezcGraphGdDriver::drawCircle() Draw circle 
ezcGraphCairoDriver::drawCircle() Draw circle 

drawCircleSector

void drawCircleSector( ezcGraphCoordinate $center , mixed $width , mixed $height , mixed $startAngle , mixed $endAngle , ezcGraphColor $color , [mixed $filled = true] )

Draws a sector of cirlce

Parameters:
Name Type Description
$center ezcGraphCoordinate Center of circle
$width mixed Width
$height mixed Height
$startAngle mixed Start angle of circle sector
$endAngle mixed End angle of circle sector
$color ezcGraphColor Color
$filled mixed Filled
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawCircleSector() Draws a sector of cirlce 
ezcGraphCairoOODriver::drawCircleSector() Draws a sector of cirlce 
ezcGraphSvgDriver::drawCircleSector() Draws a sector of cirlce 
ezcGraphGdDriver::drawCircleSector() Draws a sector of cirlce 
ezcGraphCairoDriver::drawCircleSector() Draws a sector of cirlce 

drawCircularArc

void drawCircularArc( ezcGraphCoordinate $center , integer $width , integer $height , integer $size , float $startAngle , float $endAngle , ezcGraphColor $color , [bool $filled = true] )

Draws a circular arc

Parameters:
Name Type Description
$center ezcGraphCoordinate Center of ellipse
$width integer Width of ellipse
$height integer Height of ellipse
$size integer Height of border
$startAngle float Starting angle of circle sector
$endAngle float Ending angle of circle sector
$color ezcGraphColor Color of Border
$filled bool Fill state
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawCircularArc() Draws a circular arc 
ezcGraphCairoOODriver::drawCircularArc() Draws a circular arc 
ezcGraphSvgDriver::drawCircularArc() Draws a circular arc 
ezcGraphGdDriver::drawCircularArc() Draws a circular arc 
ezcGraphCairoDriver::drawCircularArc() Draws a circular arc 

drawImage

void drawImage( mixed $file , ezcGraphCoordinate $position , mixed $width , mixed $height )

Draw an image

Parameters:
Name Type Description
$file mixed Image file
$position ezcGraphCoordinate Top left position
$width mixed Width of image in destination image
$height mixed Height of image in destination image
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawImage() Draw an image 
ezcGraphCairoOODriver::drawImage() Draw an image 
ezcGraphSvgDriver::drawImage() Draw an image 
ezcGraphGdDriver::drawImage() Draw an image 
ezcGraphCairoDriver::drawImage() Draw an image 

drawLine

void drawLine( ezcGraphCoordinate $start , ezcGraphCoordinate $end , ezcGraphColor $color , [float $thickness = 1.] )

Draws a line

Parameters:
Name Type Description
$start ezcGraphCoordinate Start point
$end ezcGraphCoordinate End point
$color ezcGraphColor Line color
$thickness float Line thickness
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawLine() Draws a line 
ezcGraphCairoOODriver::drawLine() Draws a line 
ezcGraphSvgDriver::drawLine() Draws a line 
ezcGraphGdDriver::drawLine() Draws a line 
ezcGraphCairoDriver::drawLine() Draws a line 

drawPolygon

void drawPolygon( $points , ezcGraphColor $color , [mixed $filled = true] , [float $thickness = 1.] )

Draws a single polygon.

Parameters:
Name Type Description
$points array Point array
$color ezcGraphColor Polygon color
$filled mixed Filled
$thickness float Line thickness
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawPolygon() Draws a single polygon. 
ezcGraphCairoOODriver::drawPolygon() Draws a single polygon. 
ezcGraphSvgDriver::drawPolygon() Draws a single polygon. 
ezcGraphGdDriver::drawPolygon() Draws a single polygon. 
ezcGraphCairoDriver::drawPolygon() Draws a single polygon. 

drawTextBox

void drawTextBox( string $string , ezcGraphCoordinate $position , float $width , float $height , int $align , [ $rotation = null] )

Writes text in a box of desired size

Parameters:
Name Type Description
$string string Text
$position ezcGraphCoordinate Top left position
$width float Width of text box
$height float Height of text box
$align int Alignement of text
$rotation ezcGraphRotation
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::drawTextBox() Writes text in a box of desired size 
ezcGraphCairoOODriver::drawTextBox() Writes text in a box of desired size 
ezcGraphSvgDriver::drawTextBox() Writes text in a box of desired size 
ezcGraphGdDriver::drawTextBox() Writes text in a box of desired size 
ezcGraphCairoDriver::drawTextBox() Writes text in a box of desired size 

getMimeType

string getMimeType( )

Return mime type for current image format

Redefined in descendants as:
Method Description
ezcGraphFlashDriver::getMimeType() Return mime type for current image format 
ezcGraphCairoOODriver::getMimeType() Return mime type for current image format 
ezcGraphSvgDriver::getMimeType() Return mime type for current image format 
ezcGraphGdDriver::getMimeType() Return mime type for current image format 
ezcGraphCairoDriver::getMimeType() Return mime type for current image format 

getTextBoundings

ezcGraphBoundings getTextBoundings( float $size , ezcGraphFontOptions $font , string $text )

Returns boundings of text depending on the available font extension

Parameters:
Name Type Description
$size float Textsize
$font ezcGraphFontOptions Font
$text string Text
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::getTextBoundings() Returns boundings of text depending on the available font extension 
ezcGraphCairoOODriver::getTextBoundings() Returns boundings of text depending on the available font extension 
ezcGraphSvgDriver::getTextBoundings() Returns boundings of text depending on the available font extension 
ezcGraphGdDriver::getTextBoundings() Returns boundings of text depending on the available font extension 
ezcGraphCairoDriver::getTextBoundings() Returns boundings of text depending on the available font extension 

reduceEllipseSize

array reduceEllipseSize( ezcGraphCoordinate $center , float $width , float $height , float $startAngle , float $endAngle , float $size )

Reduce the size of an ellipse

The method returns a the edgepoints and angles for an ellipse where all borders are moved to the inner side of the ellipse by the give $size value.

The method returns an array ( 'center' => (ezcGraphCoordinate) New center point, 'start' => (ezcGraphCoordinate) New outer start point, 'end' => (ezcGraphCoordinate) New outer end point, )

Parameters:
Name Type Description
$center ezcGraphCoordinate
$width float
$height float
$startAngle float
$endAngle float
$size float
Exceptions:
Type Description
ezcGraphReducementFailedException

reducePolygonSize

array( reducePolygonSize( $points , float $size )

Reduces the size of a polygon

The method takes a polygon defined by a list of points and reduces its size by moving all lines to the middle by the given $size value.

The detection of the inner side of the polygon depends on the angle at each edge point. This method will always work for 3 edged polygones, because the smaller angle will always be on the inner side. For polygons with more then 3 edges this method may fail. For ezcGraph this is a valid simplification, because we do not have any polygones which have an inner angle >= 180 degrees.

Parameters:
Name Type Description
$points array(ezcGraphCoordinate)
$size float
Exceptions:
Type Description
ezcGraphReducementFailedException

render

void render( string $file )

Finally save image

Parameters:
Name Type Description
$file string Destination filename
Redefined in descendants as:
Method Description
ezcGraphFlashDriver::render() Finally save image 
ezcGraphCairoOODriver::render() Finally save image 
ezcGraphSvgDriver::render() Finally save image 
ezcGraphGdDriver::render() Finally save image 
ezcGraphCairoDriver::render() Finally save image 

renderToOutput

void renderToOutput( )

Render image directly to output

The method renders the image directly to the standard output. You normally do not want to use this function, because it makes it harder to proper cache the generated graphs.

Redefined in descendants as:
Method Description
ezcGraphCairoOODriver::renderToOutput() Render image directly to output 
ezcGraphSvgDriver::renderToOutput() Render image directly to output 
ezcGraphGdDriver::renderToOutput() Render image directly to output 
ezcGraphCairoDriver::renderToOutput() Render image directly to output 

testFitStringInTextBox

mixed testFitStringInTextBox( string $string , ezcGraphCoordinate $position , float $width , float $height , int $size )

Test if string fits in a box with given font size

This method splits the text up into tokens and tries to wrap the text in an optimal way to fit in the Box defined by width and height.

If the text fits into the box an array with lines is returned, which can be used to render the text later: array( // Lines array( 'word', 'word', .. ), ) Otherwise the function will return false.

Parameters:
Name Type Description
$string string Text
$position ezcGraphCoordinate Topleft position of the text box
$width float Width of textbox
$height float Height of textbox
$size int Fontsize

tryFitShortenedString

void tryFitShortenedString( mixed $string , ezcGraphCoordinate $position , mixed $width , mixed $height , mixed $size )

If it is allow to shortened the string, this method tries to extract as many chars as possible to display a decent amount of characters.

If no complete token (word) does fit, the largest possible amount of chars from the first word are taken. If the amount of chars is bigger then strlen( shortenedStringPostFix ) * 2 the last chars are replace by the postfix.

If one complete word fits the box as many words are taken as possible including a appended shortenedStringPostFix.

Parameters:
Name Type Description
$string mixed
$position ezcGraphCoordinate
$width mixed
$height mixed
$size mixed
Documentation generated by phpDocumentor 1.4.3