summaryrefslogtreecommitdiffstats
path: root/src/driver
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-03-29 12:20:03 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-03-29 12:20:03 +0000
commitd96fa2d3668219a4105e986b3b75dd69a0d8ff37 (patch)
treeb123498c093978bcac9b0a30d38ad18099f1e1cf /src/driver
parent46b36627ff6184fed301ab68c428a26ac5412cda (diff)
downloadzetacomponents-graph-d96fa2d3668219a4105e986b3b75dd69a0d8ff37.zip
zetacomponents-graph-d96fa2d3668219a4105e986b3b75dd69a0d8ff37.tar.gz
- Started implementing feature request #9404 (Rotated labels on axis)
# Works only with SVG driver now. # Angle needs to be set manually, no automatic optimal angle detection yet.
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/flash.php3
-rw-r--r--src/driver/gd.php3
-rw-r--r--src/driver/svg.php30
-rw-r--r--src/driver/verbose.php3
4 files changed, 28 insertions, 11 deletions
diff --git a/src/driver/flash.php b/src/driver/flash.php
index 3ebde93..1ce2693 100644
--- a/src/driver/flash.php
+++ b/src/driver/flash.php
@@ -268,9 +268,10 @@ class ezcGraphFlashDriver extends ezcGraphDriver
* @param float $width Width of text box
* @param float $height Height of text box
* @param int $align Alignement of text
+ * @param ezcGraphRotation $rotation
* @return void
*/
- public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align )
+ public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null )
{
if ( $this->options->font->type !== ezcGraph::PALM_FONT )
{
diff --git a/src/driver/gd.php b/src/driver/gd.php
index c4c00b6..63dea3c 100644
--- a/src/driver/gd.php
+++ b/src/driver/gd.php
@@ -377,9 +377,10 @@ class ezcGraphGdDriver extends ezcGraphDriver
* @param float $width Width of text box
* @param float $height Height of text box
* @param int $align Alignement of text
+ * @param ezcGraphRotation $rotation
* @return void
*/
- public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align )
+ public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null )
{
$padding = $this->options->font->padding + ( $this->options->font->border !== false ? $this->options->font->borderWidth : 0 );
diff --git a/src/driver/svg.php b/src/driver/svg.php
index a32f541..daaa7c5 100644
--- a/src/driver/svg.php
+++ b/src/driver/svg.php
@@ -422,9 +422,10 @@ class ezcGraphSvgDriver extends ezcGraphDriver
* @param float $width Width of text box
* @param float $height Height of text box
* @param int $align Alignement of text
+ * @param ezcGraphRotation $rotation
* @return void
*/
- public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align )
+ public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null )
{
$padding = $this->options->font->padding + ( $this->options->font->border !== false ? $this->options->font->borderWidth : 0 );
@@ -462,6 +463,7 @@ class ezcGraphSvgDriver extends ezcGraphDriver
'height' => $height,
'align' => $align,
'font' => $this->options->font,
+ 'rotation' => $rotation,
);
return $id;
@@ -559,9 +561,19 @@ class ezcGraphSvgDriver extends ezcGraphDriver
foreach ( $this->strings as $text )
{
// Add all text elements into one group
- $this->elements = $this->dom->createElement( 'g' );
- $this->elements->setAttribute( 'id', $text['id'] );
- $this->elements = $elementsRoot->appendChild( $this->elements );
+ $group = $this->dom->createElement( 'g' );
+ $group->setAttribute( 'id', $text['id'] );
+
+ if ( $text['rotation'] !== null )
+ {
+ $group->setAttribute( 'transform', sprintf( 'rotate( %.2f %.4f %.4f )',
+ $text['rotation']->getRotation(),
+ $text['rotation']->getCenter()->x,
+ $text['rotation']->getCenter()->y
+ ) );
+ }
+
+ $group = $elementsRoot->appendChild( $group );
$size = $text['font']->minimalUsedFont;
$font = $text['font']->name;
@@ -651,6 +663,9 @@ class ezcGraphSvgDriver extends ezcGraphDriver
);
}
+ // Set elements root temporary to local text group to ensure
+ // background and border beeing elements of text group
+ $this->elements = $group;
if ( $text['font']->background !== false )
{
$this->drawPolygon(
@@ -680,6 +695,7 @@ class ezcGraphSvgDriver extends ezcGraphDriver
$text['font']->borderWidth
);
}
+ $this->elements = $elementsRoot;
// Bottom line for SVG fonts is lifted a bit
$text['position']->y += $size * .85;
@@ -731,7 +747,7 @@ class ezcGraphSvgDriver extends ezcGraphDriver
1 - ( $text['font']->textShadowColor->alpha / 255 )
)
);
- $this->elements->appendChild( $textNode );
+ $group->appendChild( $textNode );
}
// Finally draw text
@@ -752,13 +768,11 @@ class ezcGraphSvgDriver extends ezcGraphDriver
1 - ( $text['font']->color->alpha / 255 )
)
);
- $this->elements->appendChild( $textNode );
+ $group->appendChild( $textNode );
$text['position']->y += $size + $size * $this->options->lineSpacing;
}
}
-
- $this->elements = $elementsRoot;
}
/**
diff --git a/src/driver/verbose.php b/src/driver/verbose.php
index 5c28e45..d13307d 100644
--- a/src/driver/verbose.php
+++ b/src/driver/verbose.php
@@ -89,9 +89,10 @@ class ezcGraphVerboseDriver extends ezcGraphDriver
* @param mixed $width
* @param mixed $height
* @param ezcGraphColor $color
+ * @param ezcGraphRotation $rotation
* @return void
*/
- public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align )
+ public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null )
{
printf( "% 4d: Draw text '%s' at ( %.2f, %.2f ) with dimensions ( %d, %d ) and alignement %d.\n",
$this->call++,
OpenPOWER on IntegriCloud