|
4136 - in trunk/Graph: . src src/driver src/exceptions src/options tests te: msg#00309web.ezcomponents.cvs
Author: Kore Nordmann Date: 2006-11-30 09:44:35 +0100 (Thu, 30 Nov 2006) New Revision: 4136 Log: - Resolved: Issue #9543 (Rename Ming driver to Flash in the Graph component) Added: trunk/Graph/src/driver/flash.php trunk/Graph/src/exceptions/flash_bitmap_boundings.php trunk/Graph/src/exceptions/flash_bitmap_type.php trunk/Graph/src/options/flash_driver.php trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleLinearFill.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleLinearFilledLine.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleNonFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleRadialFill.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleRadialFilledLine.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcute.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteReverse.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorObtuse.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcAcute.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcAcuteBorder.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcAcuteReverse.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcObtuse.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawLine.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleBigCircleSectors.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleCircleSectors.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleCircularArcs.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleFilledTransparentPolygons.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonFivePoints.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonThreePointsFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonThreePointsNotFilled.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawStringWithSpecialChars.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedString.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringCenter.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringRight.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongString.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxManualBreak.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxShortString.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringCenter.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringCenterMiddle.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringRight.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringRightBottom.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringSampleRight.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithBackground.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithBorder.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithCustomTextShadow.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithMinimizedBorderAndBackgroundBottomRight.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithMinimizedBorderAndBackgroundTopLeft.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithTextShadow.swf trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf trunk/Graph/tests/driver_flash_test.php Removed: trunk/Graph/src/driver/ming.php trunk/Graph/src/exceptions/ming_bitmap_boundings.php trunk/Graph/src/exceptions/ming_bitmap_type.php trunk/Graph/src/options/ming_driver.php trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleFilled.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleLinearFill.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleLinearFilledLine.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleNonFilled.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleRadialFill.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleRadialFilledLine.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcute.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcuteNonFilled.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcuteReverse.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorObtuse.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcute.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcuteBorder.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcuteReverse.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcObtuse.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawLine.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleBigCircleSectors.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleCircleSectors.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleCircularArcs.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleFilledTransparentPolygons.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonFivePoints.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonThreePointsFilled.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonThreePointsNotFilled.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawStringWithSpecialChars.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedString.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringCenter.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringRight.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongString.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxManualBreak.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxShortString.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringCenter.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringCenterMiddle.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringRight.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringRightBottom.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringSampleRight.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithBackground.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithBorder.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithCustomTextShadow.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundBottomRight.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundTopLeft.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithTextShadow.swf trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testRenderLabeledFlashPieChart.swf trunk/Graph/tests/driver_ming_test.php Modified: trunk/Graph/ChangeLog trunk/Graph/src/graph_autoload.php trunk/Graph/tests/suite.php Modified: trunk/Graph/ChangeLog =================================================================== --- trunk/Graph/ChangeLog 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/ChangeLog 2006-11-30 08:44:35 UTC (rev 4136) @@ -1,6 +1,8 @@ 1.0 - [RELEASEDATE] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Renamed ezcGraphMingDriver to ezcGraphFlashDriver + - Fixed issue #9583: Data typecasting should only be done in axis - Fixed issue #9586: No data rendered with string keys on date axis. Copied: trunk/Graph/src/driver/flash.php (from rev 4134, trunk/Graph/src/driver/ming.php) =================================================================== --- trunk/Graph/src/driver/ming.php 2006-11-29 17:20:39 UTC (rev 4134) +++ trunk/Graph/src/driver/flash.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -0,0 +1,829 @@ +<?php +/** + * File containing the ezcGraphFlashDriver class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Driver to create Flash4 (SWF) files as graph output. + * + * @package Graph + */ + +class ezcGraphFlashDriver extends ezcGraphDriver +{ + /** + * Flash movie + * + * @var SWFMovie + */ + protected $movie; + + /** + * Unique element id + * + * @var int + */ + protected $id = 1; + + /** + * Array with strings to draw later + * + * @var array + */ + protected $strings = array(); + + /** + * Constructor + * + * @param array $options Default option array + * @return void + * @ignore + */ + public function __construct( array $options = array() ) + { + $this->options = new ezcGraphFlashDriverOptions( $options ); + } + + /** + * Returns unique movie object as a parent canvas for all swf objects. + * + * @return SWFMovie + */ + public function getDocument() + { + if ( $this->movie === null ) + { + ming_setscale( 1.0 ); + $this->movie = new SWFMovie(); + $this->movie->setDimension( $this->modifyCoordinate( $this->options->width ), $this->modifyCoordinate( $this->options->height ) ); + $this->movie->setRate( 1 ); + $this->movie->setBackground( 255, 255, 255 ); + } + + return $this->movie; + } + + /** + * Set the fill and line properties for a SWWFShape according to the + * given parameters. + * + * @param SWFShape $shape + * @param ezcGraphColor $color + * @param mixed $thickness + * @param mixed $filled + * @return void + */ + protected function setShapeColor( SWFShape $shape, ezcGraphColor $color, $thickness, $filled ) + { + if ( $filled ) + { + switch ( true ) + { + case ( $color instanceof ezcGraphLinearGradient ): + $gradient = new SWFGradient(); + $gradient->addEntry( + 0, + $color->startColor->red, + $color->startColor->green, + $color->startColor->blue, + 255 - $color->startColor->alpha + ); + $gradient->addEntry( + 1, + $color->endColor->red, + $color->endColor->green, + $color->endColor->blue, + 255 - $color->endColor->alpha + ); + + $fill = $shape->addFill( $gradient, SWFFILL_LINEAR_GRADIENT ); + + $fill->rotateTo( + rad2deg( asin( + ( $color->endPoint->x - $color->startPoint->x ) / + $length = sqrt( + pow( $color->endPoint->x - $color->startPoint->x, 2 ) + + pow( $color->endPoint->y - $color->startPoint->y, 2 ) + ) + ) + 180 ) + ); + $fill->scaleTo( $this->modifyCoordinate( $length ) / 32768 , $this->modifyCoordinate( $length ) / 32768 ); + $fill->moveTo( $this->modifyCoordinate( $color->startPoint->x ), $this->modifyCoordinate( $color->startPoint->y ) ); + + $shape->setLeftFill( $fill ); + break; + case ( $color instanceof ezcGraphRadialGradient ): + $gradient = new SWFGradient(); + $gradient->addEntry( + 0, + $color->startColor->red, + $color->startColor->green, + $color->startColor->blue, + 255 - $color->startColor->alpha + ); + $gradient->addEntry( + 1, + $color->endColor->red, + $color->endColor->green, + $color->endColor->blue, + 255 - $color->endColor->alpha + ); + + $fill = $shape->addFill( $gradient, SWFFILL_RADIAL_GRADIENT ); + + $fill->scaleTo( $this->modifyCoordinate( $color->width ) / 32768, $this->modifyCoordinate( $color->height ) / 32768 ); + $fill->moveTo( $this->modifyCoordinate( $color->center->x ), $this->modifyCoordinate( $color->center->y ) ); + + $shape->setLeftFill( $fill ); + break; + default: + $fill = $shape->addFill( $color->red, $color->green, $color->blue, 255 - $color->alpha ); + $shape->setLeftFill( $fill ); + break; + } + } + else + { + $shape->setLine( $this->modifyCoordinate( $thickness ), $color->red, $color->green, $color->blue, 255 - $color->alpha ); + } + } + + /** + * Modifies a coordinate value, as flash usally uses twips instead of + * pixels for a higher solution, as it only accepts integer values. + * + * @param float $pointValue + * @return float + */ + protected function modifyCoordinate( $pointValue ) + { + return $pointValue * 10; + } + + /** + * Demodifies a coordinate value, as flash usally uses twips instead of + * pixels for a higher solution, as it only accepts integer values. + * + * @param float $pointValue + * @return float + */ + protected function deModifyCoordinate( $pointValue ) + { + return $pointValue / 10; + } + + /** + * 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 + */ + public function drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1 ) + { + $movie = $this->getDocument(); + + $shape = new SWFShape(); + + $this->setShapeColor( $shape, $color, $thickness, $filled ); + + $lastPoint = end( $points ); + $shape->movePenTo( $this->modifyCoordinate( $lastPoint->x ), $this->modifyCoordinate( $lastPoint->y ) ); + + foreach( $points as $point ) + { + $shape->drawLineTo( $this->modifyCoordinate( $point->x ), $this->modifyCoordinate( $point->y ) ); + } + + $object = $movie->add( $shape ); + $object->setName( $id = 'ezcGraphPolygon_' . $this->id++ ); + + return $id; + } + + /** + * 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 + */ + public function drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color, $thickness = 1 ) + { + $movie = $this->getDocument(); + + $shape = new SWFShape(); + + $this->setShapeColor( $shape, $color, $thickness, false ); + + $shape->movePenTo( $this->modifyCoordinate( $start->x ), $this->modifyCoordinate( $start->y ) ); + $shape->drawLineTo( $this->modifyCoordinate( $end->x ), $this->modifyCoordinate( $end->y ) ); + + $object = $movie->add( $shape ); + $object->setName( $id = 'ezcGraphLine_' . $this->id++ ); + + return $id; + } + + /** + * 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 + */ + protected function getTextBoundings( $size, ezcGraphFontOptions $font, $text ) + { + $t = new SWFText(); + $t->setFont( new SWFFont( $font->path ) ); + $t->setHeight( $size ); + + $boundings = new ezcGraphBoundings( 0, 0, $t->getWidth( $text ), $size ); + + return $boundings; + } + + /** + * 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 + * @return void + */ + public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align ) + { + if ( $this->options->font->type !== ezcGraph::PALM_FONT ) + { + throw new ezcGraphInvalidFontTypeException( $this->options->font->type, __CLASS__ ); + } + + $padding = $this->options->font->padding + ( $this->options->font->border !== false ? $this->options->font->borderWidth : 0 ); + + $width = $this->modifyCoordinate( $width - $padding * 2 ); + $height = $this->modifyCoordinate( $height - $padding * 2 ); + $position = new ezcGraphCoordinate( + $this->modifyCoordinate( $position->x + $padding ), + $this->modifyCoordinate( $position->y + $padding ) + ); + + // Try to get a font size for the text to fit into the box + $maxSize = $this->modifyCoordinate( min( $height, $this->options->font->maxFontSize ) ); + $minSize = $this->modifyCoordinate( $this->options->font->minFontSize ); + $result = false; + for ( $size = $maxSize; $size >= $minSize; ) + { + $result = $this->testFitStringInTextBox( $string, $position, $width, $height, $size ); + if ( is_array( $result ) ) + { + break; + } + $size = $this->deModifyCoordinate( $size ); + $size = $this->modifyCoordinate( floor( ( $newsize = $size * ( $result ) ) >= $size ? $size - 1 : $newsize ) ); + } + + if ( is_array( $result ) ) + { + $this->options->font->minimalUsedFont = $this->deModifyCoordinate( $size ); + + $this->strings[] = array( + 'text' => $result, + 'id' => $id = 'ezcGraphTextBox_' . $this->id++, + 'position' => $position, + 'width' => $width, + 'height' => $height, + 'align' => $align, + 'font' => $this->options->font, + ); + } + else + { + throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + } + + return $id; + } + + /** + * Render text depending of font type and available font extensions + * + * @param resource $image Image resource + * @param string $text Text + * @param int $type Font type + * @param string $path Font path + * @param ezcGraphColor $color Font color + * @param ezcGraphCoordinate $position Position + * @param float $size Textsize + * @param ezcGraphColor $color Textcolor + * @return void + */ + protected function renderText( $id, $text, $chars, $type, $path, ezcGraphColor $color, ezcGraphCoordinate $position, $size ) + { + $movie = $this->getDocument(); + + $tb = new SWFTextField( SWFTEXTFIELD_NOEDIT ); + $tb->setFont( new SWFFont( $path ) ); + $tb->setHeight( $size ); + $tb->setColor( $color->red, $color->green, $color->blue, 255 - $color->alpha ); + $tb->addString( $text ); + $tb->addChars( $chars ); + + $object = $movie->add( $tb ); + $object->moveTo( $position->x, $position->y - $size * ( 1 + $this->options->lineSpacing ) ); + $object->setName( $id ); + } + + /** + * 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. + * + * @access protected + * @return void + */ + protected function drawAllTexts() + { + // Iterate over all strings to collect used chars per font + $chars = array(); + foreach ( $this->strings as $text ) + { + $completeString = ''; + foreach( $text['text'] as $line ) + { + $completeString .= implode( ' ', $line ); + } + + // Collect chars for each font + if ( !isset( $chars[$text['font']->path] ) ) + { + $chars[$text['font']->path] = $completeString; + } + else + { + $chars[$text['font']->path] .= $completeString; + } + } + + foreach ( $this->strings as $text ) + { + $size = $this->modifyCoordinate( $text['font']->minimalUsedFont ); + + $completeHeight = count( $text['text'] ) * $size + ( count( $text['text'] ) - 1 ) * $this->options->lineSpacing; + + // Calculate y offset for vertical alignement + switch ( true ) + { + case ( $text['align'] & ezcGraph::BOTTOM ): + $yOffset = $text['height'] - $completeHeight; + break; + case ( $text['align'] & ezcGraph::MIDDLE ): + $yOffset = ( $text['height'] - $completeHeight ) / 2; + break; + case ( $text['align'] & ezcGraph::TOP ): + default: + $yOffset = 0; + break; + } + + $padding = $text['font']->padding + $text['font']->borderWidth / 2; + if ( $this->options->font->minimizeBorder === true ) + { + // Calculate maximum width of text rows + $width = false; + foreach ( $text['text'] as $line ) + { + $string = implode( ' ', $line ); + $boundings = $this->getTextBoundings( $size, $text['font'], $string ); + if ( ( $width === false) || ( $boundings->width > $width ) ) + { + $width = $boundings->width; + } + } + + switch ( true ) + { + case ( $text['align'] & ezcGraph::LEFT ): + $xOffset = 0; + break; + case ( $text['align'] & ezcGraph::CENTER ): + $xOffset = ( $text['width'] - $width ) / 2; + break; + case ( $text['align'] & ezcGraph::RIGHT ): + $xOffset = $text['width'] - $width; + break; + } + + $borderPolygonArray = array( + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x - $padding + $xOffset ), + $this->deModifyCoordinate( $text['position']->y - $padding + $yOffset ) + ), + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $xOffset + $width ), + $this->deModifyCoordinate( $text['position']->y - $padding + $yOffset ) + ), + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $xOffset + $width ), + $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $yOffset + $completeHeight ) + ), + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x - $padding + $xOffset ), + $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $yOffset + $completeHeight ) + ), + ); + } + else + { + $borderPolygonArray = array( + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x - $padding ), + $this->deModifyCoordinate( $text['position']->y - $padding ) + ), + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $text['width'] ), + $this->deModifyCoordinate( $text['position']->y - $padding ) + ), + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $text['width'] ), + $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $text['height'] ) + ), + new ezcGraphCoordinate( + $this->deModifyCoordinate( $text['position']->x - $padding ), + $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $text['height'] ) + ), + ); + } + + if ( $text['font']->background !== false ) + { + $this->drawPolygon( + $borderPolygonArray, + $text['font']->background, + true + ); + } + + if ( $text['font']->border !== false ) + { + $this->drawPolygon( + $borderPolygonArray, + $text['font']->border, + false, + $text['font']->borderWidth + ); + } + + // Render text with evaluated font size + $completeString = ''; + foreach ( $text['text'] as $line ) + { + $string = implode( ' ', $line ); + $completeString .= $string; + $boundings = $this->getTextBoundings( $size, $text['font'], $string ); + $text['position']->y += $size; + + switch ( true ) + { + case ( $text['align'] & ezcGraph::LEFT ): + $position = new ezcGraphCoordinate( + $text['position']->x, + $text['position']->y + $yOffset + ); + break; + case ( $text['align'] & ezcGraph::RIGHT ): + $position = new ezcGraphCoordinate( + $text['position']->x + ( $text['width'] - $boundings->width ), + $text['position']->y + $yOffset + ); + break; + case ( $text['align'] & ezcGraph::CENTER ): + $position = new ezcGraphCoordinate( + $text['position']->x + ( ( $text['width'] - $boundings->width ) / 2 ), + $text['position']->y + $yOffset + ); + break; + } + + // Optionally draw text shadow + if ( $text['font']->textShadow === true ) + { + $this->renderText( + $text['id'], + $string, + $chars[$text['font']->path], + $text['font']->type, + $text['font']->path, + $text['font']->textShadowColor, + new ezcGraphCoordinate( + $position->x + $this->modifyCoordinate( $text['font']->textShadowOffset ), + $position->y + $this->modifyCoordinate( $text['font']->textShadowOffset ) + ), + $size + ); + } + + // Finally draw text + $this->renderText( + $text['id'], + $string, + $chars[$text['font']->path], + $text['font']->type, + $text['font']->path, + $text['font']->color, + $position, + $size + ); + + $text['position']->y += $size * $this->options->lineSpacing; + } + } + } + + /** + * 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 + */ + public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) + { + if ( $startAngle > $endAngle ) + { + $tmp = $startAngle; + $startAngle = $endAngle; + $endAngle = $tmp; + } + + $movie = $this->getDocument(); + + $shape = new SWFShape(); + $this->setShapeColor( $shape, $color, 1, $filled ); + + $shape->movePenTo( $this->modifyCoordinate( $center->x ), $this->modifyCoordinate( $center->y ) ); + + // @TODO: User SWFShape::curveTo + for ( $angle = $startAngle; $angle <= $endAngle; $angle += $this->options->circleResolution ) + { + $angle = min( + $angle, + $endAngle + ); + + $shape->drawLineTo( + $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), + $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) + ); + } + + $shape->drawLineTo( + $this->modifyCoordinate( $center->x ), + $this->modifyCoordinate( $center->y ) + ); + + $object = $movie->add( $shape ); + $object->setName( $id = 'ezcGraphCircleSector_' . $this->id++ ); + + return $id; + } + + /** + * 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 mixed $filled + * @return string Element id + */ + protected function simulateCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled ) + { + $movie = $this->getDocument(); + $id = 'ezcGraphCircularArc_' . $this->id++; + + for ( + $tmpAngle = min( ceil ( $startAngle / 180 ) * 180, $endAngle ); + $tmpAngle <= $endAngle; + $tmpAngle = min( ceil ( $startAngle / 180 + 1 ) * 180, $endAngle ) ) + { + $shape = new SWFShape(); + $this->setShapeColor( $shape, $color, 1, $filled ); + + $shape->movePenTo( + $this->modifyCoordinate( $center->x + cos( deg2rad( $startAngle ) ) * $width / 2 ), + $this->modifyCoordinate( $center->y + sin( deg2rad( $startAngle ) ) * $height / 2 ) + ); + + // @TODO: Use SWFShape::curveTo + for( + $angle = $startAngle; + $angle <= $tmpAngle; + $angle = min( $angle + $this->options->circleResolution, $tmpAngle ) ) + { + $shape->drawLineTo( + $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), + $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 + $size ) + ); + + if ( $angle === $tmpAngle ) + { + break; + } + } + + for( + $angle = $tmpAngle; + $angle >= $startAngle; + $angle = max( $angle - $this->options->circleResolution, $startAngle ) ) + { + $shape->drawLineTo( + $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), + $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) + ); + + if ( $angle === $startAngle ) + { + break; + } + } + + $object = $movie->add( $shape ); + $object->setName( $id ); + + $startAngle = $tmpAngle; + if ( $tmpAngle === $endAngle ) + { + break; + } + } + + return $id; + } + + /** + * 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 + * @return void + */ + public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) + { + if ( $startAngle > $endAngle ) + { + $tmp = $startAngle; + $startAngle = $endAngle; + $endAngle = $tmp; + } + + $id = $this->simulateCircularArc( $center, $width, $height, $size, $startAngle, $endAngle, $color, $filled ); + + if ( ( $this->options->shadeCircularArc !== false ) && + $filled ) + { + $gradient = new ezcGraphLinearGradient( + new ezcGraphCoordinate( + $center->x - $width, + $center->y + ), + new ezcGraphCoordinate( + $center->x + $width, + $center->y + ), + ezcGraphColor::fromHex( '#FFFFFF' )->transparent( $this->options->shadeCircularArc * 1.5 ), + ezcGraphColor::fromHex( '#000000' )->transparent( $this->options->shadeCircularArc * 1.5 ) + ); + + $this->simulateCircularArc( $center, $width, $height, $size, $startAngle, $endAngle, $gradient, $filled ); + } + + return $id; + } + + /** + * 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 + */ + public function drawCircle( ezcGraphCoordinate $center, $width, $height, ezcGraphColor $color, $filled = true ) + { + $movie = $this->getDocument(); + + $shape = new SWFShape(); + $this->setShapeColor( $shape, $color, 1, $filled ); + + $shape->movePenTo( + $this->modifyCoordinate( $center->x + $width / 2 ), + $this->modifyCoordinate( $center->y ) + ); + + // @TODO: User SWFShape::curveTo + for ( $angle = $this->options->circleResolution; $angle <= 360; $angle += $this->options->circleResolution ) + { + $shape->drawLineTo( + $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), + $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) + ); + } + + $object = $movie->add( $shape ); + $object->setName( $id = 'ezcGraphCircle_' . $this->id++ ); + + return $id; + } + + /** + * 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 + */ + public function drawImage( $file, ezcGraphCoordinate $position, $width, $height ) + { + $movie = $this->getDocument(); + + $imageData = getimagesize( $file ); + if ( $imageData[0] !== $width || $imageData[1] !== $height ) + { + throw new ezcGraphFlashBitmapBoundingsException( $imageData[0], $imageData[1], $width, $height ); + } + + if ( $imageData[2] !== 2 ) + { + throw new ezcGraphFlashBitmapTypeException( $imageData[2] ); + } + + $image = new SWFBitmap( file_get_contents( 'http://kore.phpugdo.de/jpg.jpeg' ) ); + $object = $movie->add( $image ); + + $object->moveTo( + $this->modifyCoordinate( $position->x ), + $this->modifyCoordinate( $position->y ) + ); + $object->setName( $id = 'ezcGraphImage_'. $this->id++ ); + + return $id; + } + + /** + * Finally save image + * + * @param string $file Destination filename + * @return void + */ + public function render ( $file ) + { + $this->drawAllTexts(); + $movie = $this->getDocument(); + $movie->save( $file, $this->options->compression ); + } +} + +?> Deleted: trunk/Graph/src/driver/ming.php =================================================================== --- trunk/Graph/src/driver/ming.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/src/driver/ming.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -1,829 +0,0 @@ -<?php -/** - * File containing the ezcGraphMingDriver class - * - * @package Graph - * @version //autogentag// - * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - */ -/** - * Driver to create Flash4 (SWF) files as graph output. - * - * @package Graph - */ - -class ezcGraphMingDriver extends ezcGraphDriver -{ - /** - * Flash movie - * - * @var SWFMovie - */ - protected $movie; - - /** - * Unique element id - * - * @var int - */ - protected $id = 1; - - /** - * Array with strings to draw later - * - * @var array - */ - protected $strings = array(); - - /** - * Constructor - * - * @param array $options Default option array - * @return void - * @ignore - */ - public function __construct( array $options = array() ) - { - $this->options = new ezcGraphMingDriverOptions( $options ); - } - - /** - * Returns unique movie object as a parent canvas for all swf objects. - * - * @return SWFMovie - */ - public function getDocument() - { - if ( $this->movie === null ) - { - ming_setscale( 1.0 ); - $this->movie = new SWFMovie(); - $this->movie->setDimension( $this->modifyCoordinate( $this->options->width ), $this->modifyCoordinate( $this->options->height ) ); - $this->movie->setRate( 1 ); - $this->movie->setBackground( 255, 255, 255 ); - } - - return $this->movie; - } - - /** - * Set the fill and line properties for a SWWFShape according to the - * given parameters. - * - * @param SWFShape $shape - * @param ezcGraphColor $color - * @param mixed $thickness - * @param mixed $filled - * @return void - */ - protected function setShapeColor( SWFShape $shape, ezcGraphColor $color, $thickness, $filled ) - { - if ( $filled ) - { - switch ( true ) - { - case ( $color instanceof ezcGraphLinearGradient ): - $gradient = new SWFGradient(); - $gradient->addEntry( - 0, - $color->startColor->red, - $color->startColor->green, - $color->startColor->blue, - 255 - $color->startColor->alpha - ); - $gradient->addEntry( - 1, - $color->endColor->red, - $color->endColor->green, - $color->endColor->blue, - 255 - $color->endColor->alpha - ); - - $fill = $shape->addFill( $gradient, SWFFILL_LINEAR_GRADIENT ); - - $fill->rotateTo( - rad2deg( asin( - ( $color->endPoint->x - $color->startPoint->x ) / - $length = sqrt( - pow( $color->endPoint->x - $color->startPoint->x, 2 ) + - pow( $color->endPoint->y - $color->startPoint->y, 2 ) - ) - ) + 180 ) - ); - $fill->scaleTo( $this->modifyCoordinate( $length ) / 32768 , $this->modifyCoordinate( $length ) / 32768 ); - $fill->moveTo( $this->modifyCoordinate( $color->startPoint->x ), $this->modifyCoordinate( $color->startPoint->y ) ); - - $shape->setLeftFill( $fill ); - break; - case ( $color instanceof ezcGraphRadialGradient ): - $gradient = new SWFGradient(); - $gradient->addEntry( - 0, - $color->startColor->red, - $color->startColor->green, - $color->startColor->blue, - 255 - $color->startColor->alpha - ); - $gradient->addEntry( - 1, - $color->endColor->red, - $color->endColor->green, - $color->endColor->blue, - 255 - $color->endColor->alpha - ); - - $fill = $shape->addFill( $gradient, SWFFILL_RADIAL_GRADIENT ); - - $fill->scaleTo( $this->modifyCoordinate( $color->width ) / 32768, $this->modifyCoordinate( $color->height ) / 32768 ); - $fill->moveTo( $this->modifyCoordinate( $color->center->x ), $this->modifyCoordinate( $color->center->y ) ); - - $shape->setLeftFill( $fill ); - break; - default: - $fill = $shape->addFill( $color->red, $color->green, $color->blue, 255 - $color->alpha ); - $shape->setLeftFill( $fill ); - break; - } - } - else - { - $shape->setLine( $this->modifyCoordinate( $thickness ), $color->red, $color->green, $color->blue, 255 - $color->alpha ); - } - } - - /** - * Modifies a coordinate value, as flash usally uses twips instead of - * pixels for a higher solution, as it only accepts integer values. - * - * @param float $pointValue - * @return float - */ - protected function modifyCoordinate( $pointValue ) - { - return $pointValue * 10; - } - - /** - * Demodifies a coordinate value, as flash usally uses twips instead of - * pixels for a higher solution, as it only accepts integer values. - * - * @param float $pointValue - * @return float - */ - protected function deModifyCoordinate( $pointValue ) - { - return $pointValue / 10; - } - - /** - * 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 - */ - public function drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1 ) - { - $movie = $this->getDocument(); - - $shape = new SWFShape(); - - $this->setShapeColor( $shape, $color, $thickness, $filled ); - - $lastPoint = end( $points ); - $shape->movePenTo( $this->modifyCoordinate( $lastPoint->x ), $this->modifyCoordinate( $lastPoint->y ) ); - - foreach( $points as $point ) - { - $shape->drawLineTo( $this->modifyCoordinate( $point->x ), $this->modifyCoordinate( $point->y ) ); - } - - $object = $movie->add( $shape ); - $object->setName( $id = 'ezcGraphPolygon_' . $this->id++ ); - - return $id; - } - - /** - * 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 - */ - public function drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color, $thickness = 1 ) - { - $movie = $this->getDocument(); - - $shape = new SWFShape(); - - $this->setShapeColor( $shape, $color, $thickness, false ); - - $shape->movePenTo( $this->modifyCoordinate( $start->x ), $this->modifyCoordinate( $start->y ) ); - $shape->drawLineTo( $this->modifyCoordinate( $end->x ), $this->modifyCoordinate( $end->y ) ); - - $object = $movie->add( $shape ); - $object->setName( $id = 'ezcGraphLine_' . $this->id++ ); - - return $id; - } - - /** - * 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 - */ - protected function getTextBoundings( $size, ezcGraphFontOptions $font, $text ) - { - $t = new SWFText(); - $t->setFont( new SWFFont( $font->path ) ); - $t->setHeight( $size ); - - $boundings = new ezcGraphBoundings( 0, 0, $t->getWidth( $text ), $size ); - - return $boundings; - } - - /** - * 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 - * @return void - */ - public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align ) - { - if ( $this->options->font->type !== ezcGraph::PALM_FONT ) - { - throw new ezcGraphInvalidFontTypeException( $this->options->font->type, __CLASS__ ); - } - - $padding = $this->options->font->padding + ( $this->options->font->border !== false ? $this->options->font->borderWidth : 0 ); - - $width = $this->modifyCoordinate( $width - $padding * 2 ); - $height = $this->modifyCoordinate( $height - $padding * 2 ); - $position = new ezcGraphCoordinate( - $this->modifyCoordinate( $position->x + $padding ), - $this->modifyCoordinate( $position->y + $padding ) - ); - - // Try to get a font size for the text to fit into the box - $maxSize = $this->modifyCoordinate( min( $height, $this->options->font->maxFontSize ) ); - $minSize = $this->modifyCoordinate( $this->options->font->minFontSize ); - $result = false; - for ( $size = $maxSize; $size >= $minSize; ) - { - $result = $this->testFitStringInTextBox( $string, $position, $width, $height, $size ); - if ( is_array( $result ) ) - { - break; - } - $size = $this->deModifyCoordinate( $size ); - $size = $this->modifyCoordinate( floor( ( $newsize = $size * ( $result ) ) >= $size ? $size - 1 : $newsize ) ); - } - - if ( is_array( $result ) ) - { - $this->options->font->minimalUsedFont = $this->deModifyCoordinate( $size ); - - $this->strings[] = array( - 'text' => $result, - 'id' => $id = 'ezcGraphTextBox_' . $this->id++, - 'position' => $position, - 'width' => $width, - 'height' => $height, - 'align' => $align, - 'font' => $this->options->font, - ); - } - else - { - throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); - } - - return $id; - } - - /** - * Render text depending of font type and available font extensions - * - * @param resource $image Image resource - * @param string $text Text - * @param int $type Font type - * @param string $path Font path - * @param ezcGraphColor $color Font color - * @param ezcGraphCoordinate $position Position - * @param float $size Textsize - * @param ezcGraphColor $color Textcolor - * @return void - */ - protected function renderText( $id, $text, $chars, $type, $path, ezcGraphColor $color, ezcGraphCoordinate $position, $size ) - { - $movie = $this->getDocument(); - - $tb = new SWFTextField( SWFTEXTFIELD_NOEDIT ); - $tb->setFont( new SWFFont( $path ) ); - $tb->setHeight( $size ); - $tb->setColor( $color->red, $color->green, $color->blue, 255 - $color->alpha ); - $tb->addString( $text ); - $tb->addChars( $chars ); - - $object = $movie->add( $tb ); - $object->moveTo( $position->x, $position->y - $size * ( 1 + $this->options->lineSpacing ) ); - $object->setName( $id ); - } - - /** - * 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. - * - * @access protected - * @return void - */ - protected function drawAllTexts() - { - // Iterate over all strings to collect used chars per font - $chars = array(); - foreach ( $this->strings as $text ) - { - $completeString = ''; - foreach( $text['text'] as $line ) - { - $completeString .= implode( ' ', $line ); - } - - // Collect chars for each font - if ( !isset( $chars[$text['font']->path] ) ) - { - $chars[$text['font']->path] = $completeString; - } - else - { - $chars[$text['font']->path] .= $completeString; - } - } - - foreach ( $this->strings as $text ) - { - $size = $this->modifyCoordinate( $text['font']->minimalUsedFont ); - - $completeHeight = count( $text['text'] ) * $size + ( count( $text['text'] ) - 1 ) * $this->options->lineSpacing; - - // Calculate y offset for vertical alignement - switch ( true ) - { - case ( $text['align'] & ezcGraph::BOTTOM ): - $yOffset = $text['height'] - $completeHeight; - break; - case ( $text['align'] & ezcGraph::MIDDLE ): - $yOffset = ( $text['height'] - $completeHeight ) / 2; - break; - case ( $text['align'] & ezcGraph::TOP ): - default: - $yOffset = 0; - break; - } - - $padding = $text['font']->padding + $text['font']->borderWidth / 2; - if ( $this->options->font->minimizeBorder === true ) - { - // Calculate maximum width of text rows - $width = false; - foreach ( $text['text'] as $line ) - { - $string = implode( ' ', $line ); - $boundings = $this->getTextBoundings( $size, $text['font'], $string ); - if ( ( $width === false) || ( $boundings->width > $width ) ) - { - $width = $boundings->width; - } - } - - switch ( true ) - { - case ( $text['align'] & ezcGraph::LEFT ): - $xOffset = 0; - break; - case ( $text['align'] & ezcGraph::CENTER ): - $xOffset = ( $text['width'] - $width ) / 2; - break; - case ( $text['align'] & ezcGraph::RIGHT ): - $xOffset = $text['width'] - $width; - break; - } - - $borderPolygonArray = array( - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x - $padding + $xOffset ), - $this->deModifyCoordinate( $text['position']->y - $padding + $yOffset ) - ), - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $xOffset + $width ), - $this->deModifyCoordinate( $text['position']->y - $padding + $yOffset ) - ), - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $xOffset + $width ), - $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $yOffset + $completeHeight ) - ), - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x - $padding + $xOffset ), - $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $yOffset + $completeHeight ) - ), - ); - } - else - { - $borderPolygonArray = array( - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x - $padding ), - $this->deModifyCoordinate( $text['position']->y - $padding ) - ), - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $text['width'] ), - $this->deModifyCoordinate( $text['position']->y - $padding ) - ), - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $text['width'] ), - $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $text['height'] ) - ), - new ezcGraphCoordinate( - $this->deModifyCoordinate( $text['position']->x - $padding ), - $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $text['height'] ) - ), - ); - } - - if ( $text['font']->background !== false ) - { - $this->drawPolygon( - $borderPolygonArray, - $text['font']->background, - true - ); - } - - if ( $text['font']->border !== false ) - { - $this->drawPolygon( - $borderPolygonArray, - $text['font']->border, - false, - $text['font']->borderWidth - ); - } - - // Render text with evaluated font size - $completeString = ''; - foreach ( $text['text'] as $line ) - { - $string = implode( ' ', $line ); - $completeString .= $string; - $boundings = $this->getTextBoundings( $size, $text['font'], $string ); - $text['position']->y += $size; - - switch ( true ) - { - case ( $text['align'] & ezcGraph::LEFT ): - $position = new ezcGraphCoordinate( - $text['position']->x, - $text['position']->y + $yOffset - ); - break; - case ( $text['align'] & ezcGraph::RIGHT ): - $position = new ezcGraphCoordinate( - $text['position']->x + ( $text['width'] - $boundings->width ), - $text['position']->y + $yOffset - ); - break; - case ( $text['align'] & ezcGraph::CENTER ): - $position = new ezcGraphCoordinate( - $text['position']->x + ( ( $text['width'] - $boundings->width ) / 2 ), - $text['position']->y + $yOffset - ); - break; - } - - // Optionally draw text shadow - if ( $text['font']->textShadow === true ) - { - $this->renderText( - $text['id'], - $string, - $chars[$text['font']->path], - $text['font']->type, - $text['font']->path, - $text['font']->textShadowColor, - new ezcGraphCoordinate( - $position->x + $this->modifyCoordinate( $text['font']->textShadowOffset ), - $position->y + $this->modifyCoordinate( $text['font']->textShadowOffset ) - ), - $size - ); - } - - // Finally draw text - $this->renderText( - $text['id'], - $string, - $chars[$text['font']->path], - $text['font']->type, - $text['font']->path, - $text['font']->color, - $position, - $size - ); - - $text['position']->y += $size * $this->options->lineSpacing; - } - } - } - - /** - * 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 - */ - public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) - { - if ( $startAngle > $endAngle ) - { - $tmp = $startAngle; - $startAngle = $endAngle; - $endAngle = $tmp; - } - - $movie = $this->getDocument(); - - $shape = new SWFShape(); - $this->setShapeColor( $shape, $color, 1, $filled ); - - $shape->movePenTo( $this->modifyCoordinate( $center->x ), $this->modifyCoordinate( $center->y ) ); - - // @TODO: User SWFShape::curveTo - for ( $angle = $startAngle; $angle <= $endAngle; $angle += $this->options->circleResolution ) - { - $angle = min( - $angle, - $endAngle - ); - - $shape->drawLineTo( - $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), - $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) - ); - } - - $shape->drawLineTo( - $this->modifyCoordinate( $center->x ), - $this->modifyCoordinate( $center->y ) - ); - - $object = $movie->add( $shape ); - $object->setName( $id = 'ezcGraphCircleSector_' . $this->id++ ); - - return $id; - } - - /** - * 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 mixed $filled - * @return string Element id - */ - protected function simulateCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled ) - { - $movie = $this->getDocument(); - $id = 'ezcGraphCircularArc_' . $this->id++; - - for ( - $tmpAngle = min( ceil ( $startAngle / 180 ) * 180, $endAngle ); - $tmpAngle <= $endAngle; - $tmpAngle = min( ceil ( $startAngle / 180 + 1 ) * 180, $endAngle ) ) - { - $shape = new SWFShape(); - $this->setShapeColor( $shape, $color, 1, $filled ); - - $shape->movePenTo( - $this->modifyCoordinate( $center->x + cos( deg2rad( $startAngle ) ) * $width / 2 ), - $this->modifyCoordinate( $center->y + sin( deg2rad( $startAngle ) ) * $height / 2 ) - ); - - // @TODO: Use SWFShape::curveTo - for( - $angle = $startAngle; - $angle <= $tmpAngle; - $angle = min( $angle + $this->options->circleResolution, $tmpAngle ) ) - { - $shape->drawLineTo( - $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), - $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 + $size ) - ); - - if ( $angle === $tmpAngle ) - { - break; - } - } - - for( - $angle = $tmpAngle; - $angle >= $startAngle; - $angle = max( $angle - $this->options->circleResolution, $startAngle ) ) - { - $shape->drawLineTo( - $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), - $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) - ); - - if ( $angle === $startAngle ) - { - break; - } - } - - $object = $movie->add( $shape ); - $object->setName( $id ); - - $startAngle = $tmpAngle; - if ( $tmpAngle === $endAngle ) - { - break; - } - } - - return $id; - } - - /** - * 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 - * @return void - */ - public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) - { - if ( $startAngle > $endAngle ) - { - $tmp = $startAngle; - $startAngle = $endAngle; - $endAngle = $tmp; - } - - $id = $this->simulateCircularArc( $center, $width, $height, $size, $startAngle, $endAngle, $color, $filled ); - - if ( ( $this->options->shadeCircularArc !== false ) && - $filled ) - { - $gradient = new ezcGraphLinearGradient( - new ezcGraphCoordinate( - $center->x - $width, - $center->y - ), - new ezcGraphCoordinate( - $center->x + $width, - $center->y - ), - ezcGraphColor::fromHex( '#FFFFFF' )->transparent( $this->options->shadeCircularArc * 1.5 ), - ezcGraphColor::fromHex( '#000000' )->transparent( $this->options->shadeCircularArc * 1.5 ) - ); - - $this->simulateCircularArc( $center, $width, $height, $size, $startAngle, $endAngle, $gradient, $filled ); - } - - return $id; - } - - /** - * 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 - */ - public function drawCircle( ezcGraphCoordinate $center, $width, $height, ezcGraphColor $color, $filled = true ) - { - $movie = $this->getDocument(); - - $shape = new SWFShape(); - $this->setShapeColor( $shape, $color, 1, $filled ); - - $shape->movePenTo( - $this->modifyCoordinate( $center->x + $width / 2 ), - $this->modifyCoordinate( $center->y ) - ); - - // @TODO: User SWFShape::curveTo - for ( $angle = $this->options->circleResolution; $angle <= 360; $angle += $this->options->circleResolution ) - { - $shape->drawLineTo( - $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ), - $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) - ); - } - - $object = $movie->add( $shape ); - $object->setName( $id = 'ezcGraphCircle_' . $this->id++ ); - - return $id; - } - - /** - * 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 - */ - public function drawImage( $file, ezcGraphCoordinate $position, $width, $height ) - { - $movie = $this->getDocument(); - - $imageData = getimagesize( $file ); - if ( $imageData[0] !== $width || $imageData[1] !== $height ) - { - throw new ezcGraphMingBitmapBoundingsException( $imageData[0], $imageData[1], $width, $height ); - } - - if ( $imageData[2] !== 2 ) - { - throw new ezcGraphMingBitmapTypeException( $imageData[2] ); - } - - $image = new SWFBitmap( file_get_contents( 'http://kore.phpugdo.de/jpg.jpeg' ) ); - $object = $movie->add( $image ); - - $object->moveTo( - $this->modifyCoordinate( $position->x ), - $this->modifyCoordinate( $position->y ) - ); - $object->setName( $id = 'ezcGraphImage_'. $this->id++ ); - - return $id; - } - - /** - * Finally save image - * - * @param string $file Destination filename - * @return void - */ - public function render ( $file ) - { - $this->drawAllTexts(); - $movie = $this->getDocument(); - $movie->save( $file, $this->options->compression ); - } -} - -?> Copied: trunk/Graph/src/exceptions/flash_bitmap_boundings.php (from rev 4134, trunk/Graph/src/exceptions/ming_bitmap_boundings.php) =================================================================== --- trunk/Graph/src/exceptions/ming_bitmap_boundings.php 2006-11-29 17:20:39 UTC (rev 4134) +++ trunk/Graph/src/exceptions/flash_bitmap_boundings.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -0,0 +1,25 @@ +<?php +/** + * File containing the ezcGraphFlashBitmapBoundingsException class + * + * @package Graph + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Flash does not support bitmap scaling, so that this exceptions is thrown + * when an image does not have the requested size. + * + * @package Graph + * @version //autogen// + */ +class ezcGraphFlashBitmapBoundingsException extends ezcGraphException +{ + public function __construct( $imageWidth, $imageHeight, $reqWidth, $reqHeight ) + { + parent::__construct( "Flash does not support bitmap scaling, so that it is up to you to scale the image '$imageWidth' * '$imageHeight' to '$reqWidth' * '$reqHeight'." ); + } +} + +?> Copied: trunk/Graph/src/exceptions/flash_bitmap_type.php (from rev 4134, trunk/Graph/src/exceptions/ming_bitmap_type.php) =================================================================== --- trunk/Graph/src/exceptions/ming_bitmap_type.php 2006-11-29 17:20:39 UTC (rev 4134) +++ trunk/Graph/src/exceptions/flash_bitmap_type.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -0,0 +1,25 @@ +<?php +/** + * File containing the ezcGraphFlashBitmapTypeException class + * + * @package Graph + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Flash can only read non interlaced bitmaps. This exception is thrown for + * all other image types. + * + * @package Graph + * @version //autogen// + */ +class ezcGraphFlashBitmapTypeException extends ezcGraphException +{ + public function __construct( $type ) + { + parent::__construct( "Flash can only read non interlaced JPEGs." ); + } +} + +?> Deleted: trunk/Graph/src/exceptions/ming_bitmap_boundings.php =================================================================== --- trunk/Graph/src/exceptions/ming_bitmap_boundings.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/src/exceptions/ming_bitmap_boundings.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -1,25 +0,0 @@ -<?php -/** - * File containing the ezcGraphMingBitmapBoundingsException class - * - * @package Graph - * @version //autogen// - * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - */ -/** - * Ming does not support bitmap scaling, so that this exceptions is thrown - * when an image does not have the requested size. - * - * @package Graph - * @version //autogen// - */ -class ezcGraphMingBitmapBoundingsException extends ezcGraphException -{ - public function __construct( $imageWidth, $imageHeight, $reqWidth, $reqHeight ) - { - parent::__construct( "Ming does not support bitmap scaling, so that it is up to you to scale the image '$imageWidth' * '$imageHeight' to '$reqWidth' * '$reqHeight'." ); - } -} - -?> Deleted: trunk/Graph/src/exceptions/ming_bitmap_type.php =================================================================== --- trunk/Graph/src/exceptions/ming_bitmap_type.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/src/exceptions/ming_bitmap_type.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -1,25 +0,0 @@ -<?php -/** - * File containing the ezcGraphMingBitmapTypeException class - * - * @package Graph - * @version //autogen// - * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - */ -/** - * Ming can only read non interlaced bitmaps. This exception is thrown for - * all other image types. - * - * @package Graph - * @version //autogen// - */ -class ezcGraphMingBitmapTypeException extends ezcGraphException -{ - public function __construct( $type ) - { - parent::__construct( "Ming can only read non interlaced JPEGs." ); - } -} - -?> Modified: trunk/Graph/src/graph_autoload.php =================================================================== --- trunk/Graph/src/graph_autoload.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/src/graph_autoload.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -55,10 +55,10 @@ 'ezcGraphSvgDriverOptions' => 'Graph/options/svg_driver.php', 'ezcGraphSvgDriverInvalidIdException' => 'Graph/exceptions/invalid_id.php', 'ezcGraphVerboseDriver' => 'Graph/driver/verbose.php', - 'ezcGraphMingDriver' => 'Graph/driver/ming.php', - 'ezcGraphMingDriverOptions' => 'Graph/options/ming_driver.php', - 'ezcGraphMingBitmapTypeException' => 'Graph/exceptions/ming_bitmap_type.php', - 'ezcGraphMingBitmapBoundingsException' => 'Graph/exceptions/ming_bitmap_boundings.php', + 'ezcGraphFlashDriver' => 'Graph/driver/flash.php', + 'ezcGraphFlashDriverOptions' => 'Graph/options/flash_driver.php', + 'ezcGraphFlashBitmapTypeException' => 'Graph/exceptions/flash_bitmap_type.php', + 'ezcGraphFlashBitmapBoundingsException' => 'Graph/exceptions/flash_bitmap_boundings.php', 'ezcGraphPalette' => 'Graph/interfaces/palette.php', 'ezcGraphPaletteTango' => 'Graph/palette/tango.php', Copied: trunk/Graph/src/options/flash_driver.php (from rev 4134, trunk/Graph/src/options/ming_driver.php) =================================================================== --- trunk/Graph/src/options/ming_driver.php 2006-11-29 17:20:39 UTC (rev 4134) +++ trunk/Graph/src/options/flash_driver.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -0,0 +1,79 @@ +<?php +/** + * File containing the ezcGraphFlashDriverOption class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Class containing the basic options for charts + * + * @property int $compression + * Compression level used for generated flash file + * @see http://php.net/manual/en/function.swfmovie.save.php + * @property float $circleResolution + * Resolution for circles, until I understand how to draw ellipses + * with SWFShape::curveTo() + * + * @package Graph + */ +class ezcGraphFlashDriverOptions extends ezcGraphDriverOptions +{ + /** + * Constructor + * + * @param array $options Default option array + * @return void + * @ignore + */ + public function __construct( array $options = array() ) + { + $this->properties['compression'] = 9; + $this->properties['circleResolution'] = 2.; + + parent::__construct( $options ); + } + + /** + * Set an option value + * + * @param string $propertyName + * @param mixed $propertyValue + * @throws ezcBasePropertyNotFoundException + * If a property is not defined in this class + * @return void + * @ignore + */ + public function __set( $propertyName, $propertyValue ) + { + switch ( $propertyName ) + { + case 'compression': + if ( !is_numeric( $propertyValue ) || + ( $propertyValue < 0 ) || + ( $propertyValue > 9 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 9' ); + } + + $this->properties['compression'] = max( 0, min( 9, (int) $propertyValue ) ); + break; + case 'circleResolution': + if ( !is_numeric( $propertyValue ) || + ( $propertyValue <= 0 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); + } + + $this->properties['circleResolution'] = (float) $propertyValue; + break; + default: + parent::__set( $propertyName, $propertyValue ); + break; + } + } +} + +?> Deleted: trunk/Graph/src/options/ming_driver.php =================================================================== --- trunk/Graph/src/options/ming_driver.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/src/options/ming_driver.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -1,79 +0,0 @@ -<?php -/** - * File containing the ezcGraphMingDriverOption class - * - * @package Graph - * @version //autogentag// - * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - */ -/** - * Class containing the basic options for charts - * - * @property int $compression - * Compression level used for generated flash file - * @see http://php.net/manual/en/function.swfmovie.save.php - * @property float $circleResolution - * Resolution for circles, until I understand how to draw ellipses - * with SWFShape::curveTo() - * - * @package Graph - */ -class ezcGraphMingDriverOptions extends ezcGraphDriverOptions -{ - /** - * Constructor - * - * @param array $options Default option array - * @return void - * @ignore - */ - public function __construct( array $options = array() ) - { - $this->properties['compression'] = 9; - $this->properties['circleResolution'] = 2.; - - parent::__construct( $options ); - } - - /** - * Set an option value - * - * @param string $propertyName - * @param mixed $propertyValue - * @throws ezcBasePropertyNotFoundException - * If a property is not defined in this class - * @return void - * @ignore - */ - public function __set( $propertyName, $propertyValue ) - { - switch ( $propertyName ) - { - case 'compression': - if ( !is_numeric( $propertyValue ) || - ( $propertyValue < 0 ) || - ( $propertyValue > 9 ) ) - { - throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 9' ); - } - - $this->properties['compression'] = max( 0, min( 9, (int) $propertyValue ) ); - break; - case 'circleResolution': - if ( !is_numeric( $propertyValue ) || - ( $propertyValue <= 0 ) ) - { - throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); - } - - $this->properties['circleResolution'] = (float) $propertyValue; - break; - default: - parent::__set( $propertyName, $propertyValue ); - break; - } - } -} - -?> Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleFilled.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleFilled.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleLinearFill.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleLinearFill.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleLinearFilledLine.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleLinearFilledLine.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleNonFilled.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleNonFilled.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleRadialFill.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleRadialFill.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleRadialFilledLine.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleRadialFilledLine.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcute.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcute.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteNonFilled.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcuteNonFilled.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorAcuteReverse.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcuteReverse.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircleSectorObtuse.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorObtuse.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcAcute.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcute.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcAcuteBorder.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcuteBorder.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcAcuteReverse.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcuteReverse.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawCircularArcObtuse.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcObtuse.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawLine.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawLine.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleBigCircleSectors.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleBigCircleSectors.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleCircleSectors.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleCircleSectors.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleCircularArcs.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleCircularArcs.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawMultipleFilledTransparentPolygons.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleFilledTransparentPolygons.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonFivePoints.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonFivePoints.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonThreePointsFilled.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonThreePointsFilled.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawPolygonThreePointsNotFilled.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonThreePointsNotFilled.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawStringWithSpecialChars.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawStringWithSpecialChars.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedString.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedString.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringCenter.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringCenter.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringRight.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringRight.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxLongString.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongString.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxManualBreak.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxManualBreak.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxShortString.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxShortString.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringCenter.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringCenter.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringCenterMiddle.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringCenterMiddle.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringRight.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringRight.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringRightBottom.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringRightBottom.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextBoxStringSampleRight.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringSampleRight.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithBackground.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithBackground.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithBorder.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithBorder.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithCustomTextShadow.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithCustomTextShadow.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithMinimizedBorderAndBackgroundBottomRight.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundBottomRight.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithMinimizedBorderAndBackgroundTopLeft.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundTopLeft.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testDrawTextWithTextShadow.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithTextShadow.swf) Copied: trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderLabeledFlashPieChart.swf (from rev 4134, trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testRenderLabeledFlashPieChart.swf) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleFilled.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleLinearFill.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleLinearFilledLine.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleNonFilled.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleRadialFill.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleRadialFilledLine.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcute.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcuteNonFilled.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorAcuteReverse.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircleSectorObtuse.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcute.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcuteBorder.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcAcuteReverse.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawCircularArcObtuse.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawLine.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleBigCircleSectors.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleCircleSectors.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleCircularArcs.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawMultipleFilledTransparentPolygons.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonFivePoints.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonThreePointsFilled.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawPolygonThreePointsNotFilled.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawStringWithSpecialChars.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedString.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringCenter.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringRight.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxLongString.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxManualBreak.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxShortString.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringCenter.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringCenterMiddle.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringRight.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringRightBottom.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextBoxStringSampleRight.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithBackground.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithBorder.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithCustomTextShadow.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundBottomRight.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithMinimizedBorderAndBackgroundTopLeft.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testDrawTextWithTextShadow.swf =================================================================== (Binary files differ) Deleted: trunk/Graph/tests/data/compare/ezcGraphMingDriverTest_testRenderLabeledFlashPieChart.swf =================================================================== (Binary files differ) Copied: trunk/Graph/tests/driver_flash_test.php (from rev 4134, trunk/Graph/tests/driver_ming_test.php) =================================================================== --- trunk/Graph/tests/driver_ming_test.php 2006-11-29 17:20:39 UTC (rev 4134) +++ trunk/Graph/tests/driver_flash_test.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -0,0 +1,1476 @@ +<?php +/** + * ezcGraphFlashDriverTest + * + * @package Graph + * @version //autogen// + * @subpackage Tests + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Tests for ezcGraph class. + * + * @package ImageAnalysis + * @subpackage Tests + */ +class ezcGraphFlashDriverTest extends ezcTestCase +{ + protected $driver; + + protected $tempDir; + + protected $basePath; + + protected $testFiles = array( + 'jpeg' => 'jpeg.jpg', + 'png' => 'png.png', + 'gif' => 'gif.gif', + ); + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcGraphFlashDriverTest" ); + } + + protected function setUp() + { + if ( !ezcBaseFeatures::hasExtensionSupport( 'ming' ) ) + { + $this->markTestSkipped( 'This test needs ext/ming support.' ); + } + + static $i = 0; + $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/'; + $this->basePath = dirname( __FILE__ ) . '/data/'; + + $this->driver = new ezcGraphFlashDriver(); + $this->driver->options->width = 200; + $this->driver->options->height = 100; + + $this->driver->options->font->path = $this->basePath . 'fdb_font.fdb'; + } + + protected function tearDown() + { + unset( $this->driver ); + if ( !$this->hasFailed() ) + { + $this->removeTempDir(); + } + } + + /** + * Compares a generated image with a stored file + * + * @param string $generated Filename of generated image + * @param string $compare Filename of stored image + * @return void + */ + protected function compare( $generated, $compare ) + { + $this->assertTrue( + file_exists( $generated ), + 'No image file has been created.' + ); + + $this->assertTrue( + file_exists( $compare ), + 'Comparision image does not exist.' + ); + + if ( md5_file( $generated ) !== md5_file( $compare ) ) + { + // Adding a diff makes no sense here, because created XML uses + // only two lines + $this->fail( 'Rendered image is not correct.'); + } + } + + public function testDrawLine() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawLine( + new ezcGraphCoordinate( 12, 45 ), + new ezcGraphCoordinate( 134, 12 ), + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawPolygonThreePointsFilled() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 45, 12 ), + new ezcGraphCoordinate( 122, 34 ), + new ezcGraphCoordinate( 12, 71 ), + ), + ezcGraphColor::fromHex( '#3465A4' ), + true + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphPolygon_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawPolygonThreePointsNotFilled() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 45, 12 ), + new ezcGraphCoordinate( 122, 34 ), + new ezcGraphCoordinate( 12, 71 ), + ), + ezcGraphColor::fromHex( '#3465A4' ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawPolygonFivePoints() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 45, 12 ), + new ezcGraphCoordinate( 122, 34 ), + new ezcGraphCoordinate( 12, 71 ), + new ezcGraphCoordinate( 3, 45 ), + new ezcGraphCoordinate( 60, 32 ), + ), + ezcGraphColor::fromHex( '#3465A4' ), + true + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircleSectorAcute() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + 12.5, + 25, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircleSector_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawMultipleCircleSectors() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $angles = array( 10, 25, 45, 75, 110, 55 ); + + $startAngle = 0; + foreach ( $angles as $angle ) + { + $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + $startAngle, + $startAngle += $angle, + ezcGraphColor::fromHex( '#3465A4' ) + ); + $startAngle += 5; + } + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawMultipleBigCircleSectors() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $angles = array( 135, 250 ); + + $startAngle = 5; + foreach ( $angles as $angle ) + { + $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + $startAngle, + $startAngle += $angle, + ezcGraphColor::fromHex( '#3465A4' ) + ); + $startAngle += 5; + } + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircleSectorAcuteNonFilled() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + 12.5, + 45, + ezcGraphColor::fromHex( '#3465A4' ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircleSectorAcuteReverse() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + 25, + 12.5, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircleSectorObtuse() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircleSector( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + 25, + 273, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircularArcAcute() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircularArc( + new ezcGraphCoordinate( 100, 50 ), + 150, + 80, + 10, + 12.5, + 55, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircularArc_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawCircularArcAcuteBorder() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircularArc( + new ezcGraphCoordinate( 100, 50 ), + 150, + 80, + 10, + 12.5, + 55, + ezcGraphColor::fromHex( '#3465A4' ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircularArcAcuteReverse() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircularArc( + new ezcGraphCoordinate( 100, 50 ), + 150, + 80, + 10, + 55, + 12.5, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircularArcObtuse() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircularArc( + new ezcGraphCoordinate( 100, 50 ), + 150, + 80, + 10, + 25, + 300, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawCircleFilled() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircle( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + ezcGraphColor::fromHex( '#3465A4' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircle_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawCircleNonFilled() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawCircle( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + ezcGraphColor::fromHex( '#3465A4' ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawImageOutOfBoundings() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + try + { + $return = $this->driver->drawImage( + $this->basePath . $this->testFiles['jpeg'], + new ezcGraphCoordinate( 10, 10 ), + 100, + 50 + ); + } + catch ( ezcGraphFlashBitmapBoundingsException $e ) + { + return true; + } + + $this->fail( 'Expected ezcGraphFlashBitmapBoundingsException.' ); + } + + public function testDrawImageGif() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + try + { + $return = $this->driver->drawImage( + $this->basePath . $this->testFiles['gif'], + new ezcGraphCoordinate( 10, 10 ), + 150, + 100 + ); + } + catch ( ezcGraphFlashBitmapTypeException $e ) + { + return true; + } + + $this->fail( 'Expected ezcGraphFlashBitmapTypeException.' ); + } + + public function testDrawImagePng() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + try + { + $return = $this->driver->drawImage( + $this->basePath . $this->testFiles['png'], + new ezcGraphCoordinate( 10, 10 ), + 177, + 100 + ); + } + catch ( ezcGraphFlashBitmapTypeException $e ) + { + return true; + } + + $this->fail( 'Expected ezcGraphFlashBitmapBoundingsException.' ); + } + + public function testDrawImageJpeg() + { + $this->fail( 'Ends up in a recursive loop somehow caused by PHPUnits error handling and exception conversion.' ); + + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawImage( + $this->basePath . $this->testFiles['non_interlaced'], + new ezcGraphCoordinate( 10, 10 ), + 177, + 100 + ); + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxShortString() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $return = $this->driver->drawTextBox( + 'Short', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphTextBox_2', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawTextBoxLongString() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'ThisIsAPrettyLongString', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxLongSpacedString() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'This Is A Pretty Long String', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxManualBreak() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + "New\nLine", + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxStringSampleRight() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 20, 20 ), + new ezcGraphCoordinate( 110, 20 ), + new ezcGraphCoordinate( 110, 30 ), + new ezcGraphCoordinate( 20, 30 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'sample 4', + new ezcGraphCoordinate( 21, 21 ), + 88, + 8, + ezcGraph::RIGHT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxStringRight() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'ThisIsAPrettyLongString', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::RIGHT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxLongSpacedStringRight() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'This Is A Pretty Long String', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::RIGHT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxStringCenter() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'ThisIsAPrettyLongString', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::CENTER + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxLongSpacedStringCenter() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'This Is A Pretty Long String', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::CENTER + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxStringRightBottom() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'ThisIsAPrettyLongString', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::RIGHT | ezcGraph::BOTTOM + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxLongSpacedStringRightMiddle() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'This Is A Pretty Long String', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::RIGHT | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxStringCenterMiddle() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'ThisIsAPrettyLongString', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::CENTER | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextBoxLongSpacedStringCenterBottom() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 10, 10 ), + new ezcGraphCoordinate( 160, 10 ), + new ezcGraphCoordinate( 160, 80 ), + new ezcGraphCoordinate( 10, 80 ), + ), + ezcGraphColor::fromHex( '#eeeeec' ), + true + ); + $this->driver->drawTextBox( + 'This Is A Pretty Long String', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::CENTER | ezcGraph::BOTTOM + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawStringWithSpecialChars() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 47, 54 ), + new ezcGraphCoordinate( 47, 84 ), + new ezcGraphCoordinate( 99, 84 ), + new ezcGraphCoordinate( 99, 54 ), + ), + ezcGraphColor::fromHex( '#DDDDDD' ), + true + ); + $this->driver->drawTextBox( + 'Safari (13.8%)', + new ezcGraphCoordinate( 47, 54 ), + 52, + 30, + ezcGraph::LEFT + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithTextShadow() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); + $this->driver->options->font->textShadow = true; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithCustomTextShadow() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); + $this->driver->options->font->textShadow = true; + $this->driver->options->font->textShadowColor = '#888888'; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithBackground() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); + $this->driver->options->font->minimizeBorder = false; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithBorder() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); + $this->driver->options->font->minimizeBorder = false; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithMinimizedBorderAndBackgroundTopLeft() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); + $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); + $this->driver->options->font->minimizeBorder = true; + $this->driver->options->font->padding = 2; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::LEFT | ezcGraph::TOP + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); + $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); + $this->driver->options->font->minimizeBorder = true; + $this->driver->options->font->padding = 2; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::CENTER | ezcGraph::MIDDLE + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTextWithMinimizedBorderAndBackgroundBottomRight() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); + $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); + $this->driver->options->font->minimizeBorder = true; + $this->driver->options->font->padding = 2; + + $this->driver->drawTextBox( + 'Some test string', + new ezcGraphCoordinate( 10, 10 ), + 150, + 70, + ezcGraph::RIGHT | ezcGraph::BOTTOM + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawTooLongTextException() + { + $filename = $this->tempDir . __FUNCTION__ . '.png'; + + try + { + $this->driver->drawTextBox( + 'This is very long text which is not supposed to fit in the bounding box.', + new ezcGraphCoordinate( 10, 10 ), + 50, + 20, + ezcGraph::LEFT + ); + + $this->driver->render( $filename ); + } + catch ( ezcGraphFontRenderingException $e ) + { + return true; + } + + $this->fail( 'Expected ezcGraphFontRenderingException.' ); + } + + public function testDrawCircleRadialFill() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircle( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + new ezcGraphRadialGradient( + new ezcGraphCoordinate( 80, 40), + 80, + 40, + ezcGraphColor::fromHex( '#729FCF' ), + ezcGraphColor::fromHex( '#3465A4' ) + ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircle_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawCircleLinearFill() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircle( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + new ezcGraphLinearGradient( + $start = new ezcGraphCoordinate( 80, 40 ), + $end = new ezcGraphCoordinate( 130, 55 ), + ezcGraphColor::fromHex( '#82BFFF' ), + ezcGraphColor::fromHex( '#3465A4' ) + ) + ); + + $this->driver->drawCircle( + $start, + 2, 2, ezcGraphColor::fromHex( '#CC0000' ) + ); + $this->driver->drawCircle( + $end, + 2, 2, ezcGraphColor::fromHex( '#CC0000' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircle_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawCircleRadialFilledLine() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircle( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + new ezcGraphRadialGradient( + new ezcGraphCoordinate( 80, 40), + 80, + 40, + ezcGraphColor::fromHex( '#729FCF' ), + ezcGraphColor::fromHex( '#3465A4' ) + ), + false + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircle_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testDrawCircleLinearFilledLine() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $return = $this->driver->drawCircle( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + new ezcGraphLinearGradient( + $start = new ezcGraphCoordinate( 80, 40 ), + $end = new ezcGraphCoordinate( 130, 55 ), + ezcGraphColor::fromHex( '#82BFFF' ), + ezcGraphColor::fromHex( '#3465A4' ) + ), + false + ); + + $this->driver->drawCircle( + $start, + 2, 2, ezcGraphColor::fromHex( '#CC0000' ) + ); + $this->driver->drawCircle( + $end, + 2, 2, ezcGraphColor::fromHex( '#CC0000' ) + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + + $this->assertEquals( + 'ezcGraphCircle_1', + $return, + 'Expected flash object id as return value.' + ); + } + + public function testRenderLabeledFlashPieChart() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $chart = new ezcGraphPieChart(); + $chart->options->font->path = dirname( __FILE__ ) . '/data/fdb_font.fdb'; + + $chart->palette = new ezcGraphPaletteEz(); + $chart->data['sample'] = new ezcGraphArrayDataSet( array( + 'Mozilla' => 4375, + 'IE' => 345, + 'Opera' => 1204, + 'wget' => 231, + 'Safari' => 987, + ) ); + + $chart->data['sample']->highlight['Safari'] = true; + + $chart->renderer = new ezcGraphRenderer3d(); + + $chart->renderer->options->pieChartShadowSize = 10; + $chart->renderer->options->pieChartGleam = .5; + $chart->renderer->options->dataBorder = false; + $chart->renderer->options->pieChartHeight = 16; + $chart->renderer->options->legendSymbolGleam = .5; + + $chart->driver = new ezcGraphFlashDriver(); + $chart->render( 500, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawMultipleFilledTransparentPolygons() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 45, 12 ), + new ezcGraphCoordinate( 122, 34 ), + new ezcGraphCoordinate( 12, 71 ), + ), + ezcGraphColor::fromHex( '#3465A4DD' ), + true + ); + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 150, 13 ), + new ezcGraphCoordinate( 90, 60 ), + new ezcGraphCoordinate( 120, 5 ), + ), + ezcGraphColor::fromHex( '#A40000DD' ), + true + ); + $this->driver->drawPolygon( + array( + new ezcGraphCoordinate( 170, 78 ), + new ezcGraphCoordinate( 60, 24 ), + new ezcGraphCoordinate( 140, 50 ), + ), + ezcGraphColor::fromHex( '#EDD400DD' ), + true + ); + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testDrawMultipleCircularArcs() + { + $filename = $this->tempDir . __FUNCTION__ . '.swf'; + + $angles = array( 10, 25, 45, 75, 110, 55 ); + + $startAngle = 0; + foreach ( $angles as $angle ) + { + $this->driver->drawCircularArc( + new ezcGraphCoordinate( 100, 50 ), + 80, + 40, + 10, + $startAngle, + $startAngle += $angle, + ezcGraphColor::fromHex( '#3465A455' ), + false + ); + $startAngle += 5; + } + + $this->driver->render( $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' + ); + } + + public function testFlashDriverOptionsPropertyCompression() + { + $options = new ezcGraphFlashDriverOptions(); + + $this->assertSame( + 9, + $options->compression, + 'Wrong default value for property compression in class ezcGraphFlashDriverOptions' + ); + + $options->compression = 4; + $this->assertSame( + 4, + $options->compression, + 'Setting property value did not work for property compression in class ezcGraphFlashDriverOptions' + ); + + try + { + $options->compression = false; + } + catch( ezcBaseValueException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBaseValueException.' ); + } + + public function testFlashDriverOptionsPropertyCircleResolution() + { + $options = new ezcGraphFlashDriverOptions(); + + $this->assertSame( + 2., + $options->circleResolution, + 'Wrong default value for property circleResolution in class ezcGraphFlashDriverOptions' + ); + + $options->circleResolution = 5.; + $this->assertSame( + 5., + $options->circleResolution, + 'Setting property value did not work for property circleResolution in class ezcGraphFlashDriverOptions' + ); + + try + { + $options->circleResolution = false; + } + catch( ezcBaseValueException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBaseValueException.' ); + } +} +?> Deleted: trunk/Graph/tests/driver_ming_test.php =================================================================== --- trunk/Graph/tests/driver_ming_test.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/tests/driver_ming_test.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -1,1476 +0,0 @@ -<?php -/** - * ezcGraphMingDriverTest - * - * @package Graph - * @version //autogen// - * @subpackage Tests - * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - */ - -/** - * Tests for ezcGraph class. - * - * @package ImageAnalysis - * @subpackage Tests - */ -class ezcGraphMingDriverTest extends ezcTestCase -{ - protected $driver; - - protected $tempDir; - - protected $basePath; - - protected $testFiles = array( - 'jpeg' => 'jpeg.jpg', - 'png' => 'png.png', - 'gif' => 'gif.gif', - ); - - public static function suite() - { - return new PHPUnit_Framework_TestSuite( "ezcGraphMingDriverTest" ); - } - - protected function setUp() - { - if ( !ezcBaseFeatures::hasExtensionSupport( 'ming' ) ) - { - $this->markTestSkipped( 'This test needs ext/ming support.' ); - } - - static $i = 0; - $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/'; - $this->basePath = dirname( __FILE__ ) . '/data/'; - - $this->driver = new ezcGraphMingDriver(); - $this->driver->options->width = 200; - $this->driver->options->height = 100; - - $this->driver->options->font->path = $this->basePath . 'fdb_font.fdb'; - } - - protected function tearDown() - { - unset( $this->driver ); - if ( !$this->hasFailed() ) - { - $this->removeTempDir(); - } - } - - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - - public function testDrawLine() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawLine( - new ezcGraphCoordinate( 12, 45 ), - new ezcGraphCoordinate( 134, 12 ), - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawPolygonThreePointsFilled() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 45, 12 ), - new ezcGraphCoordinate( 122, 34 ), - new ezcGraphCoordinate( 12, 71 ), - ), - ezcGraphColor::fromHex( '#3465A4' ), - true - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphPolygon_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawPolygonThreePointsNotFilled() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 45, 12 ), - new ezcGraphCoordinate( 122, 34 ), - new ezcGraphCoordinate( 12, 71 ), - ), - ezcGraphColor::fromHex( '#3465A4' ), - false - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawPolygonFivePoints() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 45, 12 ), - new ezcGraphCoordinate( 122, 34 ), - new ezcGraphCoordinate( 12, 71 ), - new ezcGraphCoordinate( 3, 45 ), - new ezcGraphCoordinate( 60, 32 ), - ), - ezcGraphColor::fromHex( '#3465A4' ), - true - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircleSectorAcute() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircleSector( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - 12.5, - 25, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircleSector_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawMultipleCircleSectors() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $angles = array( 10, 25, 45, 75, 110, 55 ); - - $startAngle = 0; - foreach ( $angles as $angle ) - { - $this->driver->drawCircleSector( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - $startAngle, - $startAngle += $angle, - ezcGraphColor::fromHex( '#3465A4' ) - ); - $startAngle += 5; - } - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawMultipleBigCircleSectors() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $angles = array( 135, 250 ); - - $startAngle = 5; - foreach ( $angles as $angle ) - { - $this->driver->drawCircleSector( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - $startAngle, - $startAngle += $angle, - ezcGraphColor::fromHex( '#3465A4' ) - ); - $startAngle += 5; - } - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircleSectorAcuteNonFilled() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircleSector( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - 12.5, - 45, - ezcGraphColor::fromHex( '#3465A4' ), - false - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircleSectorAcuteReverse() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircleSector( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - 25, - 12.5, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircleSectorObtuse() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircleSector( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - 25, - 273, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircularArcAcute() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircularArc( - new ezcGraphCoordinate( 100, 50 ), - 150, - 80, - 10, - 12.5, - 55, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircularArc_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawCircularArcAcuteBorder() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircularArc( - new ezcGraphCoordinate( 100, 50 ), - 150, - 80, - 10, - 12.5, - 55, - ezcGraphColor::fromHex( '#3465A4' ), - false - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircularArcAcuteReverse() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircularArc( - new ezcGraphCoordinate( 100, 50 ), - 150, - 80, - 10, - 55, - 12.5, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircularArcObtuse() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircularArc( - new ezcGraphCoordinate( 100, 50 ), - 150, - 80, - 10, - 25, - 300, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawCircleFilled() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircle( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - ezcGraphColor::fromHex( '#3465A4' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircle_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawCircleNonFilled() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawCircle( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - ezcGraphColor::fromHex( '#3465A4' ), - false - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawImageOutOfBoundings() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - try - { - $return = $this->driver->drawImage( - $this->basePath . $this->testFiles['jpeg'], - new ezcGraphCoordinate( 10, 10 ), - 100, - 50 - ); - } - catch ( ezcGraphMingBitmapBoundingsException $e ) - { - return true; - } - - $this->fail( 'Expected ezcGraphMingBitmapBoundingsException.' ); - } - - public function testDrawImageGif() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - try - { - $return = $this->driver->drawImage( - $this->basePath . $this->testFiles['gif'], - new ezcGraphCoordinate( 10, 10 ), - 150, - 100 - ); - } - catch ( ezcGraphMingBitmapTypeException $e ) - { - return true; - } - - $this->fail( 'Expected ezcGraphMingBitmapTypeException.' ); - } - - public function testDrawImagePng() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - try - { - $return = $this->driver->drawImage( - $this->basePath . $this->testFiles['png'], - new ezcGraphCoordinate( 10, 10 ), - 177, - 100 - ); - } - catch ( ezcGraphMingBitmapTypeException $e ) - { - return true; - } - - $this->fail( 'Expected ezcGraphMingBitmapBoundingsException.' ); - } - - public function testDrawImageJpeg() - { - $this->fail( 'Ends up in a recursive loop somehow caused by PHPUnits error handling and exception conversion.' ); - - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawImage( - $this->basePath . $this->testFiles['non_interlaced'], - new ezcGraphCoordinate( 10, 10 ), - 177, - 100 - ); - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxShortString() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $return = $this->driver->drawTextBox( - 'Short', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphTextBox_2', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawTextBoxLongString() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'ThisIsAPrettyLongString', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxLongSpacedString() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'This Is A Pretty Long String', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxManualBreak() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - "New\nLine", - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxStringSampleRight() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 20, 20 ), - new ezcGraphCoordinate( 110, 20 ), - new ezcGraphCoordinate( 110, 30 ), - new ezcGraphCoordinate( 20, 30 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'sample 4', - new ezcGraphCoordinate( 21, 21 ), - 88, - 8, - ezcGraph::RIGHT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxStringRight() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'ThisIsAPrettyLongString', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::RIGHT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxLongSpacedStringRight() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'This Is A Pretty Long String', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::RIGHT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxStringCenter() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'ThisIsAPrettyLongString', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::CENTER - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxLongSpacedStringCenter() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'This Is A Pretty Long String', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::CENTER - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxStringRightBottom() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'ThisIsAPrettyLongString', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::RIGHT | ezcGraph::BOTTOM - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxLongSpacedStringRightMiddle() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'This Is A Pretty Long String', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::RIGHT | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxStringCenterMiddle() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'ThisIsAPrettyLongString', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::CENTER | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextBoxLongSpacedStringCenterBottom() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 10, 10 ), - new ezcGraphCoordinate( 160, 10 ), - new ezcGraphCoordinate( 160, 80 ), - new ezcGraphCoordinate( 10, 80 ), - ), - ezcGraphColor::fromHex( '#eeeeec' ), - true - ); - $this->driver->drawTextBox( - 'This Is A Pretty Long String', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::CENTER | ezcGraph::BOTTOM - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawStringWithSpecialChars() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 47, 54 ), - new ezcGraphCoordinate( 47, 84 ), - new ezcGraphCoordinate( 99, 84 ), - new ezcGraphCoordinate( 99, 54 ), - ), - ezcGraphColor::fromHex( '#DDDDDD' ), - true - ); - $this->driver->drawTextBox( - 'Safari (13.8%)', - new ezcGraphCoordinate( 47, 54 ), - 52, - 30, - ezcGraph::LEFT - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithTextShadow() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); - $this->driver->options->font->textShadow = true; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithCustomTextShadow() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); - $this->driver->options->font->textShadow = true; - $this->driver->options->font->textShadowColor = '#888888'; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithBackground() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); - $this->driver->options->font->minimizeBorder = false; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithBorder() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); - $this->driver->options->font->minimizeBorder = false; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithMinimizedBorderAndBackgroundTopLeft() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); - $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); - $this->driver->options->font->minimizeBorder = true; - $this->driver->options->font->padding = 2; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::LEFT | ezcGraph::TOP - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithMinimizedBorderAndBackgroundMiddleCenter() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); - $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); - $this->driver->options->font->minimizeBorder = true; - $this->driver->options->font->padding = 2; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::CENTER | ezcGraph::MIDDLE - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTextWithMinimizedBorderAndBackgroundBottomRight() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->options->font->border = ezcGraphColor::fromHex( '#555555' ); - $this->driver->options->font->background = ezcGraphColor::fromHex( '#DDDDDD' ); - $this->driver->options->font->minimizeBorder = true; - $this->driver->options->font->padding = 2; - - $this->driver->drawTextBox( - 'Some test string', - new ezcGraphCoordinate( 10, 10 ), - 150, - 70, - ezcGraph::RIGHT | ezcGraph::BOTTOM - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawTooLongTextException() - { - $filename = $this->tempDir . __FUNCTION__ . '.png'; - - try - { - $this->driver->drawTextBox( - 'This is very long text which is not supposed to fit in the bounding box.', - new ezcGraphCoordinate( 10, 10 ), - 50, - 20, - ezcGraph::LEFT - ); - - $this->driver->render( $filename ); - } - catch ( ezcGraphFontRenderingException $e ) - { - return true; - } - - $this->fail( 'Expected ezcGraphFontRenderingException.' ); - } - - public function testDrawCircleRadialFill() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircle( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - new ezcGraphRadialGradient( - new ezcGraphCoordinate( 80, 40), - 80, - 40, - ezcGraphColor::fromHex( '#729FCF' ), - ezcGraphColor::fromHex( '#3465A4' ) - ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircle_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawCircleLinearFill() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircle( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - new ezcGraphLinearGradient( - $start = new ezcGraphCoordinate( 80, 40 ), - $end = new ezcGraphCoordinate( 130, 55 ), - ezcGraphColor::fromHex( '#82BFFF' ), - ezcGraphColor::fromHex( '#3465A4' ) - ) - ); - - $this->driver->drawCircle( - $start, - 2, 2, ezcGraphColor::fromHex( '#CC0000' ) - ); - $this->driver->drawCircle( - $end, - 2, 2, ezcGraphColor::fromHex( '#CC0000' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircle_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawCircleRadialFilledLine() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircle( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - new ezcGraphRadialGradient( - new ezcGraphCoordinate( 80, 40), - 80, - 40, - ezcGraphColor::fromHex( '#729FCF' ), - ezcGraphColor::fromHex( '#3465A4' ) - ), - false - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircle_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testDrawCircleLinearFilledLine() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $return = $this->driver->drawCircle( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - new ezcGraphLinearGradient( - $start = new ezcGraphCoordinate( 80, 40 ), - $end = new ezcGraphCoordinate( 130, 55 ), - ezcGraphColor::fromHex( '#82BFFF' ), - ezcGraphColor::fromHex( '#3465A4' ) - ), - false - ); - - $this->driver->drawCircle( - $start, - 2, 2, ezcGraphColor::fromHex( '#CC0000' ) - ); - $this->driver->drawCircle( - $end, - 2, 2, ezcGraphColor::fromHex( '#CC0000' ) - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - - $this->assertEquals( - 'ezcGraphCircle_1', - $return, - 'Expected flash object id as return value.' - ); - } - - public function testRenderLabeledFlashPieChart() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $chart = new ezcGraphPieChart(); - $chart->options->font->path = dirname( __FILE__ ) . '/data/fdb_font.fdb'; - - $chart->palette = new ezcGraphPaletteEz(); - $chart->data['sample'] = new ezcGraphArrayDataSet( array( - 'Mozilla' => 4375, - 'IE' => 345, - 'Opera' => 1204, - 'wget' => 231, - 'Safari' => 987, - ) ); - - $chart->data['sample']->highlight['Safari'] = true; - - $chart->renderer = new ezcGraphRenderer3d(); - - $chart->renderer->options->pieChartShadowSize = 10; - $chart->renderer->options->pieChartGleam = .5; - $chart->renderer->options->dataBorder = false; - $chart->renderer->options->pieChartHeight = 16; - $chart->renderer->options->legendSymbolGleam = .5; - - $chart->driver = new ezcGraphMingDriver(); - $chart->render( 500, 200, $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawMultipleFilledTransparentPolygons() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 45, 12 ), - new ezcGraphCoordinate( 122, 34 ), - new ezcGraphCoordinate( 12, 71 ), - ), - ezcGraphColor::fromHex( '#3465A4DD' ), - true - ); - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 150, 13 ), - new ezcGraphCoordinate( 90, 60 ), - new ezcGraphCoordinate( 120, 5 ), - ), - ezcGraphColor::fromHex( '#A40000DD' ), - true - ); - $this->driver->drawPolygon( - array( - new ezcGraphCoordinate( 170, 78 ), - new ezcGraphCoordinate( 60, 24 ), - new ezcGraphCoordinate( 140, 50 ), - ), - ezcGraphColor::fromHex( '#EDD400DD' ), - true - ); - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testDrawMultipleCircularArcs() - { - $filename = $this->tempDir . __FUNCTION__ . '.swf'; - - $angles = array( 10, 25, 45, 75, 110, 55 ); - - $startAngle = 0; - foreach ( $angles as $angle ) - { - $this->driver->drawCircularArc( - new ezcGraphCoordinate( 100, 50 ), - 80, - 40, - 10, - $startAngle, - $startAngle += $angle, - ezcGraphColor::fromHex( '#3465A455' ), - false - ); - $startAngle += 5; - } - - $this->driver->render( $filename ); - - $this->compare( - $filename, - $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf' - ); - } - - public function testMingDriverOptionsPropertyCompression() - { - $options = new ezcGraphMingDriverOptions(); - - $this->assertSame( - 9, - $options->compression, - 'Wrong default value for property compression in class ezcGraphMingDriverOptions' - ); - - $options->compression = 4; - $this->assertSame( - 4, - $options->compression, - 'Setting property value did not work for property compression in class ezcGraphMingDriverOptions' - ); - - try - { - $options->compression = false; - } - catch( ezcBaseValueException $e ) - { - return true; - } - - $this->fail( 'Expected ezcBaseValueException.' ); - } - - public function testMingDriverOptionsPropertyCircleResolution() - { - $options = new ezcGraphMingDriverOptions(); - - $this->assertSame( - 2., - $options->circleResolution, - 'Wrong default value for property circleResolution in class ezcGraphMingDriverOptions' - ); - - $options->circleResolution = 5.; - $this->assertSame( - 5., - $options->circleResolution, - 'Setting property value did not work for property circleResolution in class ezcGraphMingDriverOptions' - ); - - try - { - $options->circleResolution = false; - } - catch( ezcBaseValueException $e ) - { - return true; - } - - $this->fail( 'Expected ezcBaseValueException.' ); - } -} -?> Modified: trunk/Graph/tests/suite.php =================================================================== --- trunk/Graph/tests/suite.php 2006-11-30 08:42:04 UTC (rev 4135) +++ trunk/Graph/tests/suite.php 2006-11-30 08:44:35 UTC (rev 4136) @@ -32,7 +32,7 @@ require_once 'driver_options_test.php'; require_once 'driver_gd_test.php'; require_once 'driver_svg_test.php'; -require_once 'driver_ming_test.php'; +require_once 'driver_flash_test.php'; require_once 'font_test.php'; require_once 'palette_test.php'; require_once 'matrix_test.php'; @@ -73,7 +73,7 @@ $this->addTest( ezcGraphDriverOptionsTest::suite() ); $this->addTest( ezcGraphGdDriverTest::suite() ); $this->addTest( ezcGraphSvgDriverTest::suite() ); - $this->addTest( ezcGraphMingDriverTest::suite() ); + $this->addTest( ezcGraphFlashDriverTest::suite() ); $this->addTest( ezcGraphFontTest::suite() ); $this->addTest( ezcGraphTextTest::suite() ); $this->addTest( ezcGraphPaletteTest::suite() ); |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | 4135 - trunk/Template/tests [eZComponents: Trunk]: 00309, Raymond Bosman |
|---|---|
| Next by Date: | 4137 - trunk/Graph/docs [eZComponents: Trunk]: 00309, Kore Nordmann |
| Previous by Thread: | 4135 - trunk/Template/tests [eZComponents: Trunk]i: 00309, Raymond Bosman |
| Next by Thread: | 4137 - trunk/Graph/docs [eZComponents: Trunk]: 00309, Kore Nordmann |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |