diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-05-29 07:31:41 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-05-29 07:31:41 +0000 |
commit | e9f7f66fef8d66865eae4cf731bf502c19dc948e (patch) | |
tree | 90b2ae3b143e4e3139c71f42c5cdee9a2779331b /src/driver | |
parent | cc7669f009a394d3ac90f8aef489438fbccd3e9c (diff) | |
download | zetacomponents-graph-e9f7f66fef8d66865eae4cf731bf502c19dc948e.zip zetacomponents-graph-e9f7f66fef8d66865eae4cf731bf502c19dc948e.tar.gz |
- Fixed issue #10830: Automatically shorten labels if not enough space is
available
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/flash.php | 41 | ||||
-rw-r--r-- | src/driver/gd.php | 38 | ||||
-rw-r--r-- | src/driver/svg.php | 10 |
3 files changed, 55 insertions, 34 deletions
diff --git a/src/driver/flash.php b/src/driver/flash.php index 38c07a2..74de773 100644 --- a/src/driver/flash.php +++ b/src/driver/flash.php @@ -309,26 +309,33 @@ class ezcGraphFlashDriver extends ezcGraphDriver $size = $this->modifyCoordinate( floor( ( $newsize = $size * ( $result ) ) >= $size ? $size - 1 : $newsize ) ); } - if ( is_array( $result ) ) + 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, - 'rotation' => $rotation, - ); - } - else - { - throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + if ( ( $height >= $this->options->font->minFontSize ) && + ( $this->options->autoShortenString ) ) + { + $result = $this->tryFitShortenedString( $string, $position, $width, $height, $size = $this->modifyCoordinate( $this->options->font->minFontSize ) ); + } + else + { + throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + } } + + $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, + 'rotation' => $rotation, + ); + return $id; } diff --git a/src/driver/gd.php b/src/driver/gd.php index c398261..a3bea95 100644 --- a/src/driver/gd.php +++ b/src/driver/gd.php @@ -426,25 +426,31 @@ class ezcGraphGdDriver extends ezcGraphDriver $size = floor( ( $newsize = $size * ( $result ) ) >= $size ? $size - 1 : $newsize ); } - if ( is_array( $result ) ) + if ( !is_array( $result ) ) { - $this->options->font->minimalUsedFont = $size; - - $this->strings[] = array( - 'text' => $result, - 'position' => $position, - 'width' => $width, - 'height' => $height, - 'align' => $align, - 'font' => $this->options->font, - 'rotation' => $rotation, - ); - } - else - { - throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + if ( ( $height >= $this->options->font->minFontSize ) && + ( $this->options->autoShortenString ) ) + { + $result = $this->tryFitShortenedString( $string, $position, $width, $height, $size = $this->options->font->minFontSize ); + } + else + { + throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + } } + $this->options->font->minimalUsedFont = $size; + + $this->strings[] = array( + 'text' => $result, + 'position' => $position, + 'width' => $width, + 'height' => $height, + 'align' => $align, + 'font' => $this->options->font, + 'rotation' => $rotation, + ); + return array( clone $position, new ezcGraphCoordinate( $position->x + $width, $position->y ), diff --git a/src/driver/svg.php b/src/driver/svg.php index bfbf95c..81e2aed 100644 --- a/src/driver/svg.php +++ b/src/driver/svg.php @@ -457,7 +457,15 @@ class ezcGraphSvgDriver extends ezcGraphDriver if ( !is_array( $result ) ) { - throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + if ( ( $height >= $this->options->font->minFontSize ) && + ( $this->options->autoShortenString ) ) + { + $result = $this->tryFitShortenedString( $string, $position, $width, $height, $size = $this->options->font->minFontSize ); + } + else + { + throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); + } } $this->options->font->minimalUsedFont = $size; |