Author: Kore Nordmann
Date: 2006-06-14 15:03:43 +0200 (Wed, 14 Jun 2006)
New Revision: 3129

Log:
- Use margin, when rendering chart title

Modified:
   trunk/Graph/src/element/text.php
   trunk/Graph/tests/text_test.php

Modified: trunk/Graph/src/element/text.php
===================================================================
--- trunk/Graph/src/element/text.php    2006-06-13 17:30:30 UTC (rev 3128)
+++ trunk/Graph/src/element/text.php    2006-06-14 13:03:43 UTC (rev 3129)
@@ -57,7 +57,7 @@
                     $height - $this->padding * 2,
                     ezcGraph::CENTER | ezcGraph::MIDDLE
                 );
-                $boundings->y0 += $height;
+                $boundings->y0 += $height + $this->margin;
                 break;
             case ezcGraph::BOTTOM:
                 $renderer->drawTextBox(
@@ -70,7 +70,7 @@
                     $height - $this->padding * 2,
                     ezcGraph::CENTER | ezcGraph::MIDDLE
                 );
-                $boundings->y1 -= $height;
+                $boundings->y1 -= $height + $this->margin;
                 break;
         }
         return $boundings;

Modified: trunk/Graph/tests/text_test.php
===================================================================
--- trunk/Graph/tests/text_test.php     2006-06-13 17:30:30 UTC (rev 3128)
+++ trunk/Graph/tests/text_test.php     2006-06-14 13:03:43 UTC (rev 3129)
@@ -63,6 +63,17 @@
                 $this->equalTo( 18 ),
                 $this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
             );
+        // Test for margin
+        $mockedRenderer
+            ->expects( $this->at( 1 ) )
+            ->method( 'drawTextBox' )
+            ->with(
+                $this->equalTo( new ezcGraphCoordinate( 17, 22 ) ),
+                $this->equalTo( 'sample' ),
+                $this->equalTo( 81 ),
+                $this->equalTo( 12 ),
+                $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
+            );
 
         $chart->renderer = $mockedRenderer;
 
@@ -97,6 +108,48 @@
 
         $chart->render( 500, 200 );
     }
+
+    public function testRenderTextTopMargin()
+    {
+        $chart = ezcGraph::create( 'Line' );
+        $chart->sample = array( 'foo' => 1, 'bar' => 10 );
+
+        $chart->title = 'Title of a chart';
+        $chart->title->position = ezcGraph::TOP;
+        $chart->title->margin = 5;
+
+        $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+            'drawTextBox',
+        ) );
+
+        // Y-Axis
+        $mockedRenderer
+            ->expects( $this->at( 0 ) )
+            ->method( 'drawTextBox' )
+            ->with(
+                $this->equalTo( new ezcGraphCoordinate( 1, 1 ) ),
+                $this->equalTo( 'Title of a chart' ),
+                $this->equalTo( 498 ),
+                $this->equalTo( 18 ),
+                $this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
+            );
+        // Test for margin
+        $mockedRenderer
+            ->expects( $this->at( 1 ) )
+            ->method( 'drawTextBox' )
+            ->with(
+                $this->equalTo( new ezcGraphCoordinate( 17, 27 ) ),
+                $this->equalTo( 'sample' ),
+                $this->equalTo( 81 ),
+                $this->equalTo( 12 ),
+                $this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
+            );
+        
+
+        $chart->renderer = $mockedRenderer;
+
+        $chart->render( 500, 200 );
+    }
 }
 
 ?>

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to