public void paintStripesAndGrid ( SeaGlassContext context , Graphics g , JComponent c , int width , int height , int top ) { int rh = table . getRowHeight ( ) ; int n = table . getRowCount ( ) ; int row = Math . abs ( top / rh ) ; // if (true) return; // TableCellRenderer renderer = // table.getDefaultRenderer(java.lang.Object.class); // Paint the background, including stripes if requested. if ( alternateColor != null ) { // Fill the viewport with background color. // Rossi: Ugly broken hack to make the first column white instead of blue. // To see how the new blue table headers look like. // This is should be done by modifying the "for loop" instead. g . setColor ( alternateColor ) ; g . fillRect ( 0 , 0 , width , height ) ; // Now check if we need to paint some stripes g . setColor ( table . getBackground ( ) ) ; // Paint table rows to fill the viewport. for ( int y = top + row * rh , ymax = height ; y < ymax ; y += rh ) { if ( row % 2 == 0 ) { g . fillRect ( 0 , y , width , rh ) ; } row ++ ; } } else { // Fill the viewport with the background color of the table g . setColor ( table . getBackground ( ) ) ; g . fillRect ( 0 , 0 , c . getWidth ( ) , c . getHeight ( ) ) ; } SynthGraphicsUtils synthG = context . getStyle ( ) . getGraphicsUtils ( context ) ; // Paint the horizontal grid lines if ( table . getShowHorizontalLines ( ) ) { g . setColor ( table . getGridColor ( ) ) ; row = Math . abs ( top / rh ) ; int y = top + row * rh + rh - 1 ; while ( y < height ) { synthG . drawLine ( context , "Table.grid" , g , 0 , y , width , y ) ; y += rh ; } } // Paint the vertical grid lines if ( table . getShowVerticalLines ( ) ) { g . setColor ( table . getGridColor ( ) ) ; TableColumnModel cm = table . getColumnModel ( ) ; n = cm . getColumnCount ( ) ; int y = top + row * rh ; ; int x = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { TableColumn col = cm . getColumn ( i ) ; x += col . getWidth ( ) ; synthG . drawLine ( context , "Table.grid" , g , x , y , x , height ) ; } } }
Paint the stripes and grid .