/**
  * HorizontalLayout [Constructor]
  * @param Image_Graph_Element $part1 The 1st part of the layout
  * @param Image_Graph_Element $part2 The 2nd part of the layout
  * @param int $percentage The percentage of the layout to split at
  */
 function &Image_Graph_Layout_Horizontal(& $part1, & $part2, $percentage = 50)
 {
     parent::__construct();
     $this->_part1 = & $part1;
     $this->_part2 = & $part2;
     $this->add($this->_part1);
     $this->add($this->_part2);
     $this->_percentage = max(0, min(100, $percentage));
     $this->_split();
     $this->_padding = 0;
 }
Beispiel #2
0
 /**
  * PlotareaLayout [Constructor]
  * @param string $title The plotarea title
  * @param string $axisXTitle The title displayed on the X-axis (i.e. at the bottom)
  * @param string $axisYTitle The title displayed on the Y-axis (i.e. on the left - vertically)
  */
 function &Image_Graph_Layout_Plotarea($title, $axisXTitle, $axisYTitle)
 {
     parent::__construct();
     
     $this->_plotarea = & new Image_Graph_Plotarea();
     
     return
         new Image_Graph_Layout_Horizontal(
             new Image_Graph_Title($title, $GLOBALS['_Image_Graph_font']),        
             new Image_Graph_Layout_Vertical(
                 new Image_Graph_Title($axisYTitle, $GLOBALS['_Image_Graph_vertical_font']),
                 new Image_Graph_Layout_Horizontal(
                     $this->_plotarea,
                     new Image_Graph_Title($axisXTitle, $GLOBALS['_Image_Graph_font']),
                     95
                 ),
                 5
             ),
             10
         );
 }
 /**
  * HorizontalLayout [Constructor]
  *
  * @param Image_Graph_Element $part1 The 1st part of the layout
  * @param Image_Graph_Element $part2 The 2nd part of the layout
  * @param int $percentage The percentage of the layout to split at
  */
 function __construct(&$part1, &$part2, $percentage = 50)
 {
     parent::__construct();
     if (!is_a($part1, 'Image_Graph_Layout')) {
         $this->_error('Cannot create layout on non-layouable parts: ' . get_class($part1), array('part1' => &$part1, 'part2' => &$part2));
     } elseif (!is_a($part2, 'Image_Graph_Layout')) {
         $this->_error('Cannot create layout on non-layouable parts: ' . get_class($part2), array('part1' => &$part1, 'part2' => &$part2));
     } else {
         $this->_part1 =& $part1;
         $this->_part2 =& $part2;
         $this->add($this->_part1);
         $this->add($this->_part2);
     }
     if ($percentage === 'auto') {
         $this->_percentage = false;
         $this->_absolute = 'runtime';
     } else {
         $this->_absolute = false;
         $this->_percentage = max(0, min(100, $percentage));
     }
     $this->_split();
     $this->_padding = array('left' => 0, 'top' => 0, 'right' => 0, 'bottom' => 0);
 }
Beispiel #4
0
 /**
  * HorizontalLayout [Constructor]
  *
  * @param Image_Graph_Element $part1 The 1st part of the layout
  * @param Image_Graph_Element $part2 The 2nd part of the layout
  * @param int $percentage The percentage of the layout to split at
  */
 function Image_Graph_Layout_Horizontal(&$part1, &$part2, $percentage = 50)
 {
     parent::Image_Graph_Layout();
     if (!is_a($part1, 'Image_Graph_Layout')) {
         $this->_error('Cannot create layout on non-layouable parts: ' . get_class($part1), array('part1' => &$part1, 'part2' => &$part2));
     } elseif (!is_a($part2, 'Image_Graph_Layout')) {
         $this->_error('Cannot create layout on non-layouable parts: ' . get_class($part2), array('part1' => &$part1, 'part2' => &$part2));
     } else {
         $this->_part1 =& $part1;
         $this->_part2 =& $part2;
         $this->add($this->_part1);
         $this->add($this->_part2);
     }
     if ($percentage === 'auto') {
         $this->_percentage = false;
         $this->_absolute = 'runtime';
     } else {
         $this->_absolute = false;
         $this->_percentage = max(0, min(100, $percentage));
     }
     $this->_split();
     $this->_padding = 0;
 }
Beispiel #5
0
 /**
  * Output the text
  *
  * @return bool Was the output 'good' (true) or 'bad' (false).
  * @access private
  */
 function _done()
 {
     if ($this->_defaultFontOptions !== false) {
         $this->_canvas->setFont($this->_defaultFontOptions);
     } else {
         $this->_canvas->setFont($this->_getFont());
     }
     if (is_a($this->_parent, 'Image_Graph_Plotarea')) {
         $this->_setCoords($this->_parent->_left, $this->_parent->_top, $this->_parent->_right, $this->_parent->_top + $this->_canvas->textHeight($this->_text));
     } elseif (!is_a($this->_parent, 'Image_Graph_Layout')) {
         $this->_setCoords($this->_parent->_fillLeft(), $this->_parent->_fillTop(), $this->_parent->_fillRight(), $this->_parent->_fillTop() + $this->_canvas->textHeight($this->_text));
     }
     if (parent::_done() === false) {
         return false;
     }
     if ($this->_alignment == IMAGE_GRAPH_ALIGN_CENTER_X) {
         $x = ($this->_left + $this->_right) / 2;
     } elseif ($this->_alignment == IMAGE_GRAPH_ALIGN_LEFT) {
         $x = $this->_left;
     } else {
         $x = $this->_right;
     }
     $y = ($this->_top + $this->_bottom) / 2;
     $this->write($x, $y, $this->_text, $this->_alignment + IMAGE_GRAPH_ALIGN_CENTER_Y);
     return true;
 }
Beispiel #6
0
 /**
  * Sets the parent. The parent chain should ultimately be a GraPHP object
  *
  * @see Image_Graph
  * @param Image_Graph_Common $parent The parent
  * @access private
  */
 function _setParent(&$parent)
 {
     parent::_setParent($parent);
     if (count($this->_plotareas) == 0) {
         $this->setPlotarea($parent);
     }
 }
Beispiel #7
0
 /**
  * Output the plotarea to the canvas
  *
  * @return bool Was the output 'good' (true) or 'bad' (false).
  * @access private
  */
 function _done()
 {
     if ($this->_hasData) {
         $this->_canvas->startGroup(get_class($this));
         if ($this->_axisX != null) {
             $this->add($this->_axisX);
         }
         if ($this->_axisY != null) {
             $this->add($this->_axisY);
         }
         if ($this->_axisYSecondary != null) {
             $this->add($this->_axisYSecondary);
         }
         $this->_getFillStyle();
         $this->_canvas->rectangle(array('x0' => $this->_plotLeft, 'y0' => $this->_plotTop, 'x1' => $this->_plotRight, 'y1' => $this->_plotBottom));
         $result = parent::_done();
         $this->_canvas->endGroup();
         return $result;
     } else {
         // no data -> do nothing at all!
         return true;
     }
 }
Beispiel #8
0
 /**
  * Output the plotarea to the canvas
  *
  * @return bool Was the output 'good' (true) or 'bad' (false).
  * @access private
  */
 function _done()
 {
     $this->_getFillStyle();
     $this->_canvas->rectangle(array('x0' => $this->_fillLeft(), 'y0' => $this->_fillTop(), 'x1' => $this->_fillRight(), 'y1' => $this->_fillBottom()));
     $scaledWidth = $this->_mapSize['X'] * $this->_scale;
     $scaledHeight = $this->_mapSize['Y'] * $this->_scale;
     $this->_canvas->image(array('x' => $this->_plotLeft, 'y' => $this->_plotTop, 'filename' => $this->_imageMap, 'width' => $scaledWidth, 'height' => $scaledHeight));
     return Image_Graph_Layout::_done();
 }
 /**
  * Update coordinates
  *
  * @access private
  */
 function _updateCoords()
 {
     for ($i = 0; $i < $this->_rows; $i++) {
         for ($j = 0; $j < $this->_cols; $j++) {
             $element =& $this->getEntry($i, $j);
             $this->add($element);
         }
     }
     parent::_updateCoords();
 }
    /**
     * Output the plotarea to the canvas
     * @access private
     */
    function _done()
    {
        if ($this->_axisX != null) {
            $this->add($this->_axisX);
        }
        if ($this->_axisY != null) {
            $this->add($this->_axisY);
        }

        if ($this->_identify) {
            $red = rand(0, 255);
            $green = rand(0, 255);
            $blue = rand(0, 255);
            $color = ImageColorAllocate($this->_canvas(), $red, $green, $blue);

            if (isset($GLOBALS['_Image_Graph_gd2'])) {
                $alphaColor = ImageColorResolveAlpha($this->_canvas(), $red, $green, $blue, 200);
            } else {
                $alphaColor = $color;
            }

            ImageRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $color);
            ImageFilledRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $alphaColor);
        }

        if ($this->_fillStyle) {
            ImageFilledRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $this->_getFillStyle());
        }

        parent::_done();

        if ($this->_plotBorderStyle) {
            ImageRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $this->_plotBorderStyle->_getLineStyle());
        }
    }
Beispiel #11
0
    /**
     * Output the text 
     * @access private
     */
    function _done()
    {
        if (!$this->_font) {
            return false;
        }
        
        if (!is_a($this->_parent, "Image_Graph_Layout")) {
            $this->_setCoords(
                $this->_parent->_fillLeft(),
                $this->_parent->_fillTop(),
                $this->_parent->_fillRight(),
                $this->_parent->_fillTop() + $this->_font->height($this->_text)
            );
        }               
        
        parent::_done();

        $this->_font->_write(
            ($this->_left + $this->_right - $this->_font->width($this->_text)) / 2, 
            ($this->_top + $this->_bottom - $this->_font->height($this->_text)) / 2, 
            $this->_text
        );
    }