src/ADT/Tree/BalanceBinaryNode.php
public function toTable( $showBalanceFactor = FALSE )
	{
		$la		= $this->left  ? $this->left->getHeight()  : 0;
		$lb		= $this->right ? $this->right->getHeight() : 0;
		$depth	= $this->getHeight ();
		$color	= 240 - ( 3 * $depth );
		if( $showBalanceFactor )
		{
			$k = $la - $lb;
			if( $k <= -1*$this->balance || $k >= $this->balance )
				$k = "<b style='color:red'>$k</b>";
			$ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>".$k."</b>";
		}
		$code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>".$this->value.$ins_bf."</td></tr>";
		if( $this->left || $this->right )
		{
			$code .= "<tr><td align=center valign=top>";
			if( $this->left )
				$code .= $this->left->toTable( $showBalanceFactor);
			else
				$code .= "&nbsp;";
			$code .= "</td><td align=center valign=top>";
			if( $this->right )
				$code .= $this->right->toTable( $showBalanceFactor );
			else
				$code .= "&nbsp;";
			$code .= "</td></tr>\n";
		}
		$code .= "</table>\n";
		return $code;
	}
public function toTable( $showBalanceFactor = FALSE )
	{
		$la		= $this->left  ? $this->left->getHeight()  : 0;
		$lb		= $this->right ? $this->right->getHeight() : 0;
		$depth	= $this->getHeight ();
		$color	= 240 - ( 3 * $depth );
		if( $showBalanceFactor )
		{
			$k = $la - $lb;
			if( $k <= -1*$this->balance || $k >= $this->balance )
				$k = "<b style='color:red'>$k</b>";
			$ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>".$k."</b>";
		}
		$code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>".$this->value.$ins_bf."</td></tr>";
		if( $this->left || $this->right )
		{
			$code .= "<tr><td align=center valign=top>";
			if( $this->left )
				$code .= $this->left->toTable( $showBalanceFactor);
			else
				$code .= "&nbsp;";
			$code .= "</td><td align=center valign=top>";
			if( $this->right )
				$code .= $this->right->toTable( $showBalanceFactor );
			else
				$code .= "&nbsp;";
			$code .= "</td></tr>\n";
		}
		$code .= "</table>\n";
		return $code;
	}
public function toTable ( $ showBalanceFactor = FALSE ) { $ la = $ this -> left ? $ this -> left -> getHeight ( ) : 0 ; $ lb = $ this -> right ? $ this -> right -> getHeight ( ) : 0 ; $ depth = $ this -> getHeight ( ) ; $ color = 240 - ( 3 * $ depth ) ; if ( $ showBalanceFactor ) { $ k = $ la - $ lb ; if ( $ k <= - 1 * $ this -> balance || $ k >= $ this -> balance ) $ k = "<b style='color:red'>$k</b>" ; $ ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>" . $ k . "</b>" ; } $ code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>" . $ this -> value . $ ins_bf . "</td></tr>" ; if ( $ this -> left || $ this -> right ) { $ code .= "<tr><td align=center valign=top>" ; if ( $ this -> left ) $ code .= $ this -> left -> toTable ( $ showBalanceFactor ) ; else $ code .= "&nbsp;" ; $ code .= "</td><td align=center valign=top>" ; if ( $ this -> right ) $ code .= $ this -> right -> toTable ( $ showBalanceFactor ) ; else $ code .= "&nbsp;" ; $ code .= "</td></tr>\n" ; } $ code .= "</table>\n" ; return $ code ; }
Returns Tree as HTML Table.
@access		public
@param		bool		[showBalanceFactor]		Flag: show Balance Factor
@return		void
Returns Tree as HTML Table .