[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/ezc/Graph/src/driver/ -> cairo.php (summary)

File containing the ezcGraphCairoDriver class

Copyright: Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
License: http://ez.no/licenses/new_bsd New BSD License
Version: 1.5
File Size: 1010 lines (34 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ezcGraphCairoDriver:: (18 methods):
  __construct()
  initiliazeSurface()
  getStyle()
  drawPolygon()
  drawLine()
  getTextBoundings()
  drawTextBox()
  renderText()
  drawAllTexts()
  drawCircleSector()
  simulateCircularArc()
  drawCircularArc()
  drawCircle()
  drawImage()
  getMimeType()
  renderToOutput()
  render()
  getResource()


Class: ezcGraphCairoDriver  - X-Ref

Extension of the basic driver package to utilize the cairo library.

This drivers options are defined in the class
{@link ezcGraphCairoDriverOptions} extending the basic driver options class
{@link ezcGraphDriverOptions}.

As this is the default driver you do not need to explicitely set anything to
use it, but may use some of its advanced features.

<code>
$graph = new ezcGraphPieChart();
$graph->background->color = '#FFFFFFFF';
$graph->title = 'Access statistics';
$graph->legend = false;

$graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
'Mozilla' => 19113,
'Explorer' => 10917,
'Opera' => 1464,
'Safari' => 652,
'Konqueror' => 474,
) );

$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->pieChartShadowSize = 10;
$graph->renderer->options->pieChartGleam = .5;
$graph->renderer->options->dataBorder = false;
$graph->renderer->options->pieChartHeight = 16;
$graph->renderer->options->legendSymbolGleam = .5;

// Use cairo driver
$graph->driver = new ezcGraphCairoDriver();

$graph->render( 400, 200, 'tutorial_driver_cairo.png' );
</code>

__construct( array $options = array()   X-Ref
Constructor

param: array $options Default option array
return: void

initiliazeSurface()   X-Ref
Initilize cairo surface

Initilize cairo surface from values provided in the options object, if
is has not been already initlized.

return: void

getStyle( ezcGraphColor $color, $filled = true, $thickness = 1. )   X-Ref
Get SVG style definition

Returns a string with SVG style definitions created from color,
fillstatus and line thickness.

param: ezcGraphColor $color Color
param: mixed $filled Filled
param: float $thickness Line thickness.
return: string Formatstring

drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1. )   X-Ref
Draws a single polygon.

param: array $points Point array
param: ezcGraphColor $color Polygon color
param: mixed $filled Filled
param: float $thickness Line thickness
return: void

drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color, $thickness = 1. )   X-Ref
Draws a line

param: ezcGraphCoordinate $start Start point
param: ezcGraphCoordinate $end End point
param: ezcGraphColor $color Line color
param: float $thickness Line thickness
return: void

getTextBoundings( $size, ezcGraphFontOptions $font, $text )   X-Ref
Returns boundings of text depending on the available font extension

param: float $size Textsize
param: ezcGraphFontOptions $font Font
param: string $text Text
return: ezcGraphBoundings Boundings of text

drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null )   X-Ref
Writes text in a box of desired size

param: string $string Text
param: ezcGraphCoordinate $position Top left position
param: float $width Width of text box
param: float $height Height of text box
param: int $align Alignement of text
param: ezcGraphRotation $rotation
return: void

renderText( $text, $font, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null )   X-Ref
Render text depending of font type and available font extensions

param: string $id
param: string $text
param: string $font
param: ezcGraphColor $color
param: ezcGraphCoordinate $position
param: float $size
param: float $rotation
return: void

drawAllTexts()   X-Ref
Draw all collected texts

The texts are collected and their maximum possible font size is
calculated. This function finally draws the texts on the image, this
delayed drawing has two reasons:

1) This way the text strings are always on top of the image, what
results in better readable texts
2) The maximum possible font size can be calculated for a set of texts
with the same font configuration. Strings belonging to one chart
element normally have the same font configuration, so that all texts
belonging to one element will have the same font size.

return: void

drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true )   X-Ref
Draws a sector of cirlce

param: ezcGraphCoordinate $center Center of circle
param: mixed $width Width
param: mixed $height Height
param: mixed $startAngle Start angle of circle sector
param: mixed $endAngle End angle of circle sector
param: ezcGraphColor $color Color
param: mixed $filled Filled;
return: void

simulateCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled )   X-Ref
Draws a circular arc consisting of several minor steps on the bounding
lines.

param: ezcGraphCoordinate $center
param: mixed $width
param: mixed $height
param: mixed $size
param: mixed $startAngle
param: mixed $endAngle
param: ezcGraphColor $color
param: bool $filled
return: string Element id

drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true )   X-Ref
Draws a circular arc

param: ezcGraphCoordinate $center Center of ellipse
param: integer $width Width of ellipse
param: integer $height Height of ellipse
param: integer $size Height of border
param: float $startAngle Starting angle of circle sector
param: float $endAngle Ending angle of circle sector
param: ezcGraphColor $color Color of Border
param: bool $filled
return: void

drawCircle( ezcGraphCoordinate $center, $width, $height, ezcGraphColor $color, $filled = true )   X-Ref
Draw circle

param: ezcGraphCoordinate $center Center of ellipse
param: mixed $width Width of ellipse
param: mixed $height height of ellipse
param: ezcGraphColor $color Color
param: mixed $filled Filled
return: void

drawImage( $file, ezcGraphCoordinate $position, $width, $height )   X-Ref
Draw an image

The image will be inlined in the SVG document using data URL scheme. For
this the mime type and base64 encoded file content will be merged to
URL.

param: mixed $file Image file
param: ezcGraphCoordinate $position Top left position
param: mixed $width Width of image in destination image
param: mixed $height Height of image in destination image
return: void

getMimeType()   X-Ref
Return mime type for current image format

return: string

renderToOutput()   X-Ref
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.

return: void

render( $file )   X-Ref
Finally save image

param: string $file Destination filename
return: void

getResource()   X-Ref
Get resource of rendered result

Return the resource of the rendered result. You should not use this
method before you called either renderToOutput() or render(), as the
image may not be completely rendered until then.

This method returns an array, containing the surface and the context in
a structure like:
<code>
array(
'surface' => resource,
'context' => resource,
)
</code>

return: array



Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7