logo       

4146 - in trunk/Graph: . src/driver src/interfaces tests tests/data/compare: msg#00320

web.ezcomponents.cvs

Subject: 4146 - in trunk/Graph: . src/driver src/interfaces tests tests/data/compare [eZComponents: Trunk]

Author: Kore Nordmann
Date: 2006-11-30 12:11:42 +0100 (Thu, 30 Nov 2006)
New Revision: 4146

Log:
- Implemented #9647 (Add render to output method)

Added:
trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderToOutput.swf

trunk/Graph/tests/data/compare/ezcGraphGdDriverTest_testRenderJpegToOutput.jpeg
trunk/Graph/tests/data/compare/ezcGraphGdDriverTest_testRenderPngToOutput.png
trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testRenderToOutput.svg
Modified:
trunk/Graph/ChangeLog
trunk/Graph/src/driver/flash.php
trunk/Graph/src/driver/gd.php
trunk/Graph/src/driver/svg.php
trunk/Graph/src/driver/verbose.php
trunk/Graph/src/interfaces/driver.php
trunk/Graph/tests/driver_flash_test.php
trunk/Graph/tests/driver_gd_test.php
trunk/Graph/tests/driver_svg_test.php

Modified: trunk/Graph/ChangeLog
===================================================================
--- trunk/Graph/ChangeLog 2006-11-30 10:28:24 UTC (rev 4145)
+++ trunk/Graph/ChangeLog 2006-11-30 11:11:42 UTC (rev 4146)
@@ -5,6 +5,7 @@
- Renamed pie chart options percentTreshHold to percentThreshold and
absoluteTreshHold to absoluteThreshold

+- Added feature #9647: Add render to output method
- Fixed issue #9612: Element links for SVG image in the legend require you to
click on exactly the text.
- Fixed issue #9586: No data rendered with string keys on date axis.

Modified: trunk/Graph/src/driver/flash.php
===================================================================
--- trunk/Graph/src/driver/flash.php 2006-11-30 10:28:24 UTC (rev 4145)
+++ trunk/Graph/src/driver/flash.php 2006-11-30 11:11:42 UTC (rev 4146)
@@ -813,6 +813,16 @@
}

/**
+ * Return mime type for current image format
+ *
+ * @return string
+ */
+ public function getMimeType()
+ {
+ return 'application/x-shockwave-flash';
+ }
+
+ /**
* Finally save image
*
* @param string $file Destination filename

Modified: trunk/Graph/src/driver/gd.php
===================================================================
--- trunk/Graph/src/driver/gd.php 2006-11-30 10:28:24 UTC (rev 4145)
+++ trunk/Graph/src/driver/gd.php 2006-11-30 11:11:42 UTC (rev 4146)
@@ -981,6 +981,37 @@
}

/**
+ * Return mime type for current image format
+ *
+ * @return string
+ */
+ public function getMimeType()
+ {
+ switch ( $this->options->imageFormat )
+ {
+ case IMG_PNG:
+ return 'image/png';
+ case IMG_JPEG:
+ return 'image/jpeg';
+ }
+ }
+
+ /**
+ * Render image directly to output
+ *
+ * The method renders the image directly to the standard output. You
+ * normally do not want to use this function, because it makes it harder
+ * to proper cache the generated graphs.
+ *
+ * @return void
+ */
+ public function renderToOutput()
+ {
+ header( 'Content-Type: ' . $this->getMimeType() );
+ $this->render( null );
+ }
+
+ /**
* Finally save image
*
* @param string $file Destination filename

Modified: trunk/Graph/src/driver/svg.php
===================================================================
--- trunk/Graph/src/driver/svg.php 2006-11-30 10:28:24 UTC (rev 4145)
+++ trunk/Graph/src/driver/svg.php 2006-11-30 11:11:42 UTC (rev 4146)
@@ -982,6 +982,16 @@
}

/**
+ * Return mime type for current image format
+ *
+ * @return string
+ */
+ public function getMimeType()
+ {
+ return 'image/svg+xml';
+ }
+
+ /**
* Finally save image
*
* @param string $file Destination filename

Modified: trunk/Graph/src/driver/verbose.php
===================================================================
--- trunk/Graph/src/driver/verbose.php 2006-11-30 10:28:24 UTC (rev 4145)
+++ trunk/Graph/src/driver/verbose.php 2006-11-30 11:11:42 UTC (rev 4146)
@@ -186,6 +186,16 @@
}

/**
+ * Return mime type for current image format
+ *
+ * @return string
+ */
+ public function getMimeType()
+ {
+ return 'text/plain';
+ }
+
+ /**
* Finally save image
*
* @param mixed $file

Modified: trunk/Graph/src/interfaces/driver.php
===================================================================
--- trunk/Graph/src/interfaces/driver.php 2006-11-30 10:28:24 UTC (rev
4145)
+++ trunk/Graph/src/interfaces/driver.php 2006-11-30 11:11:42 UTC (rev
4146)
@@ -252,6 +252,28 @@
abstract public function drawImage( $file, ezcGraphCoordinate $position,
$width, $height );

/**
+ * Return mime type for current image format
+ *
+ * @return string
+ */
+ abstract public function getMimeType();
+
+ /**
+ * Render image directly to output
+ *
+ * The method renders the image directly to the standard output. You
+ * normally do not want to use this function, because it makes it harder
+ * to proper cache the generated graphs.
+ *
+ * @return void
+ */
+ public function renderToOutput()
+ {
+ header( 'Content-Type: ' . $this->getMimeType() );
+ $this->render( 'php://output' );
+ }
+
+ /**
* Finally save image
*
* @param string $file Destination filename

Added:
trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderToOutput.swf
===================================================================
(Binary files differ)


Property changes on:
trunk/Graph/tests/data/compare/ezcGraphFlashDriverTest_testRenderToOutput.swf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream

Added:
trunk/Graph/tests/data/compare/ezcGraphGdDriverTest_testRenderJpegToOutput.jpeg
===================================================================
(Binary files differ)


Property changes on:
trunk/Graph/tests/data/compare/ezcGraphGdDriverTest_testRenderJpegToOutput.jpeg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream

Added:
trunk/Graph/tests/data/compare/ezcGraphGdDriverTest_testRenderPngToOutput.png
===================================================================
(Binary files differ)


Property changes on:
trunk/Graph/tests/data/compare/ezcGraphGdDriverTest_testRenderPngToOutput.png
___________________________________________________________________
Name: svn:mime-type
+ image/png

Added:
trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testRenderToOutput.svg
===================================================================
--- trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testRenderToOutput.svg
2006-11-30 10:28:24 UTC (rev 4145)
+++ trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testRenderToOutput.svg
2006-11-30 11:11:42 UTC (rev 4146)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="200" height="100" version="1.0"
id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality"
shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path
d=" M 12.0000,45.0000 L 134.0000,12.0000" style="fill: none; stroke: #3465a4;
stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin:
round;" id="ezcGraphLine_1"/></g></svg>


Property changes on:
trunk/Graph/tests/data/compare/ezcGraphSvgDriverTest_testRenderToOutput.svg
___________________________________________________________________
Name: svn:eol-style
+ native

Modified: trunk/Graph/tests/driver_flash_test.php
===================================================================
--- trunk/Graph/tests/driver_flash_test.php 2006-11-30 10:28:24 UTC (rev
4145)
+++ trunk/Graph/tests/driver_flash_test.php 2006-11-30 11:11:42 UTC (rev
4146)
@@ -1472,5 +1472,32 @@

$this->fail( 'Expected ezcBaseValueException.' );
}
+
+ public function testRenderToOutput()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.swf';
+
+ $this->driver->drawLine(
+ new ezcGraphCoordinate( 12, 45 ),
+ new ezcGraphCoordinate( 134, 12 ),
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->assertEquals(
+ $this->driver->getMimeType(),
+ 'application/x-shockwave-flash',
+ 'Wrong mime type returned.'
+ );
+
+ ob_start();
+ // Suppress header already sent warning
+ @$this->driver->renderToOutput();
+ file_put_contents( $filename, ob_get_clean() );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.swf'
+ );
+ }
}
?>

Modified: trunk/Graph/tests/driver_gd_test.php
===================================================================
--- trunk/Graph/tests/driver_gd_test.php 2006-11-30 10:28:24 UTC (rev
4145)
+++ trunk/Graph/tests/driver_gd_test.php 2006-11-30 11:11:42 UTC (rev
4146)
@@ -62,6 +62,65 @@
}
}

+ public function testRenderPngToOutput()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $this->driver->options->imageFormat = IMG_PNG;
+ $this->driver->drawLine(
+ new ezcGraphCoordinate( 12, 45 ),
+ new ezcGraphCoordinate( 134, 12 ),
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->assertEquals(
+ $this->driver->getMimeType(),
+ 'image/png',
+ 'Wrong mime type returned.'
+ );
+
+ ob_start();
+ // Suppress header already sent warning
+ @$this->driver->renderToOutput();
+ file_put_contents( $filename, ob_get_clean() );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
+ public function testRenderJpegToOutput() {
+ $filename = $this->tempDir . __FUNCTION__ . '.jpeg';
+
+ $this->driver->options->imageFormat = IMG_JPEG;
+ $this->driver->drawLine(
+ new ezcGraphCoordinate( 12, 45 ),
+ new ezcGraphCoordinate( 134, 12 ),
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->assertEquals(
+ $this->driver->getMimeType(),
+ 'image/jpeg',
+ 'Wrong mime type returned.'
+ );
+
+ ob_start();
+ // Suppress header already sent warning
+ @$this->driver->renderToOutput();
+ file_put_contents( $filename, ob_get_clean() );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.jpeg',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
public function testDrawLine()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';

Modified: trunk/Graph/tests/driver_svg_test.php
===================================================================
--- trunk/Graph/tests/driver_svg_test.php 2006-11-30 10:28:24 UTC (rev
4145)
+++ trunk/Graph/tests/driver_svg_test.php 2006-11-30 11:11:42 UTC (rev
4146)
@@ -81,6 +81,33 @@
}
}

+ public function testRenderToOutput()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawLine(
+ new ezcGraphCoordinate( 12, 45 ),
+ new ezcGraphCoordinate( 134, 12 ),
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->assertEquals(
+ $this->driver->getMimeType(),
+ 'image/svg+xml',
+ 'Wrong mime type returned.'
+ );
+
+ ob_start();
+ // Suppress header already sent warning
+ @$this->driver->renderToOutput();
+ file_put_contents( $filename, ob_get_clean() );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ .
'.svg'
+ );
+ }
+
public function testDrawLine()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise