]->SetFont($aFF,$aFS,$aFSize); } } function SetCellFont($aRow,$aCol,$aFF,$aFS,$aFSize=10) { $this->_chkR($aRow); $this->_chkC($aCol); $this->iCells[$aRow][$aCol]->SetFont($aFF,$aFS,$aFSize); } /*--------------------------------------------------------------------- * Cell align settings *--------------------------------------------------------------------- */ function SetAlign($aR1HAlign=null,$aC1VAlign=null,$aR2=null,$aC2=null,$aHArg=null,$aVArg='center') { if( $aC1VAlign !== null && $aR2!==null && $aC2!==null && $aHArg!==null ) { $this->_chkR($aR1HAlign); $this->_chkC($aC1VAlign); $this->_chkR($aR2); $this->_chkC($aC2); } else { if( $aR1HAlign === null ) { JpGraphError::RaiseL(24010); } if( $aC1VAlign === null ) { $aC1VAlign = 'center'; } $aHArg = $aR1HAlign; $aVArg = $aC1VAlign === null ? 'center' : $aC1VAlign ; $aR2 = $this->iSize[0]-1; $aR1HAlign = 0; $aC2 = $this->iSize[1]-1; $aC1VAlign = 0; } for($i=$aR1HAlign; $i <= $aR2; ++$i) { for($j=$aC1VAlign; $j <= $aC2; ++$j) { $this->iCells[$i][$j]->SetAlign($aHArg,$aVArg); } } } function SetCellAlign($aRow,$aCol,$aHorAlign,$aVertAlign='bottom') { $this->_chkR($aRow); $this->_chkC($aCol); $this->iCells[$aRow][$aCol]->SetAlign($aHorAlign,$aVertAlign); } function SetRowAlign($aRow,$aHorAlign,$aVertAlign='bottom') { $this->_chkR($aRow); for($j=0; $j < $this->iSize[1]; ++$j) { $this->iCells[$aRow][$j]->SetAlign($aHorAlign,$aVertAlign); } } function SetColAlign($aCol,$aHorAlign,$aVertAlign='bottom') { $this->_chkC($aCol); for($i=0; $i < $this->iSize[0]; ++$i) { $this->iCells[$i][$aCol]->SetAlign($aHorAlign,$aVertAlign); } } /*--------------------------------------------------------------------- * Cell number format *--------------------------------------------------------------------- */ function SetNumberFormat($aArgR1,$aC1=null,$aR2=null,$aC2=null,$aArg=null) { if( $aC1 !== null && $aR2!==null && $aC2!==null && $aArg!==null ) { $this->_chkR($aArgR1); $this->_chkC($aC1); $this->_chkR($aR2); $this->_chkC($aC2); } else { $aArg = $aArgR1; $aR2 = $this->iSize[0]-1; $aArgR1 = 0; $aC2 = $this->iSize[1]-1; $aC1 = 0; } if( !is_string($aArg) ) { JpGraphError::RaiseL(24013); // argument must be a string } for($i=$aArgR1; $i <= $aR2; ++$i) { for($j=$aC1; $j <= $aC2; ++$j) { $this->iCells[$i][$j]->SetNumberFormat($aArg); } } } function SetRowNumberFormat($aRow,$aF) { $this->_chkR($aRow); if( !is_string($aF) ) { JpGraphError::RaiseL(24013); // argument must be a string } for($j=0; $j < $this->iSize[1]; ++$j) { $this->iCells[$aRow][$j]->SetNumberFormat($aF); } } function SetColNumberFormat($aCol,$aF) { $this->_chkC($aCol); if( !is_string($aF) ) { JpGraphError::RaiseL(24013); // argument must be a string } for($i=0; $i < $this->iSize[0]; ++$i) { $this->iCells[$i][$aCol]->SetNumberFormat($aF); } } function SetCellNumberFormat($aRow,$aCol,$aF) { $this->_chkR($aRow); $this->_chkC($aCol); if( !is_string($aF) ) { JpGraphError::RaiseL(24013); // argument must be a string } $this->iCells[$aRow][$aCol]->SetNumberFormat($aF); } /*--------------------------------------------------------------------- * Set row and column min size *--------------------------------------------------------------------- */ function SetMinColWidth($aColWidth,$aWidth=null) { // If there is only one argument this means that all // columns get set to the same width if( $aWidth===null ) { for($i=0; $i < $this->iSize[1]; ++$i) { $this->iColWidth[$i] = $aColWidth; } } else { $this->_chkC($aColWidth); $this->iColWidth[$aColWidth] = $aWidth; } } function SetMinRowHeight($aRowHeight,$aHeight=null) { // If there is only one argument this means that all // rows get set to the same height if( $aHeight===null ) { for($i=0; $i < $this->iSize[0]; ++$i) { $this->iRowHeight[$i] = $aRowHeight; } } else { $this->_chkR($aRowHeight); $this->iRowHeight[$aRowHeight] = $aHeight; } } /*--------------------------------------------------------------------- * Grid line settings *--------------------------------------------------------------------- */ function SetGrid($aWeight=1,$aColor='black',$aStyle=TGRID_SINGLE) { $rc = $this->iSize[0]; $cc = $this->iSize[1]; for($i=0; $i < $rc; ++$i) { for($j=0; $j < $cc; ++$j) { $this->iCells[$i][$j]->SetGridColor($aColor,$aColor); $this->iCells[$i][$j]->SetGridWeight($aWeight,$aWeight); $this->iCells[$i][$j]->SetGridStyle($aStyle); } } } function SetColGrid($aCol,$aWeight=1,$aColor='black',$aStyle=TGRID_SINGLE) { $this->_chkC($aCol); for($i=0; $i < $this->iSize[0]; ++$i) { $this->iCells[$i][$aCol]->SetGridWeight($aWeight); $this->iCells[$i][$aCol]->SetGridColor($aColor); $this->iCells[$i][$aCol]->SetGridStyle($aStyle); } } function SetRowGrid($aRow,$aWeight=1,$aColor='black',$aStyle=TGRID_SINGLE) { $this->_chkR($aRow); for($j=0; $j < $this->iSize[1]; ++$j) { $this->iCells[$aRow][$j]->SetGridWeight(NULL,$aWeight); $this->iCells[$aRow][$j]->SetGridColor(NULL,$aColor); $this->iCells[$aRow][$j]->SetGridStyle(NULL,$aStyle); } } /*--------------------------------------------------------------------- * Merge cells *--------------------------------------------------------------------- */ function MergeRow($aRow,$aHAlign='center',$aVAlign='center') { $this->_chkR($aRow); $this->MergeCells($aRow,0,$aRow,$this->iSize[1]-1,$aHAlign,$aVAlign); } function MergeCol($aCol,$aHAlign='center',$aVAlign='center') { $this->_chkC($aCol); $this->MergeCells(0,$aCol,$this->iSize[0]-1,$aCol,$aHAlign,$aVAlign); } function MergeCells($aR1,$aC1,$aR2,$aC2,$aHAlign='center',$aVAlign='center') { if( $aR1 > $aR2 || $aC1 > $aC2 ) { JpGraphError::RaiseL(24004); //('GTextTable::MergeCells(). Specified cell range to be merged is not valid.'); } $this->_chkR($aR1); $this->_chkC($aC1); $this->_chkR($aR2); $this->_chkC($aC2); $rspan = $aR2-$aR1+1; $cspan = $aC2-$aC1+1; // Setup the parent cell for this merged group if( $this->iCells[$aR1][$aC1]->IsMerged() ) { JpGraphError::RaiseL(24005,$aR1,$aC1,$aR2,$aC2); //("Cannot merge already merged cells in the range ($aR1,$aC1), ($aR2,$aC2)"); } $this->iCells[$aR1][$aC1]->SetRowColSpan($rspan,$cspan); $this->iCells[$aR1][$aC1]->SetAlign($aHAlign,$aVAlign); for($i=$aR1; $i <= $aR2; ++$i) { for($j=$aC1; $j <= $aC2; ++$j) { if( ! ($i == $aR1 && $j == $aC1) ) { if( $this->iCells[$i][$j]->IsMerged() ) { JpGraphError::RaiseL(24005,$aR1,$aC1,$aR2,$aC2); //("Cannot merge already merged cells in the range ($aR1,$aC1), ($aR2,$aC2)"); } $this->iCells[$i][$j]->SetMerged($aR1,$aC1,true); } } } } /*--------------------------------------------------------------------- * CSIM methods *--------------------------------------------------------------------- */ function SetCSIMTarget($aTarget,$aAlt=null,$aAutoTarget=false) { $m = $this->iSize[0]; $n = $this->iSize[1]; $csim = ''; for($i=0; $i < $m; ++$i) { for($j=0; $j < $n; ++$j) { if( $aAutoTarget ) $t = $aTarget."?row=$i&col=$j"; else $t = $aTarget; $this->iCells[$i][$j]->SetCSIMTarget($t,$aAlt); } } } function SetCellCSIMTarget($aRow,$aCol,$aTarget,$aAlt=null) { $this->_chkR($aRow); $this->_chkC($aCol); $this->iCells[$aRow][$aCol]->SetCSIMTarget($aTarget,$aAlt); } /*--------------------------------------------------------------------- * Private methods *--------------------------------------------------------------------- */ function GetCSIMAreas() { $m = $this->iSize[0]; $n = $this->iSize[1]; $csim = ''; for($i=0; $i < $m; ++$i) { for($j=0; $j < $n; ++$j) { $csim .= $this->iCells[$i][$j]->GetCSIMArea(); } } return $csim; } function _chkC($aCol) { if( ! $this->iInit ) { JpGraphError::Raise(24014); // Table not initialized } if( $aCol < 0 || $aCol >= $this->iSize[1] ) JpGraphError::RaiseL(24006,$aCol); //("GTextTable:\nColumn argument ($aCol) is outside specified table size."); } function _chkR($aRow) { if( ! $this->iInit ) { JpGraphError::Raise(24014); // Table not initialized } if( $aRow < 0 || $aRow >= $this->iSize[0] ) JpGraphError::RaiseL(24007,$aRow); //("GTextTable:\nRow argument ($aRow) is outside specified table size."); } function _getScalePos() { if( $this->iScaleXPos === null || $this->iScaleYPos === null ) { return false; } return array($this->iScaleXPos, $this->iScaleYPos); } function _autoSizeTable(&$aImg) { // Get maximum column width and row height $m = $this->iSize[0]; $n = $this->iSize[1]; $w=1;$h=1; // Get maximum row height per row for($i=0; $i < $m; ++$i) { $h=0; for($j=0; $j < $n; ++$j) { $h = max($h,$this->iCells[$i][$j]->GetHeight($aImg)); } if( isset($this->iRowHeight[$i]) ) { $this->iRowHeight[$i] = max($h,$this->iRowHeight[$i]); } else $this->iRowHeight[$i] = $h; } // Get maximum col width per columns for($j=0; $j < $n; ++$j) { $w=0; for($i=0; $i < $m; ++$i) { $w = max($w,$this->iCells[$i][$j]->GetWidth($aImg)); } if( isset($this->iColWidth[$j]) ) { $this->iColWidth[$j] = max($w,$this->iColWidth[$j]); } else $this->iColWidth[$j] = $w; } } function _setcell($aRow,$aCol,$aVal='') { if( isset($this->iCells[$aRow][$aCol]) ) { $this->iCells[$aRow][$aCol]->Set($aVal); } else { $this->iCells[$aRow][$aCol] =& new GTextTableCell((string)$aVal,$aRow,$aCol); $this->iCells[$aRow][$aCol]->Init($this); } } function StrokeWithScale(&$aImg,$aXScale,$aYScale) { if( is_numeric($this->iScaleXPos) && is_numeric($this->iScaleYPos) ) { $x = round($aXScale->Translate($this->iScaleXPos)); $y = round($aYScale->Translate($this->iScaleYPos)); $this->Stroke($aImg,$x,$y); } else { $this->Stroke($aImg); } } function Stroke(&$aImg,$aX=NULL,$aY=NULL) { if( $aX !== NULL && $aY !== NULL ) { $this->iXPos = $aX; $this->iYPos = $aY; } $rc = $this->iSize[0]; // row count $cc = $this->iSize[1]; // column count if( $rc == 0 || $cc == 0 ) { JpGraphError::RaiseL(24009); } // Adjust margins of each cell based on the weight of the grid. Each table grid line // is actually occupying the left side and top part of each cell. for($j=0; $j < $cc; ++$j) { $this->iCells[0][$j]->iMarginTop += $this->iBorderWeight; } for($i=0; $i < $rc; ++$i) { $this->iCells[$i][0]->iMarginLeft += $this->iBorderWeight; } for($i=0; $i < $rc; ++$i) { for($j=0; $j < $cc; ++$j) { $this->iCells[$i][$j]->AdjustMarginsForGrid(); } } // adjust row and column size depending on cell content $this->_autoSizeTable($aImg); if( $this->iSize[1] != count($this->iColWidth) || $this->iSize[0] != count($this->iRowHeight) ) { JpGraphError::RaiseL(24008); //('Column and row size arrays must match the dimesnions of the table'); } // Find out overall table size $width=0; for($i=0; $i < $cc; ++$i