Author: kn
Date: Tue Dec 18 21:08:00 2007
New Revision: 7021

Log:
- Completed cairo driver

Added:
    
trunk/Graph/tests/data/compare/ezcGraphCairoDriverTest_testDrawTextBoxShortStringRotated340Degrees.png
   (with props)
    
trunk/Graph/tests/data/compare/ezcGraphCairoDriverTest_testDrawTextBoxShortStringRotated45Degrees.png
   (with props)
Modified:
    trunk/Graph/src/driver/cairo.php
    trunk/Graph/tests/suite.php

Modified: trunk/Graph/src/driver/cairo.php
==============================================================================
--- trunk/Graph/src/driver/cairo.php [iso-8859-1] (original)
+++ trunk/Graph/src/driver/cairo.php [iso-8859-1] Tue Dec 18 21:08:00 2007
@@ -377,24 +377,35 @@
         
         // Store current state of context
         cairo_save( $this->context );
-
+        cairo_move_to( $this->context, 0, 0 );
 
         if ( $rotation !== null )
         {
-            cairo_rotate( $this->context, deg2rad( $rotation->getRotation() ) 
);
-            cairo_move_to( $this->context,
-                $position->x + $rotation->get( 0, 1 ), 
-                $position->y + $rotation->get( 0, 2 ) - $size * .15
+            // Move to the center
+            cairo_translate( $this->context, 
+                $rotation->getCenter()->x, 
+                $rotation->getCenter()->y
+            );
+            // Rotate around text center
+            cairo_rotate( $this->context, 
+                deg2rad( $rotation->getRotation() ) 
+            );
+            // Center the text
+            cairo_translate( $this->context, 
+                $position->x - $rotation->getCenter()->x,
+                $position->y - $rotation->getCenter()->y - $size * .15
             );
         } else {
-            cairo_move_to( $this->context,
+            cairo_translate( $this->context,
                 $position->x,
                 $position->y - $size * .15
             );
         }
 
+        cairo_new_path( $this->context );
         $this->getStyle( $color, true );
         cairo_show_text( $this->context, $text );
+        cairo_stroke( $this->context );
 
         // Restore state of context
         cairo_restore( $this->context );
@@ -419,6 +430,8 @@
      */
     protected function drawAllTexts()
     {
+        $this->initiliazeSurface();
+
         foreach ( $this->strings as $text )
         {
             $size = $text['font']->minimalUsedFont;
@@ -457,14 +470,15 @@
 
                 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;
+                    case ( $text['align'] & ezcGraph::LEFT ):
+                    default:
+                        $xOffset = 0;
                         break;
                 }
 

Added: 
trunk/Graph/tests/data/compare/ezcGraphCairoDriverTest_testDrawTextBoxShortStringRotated340Degrees.png
==============================================================================
Binary file - no diff available.

Propchange: 
trunk/Graph/tests/data/compare/ezcGraphCairoDriverTest_testDrawTextBoxShortStringRotated340Degrees.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: 
trunk/Graph/tests/data/compare/ezcGraphCairoDriverTest_testDrawTextBoxShortStringRotated45Degrees.png
==============================================================================
Binary file - no diff available.

Propchange: 
trunk/Graph/tests/data/compare/ezcGraphCairoDriverTest_testDrawTextBoxShortStringRotated45Degrees.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: trunk/Graph/tests/suite.php
==============================================================================
--- trunk/Graph/tests/suite.php [iso-8859-1] (original)
+++ trunk/Graph/tests/suite.php [iso-8859-1] Tue Dec 18 21:08:00 2007
@@ -25,6 +25,7 @@
 require_once 'date_axis_test.php';
 require_once 'driver_flash_test.php';
 require_once 'driver_gd_test.php';
+require_once 'driver_cairo_test.php';
 require_once 'driver_options_test.php';
 require_once 'driver_svg_test.php';
 require_once 'element_options_test.php';
@@ -79,6 +80,7 @@
         $this->addTest( ezcGraphFlashDriverTest::suite() );
         $this->addTest( ezcGraphFontTest::suite() );
         $this->addTest( ezcGraphGdDriverTest::suite() );
+        $this->addTest( ezcGraphCairoDriverTest::suite() );
         $this->addTest( ezcGraphImageMapTest::suite() );
         $this->addTest( ezcGraphLabeledAxisTest::suite() );
         $this->addTest( ezcGraphLegendTest::suite() );


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to