484 if (horizontal) { 485 rect.x = 0; 486 rect.width = table.getWidth(); 487 } else { 488 rect.y = 0; 489 490 if (table.getRowCount() != 0) { 491 Rectangle lastRect = table.getCellRect(table.getRowCount() - 1, 0, true); 492 rect.height = lastRect.y + lastRect.height; 493 } else { 494 rect.height = table.getHeight(); 495 } 496 } 497 498 return rect; 499 } 500 501 /* 502 * Paints the grid lines within <I>aRect</I>, using the grid 503 * color set with <I>setGridColor</I>. Paints vertical lines 504 * if <code>getShowVerticalLines()</code> returns true and paints 505 * horizontal lines if <code>getShowHorizontalLines()</code> 506 * returns true. 507 */ 508 private void paintGrid(SynthContext context, Graphics g, int rMin, 509 int rMax, int cMin, int cMax) { 510 g.setColor(table.getGridColor()); 511 512 Rectangle minCell = table.getCellRect(rMin, cMin, true); 513 Rectangle maxCell = table.getCellRect(rMax, cMax, true); 514 Rectangle damagedArea = minCell.union( maxCell ); 515 SynthGraphicsUtils synthG = context.getStyle().getGraphicsUtils( 516 context); 517 518 if (table.getShowHorizontalLines()) { 519 int tableWidth = damagedArea.x + damagedArea.width; 520 int y = damagedArea.y; 521 for (int row = rMin; row <= rMax; row++) { 522 y += table.getRowHeight(row); 523 synthG.drawLine(context, "Table.grid", 524 g, damagedArea.x, y - 1, tableWidth - 1,y - 1); 525 } | 484 if (horizontal) { 485 rect.x = 0; 486 rect.width = table.getWidth(); 487 } else { 488 rect.y = 0; 489 490 if (table.getRowCount() != 0) { 491 Rectangle lastRect = table.getCellRect(table.getRowCount() - 1, 0, true); 492 rect.height = lastRect.y + lastRect.height; 493 } else { 494 rect.height = table.getHeight(); 495 } 496 } 497 498 return rect; 499 } 500 501 /* 502 * Paints the grid lines within <I>aRect</I>, using the grid 503 * color set with <I>setGridColor</I>. Paints vertical lines 504 * if {@code getShowVerticalLines()} returns true and paints 505 * horizontal lines if {@code getShowHorizontalLines()} 506 * returns true. 507 */ 508 private void paintGrid(SynthContext context, Graphics g, int rMin, 509 int rMax, int cMin, int cMax) { 510 g.setColor(table.getGridColor()); 511 512 Rectangle minCell = table.getCellRect(rMin, cMin, true); 513 Rectangle maxCell = table.getCellRect(rMax, cMax, true); 514 Rectangle damagedArea = minCell.union( maxCell ); 515 SynthGraphicsUtils synthG = context.getStyle().getGraphicsUtils( 516 context); 517 518 if (table.getShowHorizontalLines()) { 519 int tableWidth = damagedArea.x + damagedArea.width; 520 int y = damagedArea.y; 521 for (int row = rMin; row <= rMax; row++) { 522 y += table.getRowHeight(row); 523 synthG.drawLine(context, "Table.grid", 524 g, damagedArea.x, y - 1, tableWidth - 1,y - 1); 525 } |