(Graphics g)
| 276 | |
| 277 | /// {@inheritDoc} |
| 278 | @Override |
| 279 | protected void paintGlass(Graphics g) { |
| 280 | if ((drawBorder) && (innerBorder != INNER_BORDERS_NONE)) { |
| 281 | int xPos = getAbsoluteX(); |
| 282 | int yPos = getAbsoluteY(); |
| 283 | g.translate(xPos, yPos); |
| 284 | int rows = model.getRowCount(); |
| 285 | int cols = model.getColumnCount(); |
| 286 | if (includeHeader) { |
| 287 | rows++; |
| 288 | } |
| 289 | g.setColor(getStyle().getFgColor()); |
| 290 | int alpha = g.concatenateAlpha(getStyle().getFgAlpha()); |
| 291 | TableLayout t = (TableLayout) getLayout(); |
| 292 | int actualWidth = Math.max(getWidth(), getScrollDimension().getWidth()); |
| 293 | int actualHeight = Math.max(getHeight(), getScrollDimension().getHeight()); |
| 294 | |
| 295 | if ((collapseBorder) || (innerBorder != INNER_BORDERS_ALL) || // inner borders cols/rows are supported only in collapsed mode |
| 296 | (t.hasHorizontalSpanning()) || (t.hasVerticalSpanning())) { // TODO - We currently don't support separate borders for tables with spanned cells |
| 297 | if ((innerBorder == INNER_BORDERS_ALL) || (innerBorder == INNER_BORDERS_ROWS)) { |
| 298 | if (t.hasVerticalSpanning()) { |
| 299 | // iterate over the components and draw a line on the side of all |
| 300 | // the components other than the ones that are at the last column. |
| 301 | for (int cellRow = 0; cellRow < rows - 1; cellRow++) { |
| 302 | for (int cellColumn = 0; cellColumn < cols; cellColumn++) { |
| 303 | // if this isn't the last row |
| 304 | if (cellRow + t.getCellVerticalSpan(cellRow, cellColumn) - 1 != rows - 1) { |
| 305 | // if this is a spanned through cell we don't want to draw a line here |
| 306 | if (t.isCellSpannedThroughHorizontally(cellRow, cellColumn)) { |
| 307 | continue; |
| 308 | } |
| 309 | |
| 310 | int x = t.getColumnPosition(cellColumn); |
| 311 | int y = t.getRowPosition(cellRow); |
| 312 | int rowHeight = t.getRowPosition(cellRow + t.getCellVerticalSpan(cellRow, cellColumn)) - y; |
| 313 | int columnWidth; |
| 314 | if (cellColumn < getModel().getColumnCount() - 1) { |
| 315 | columnWidth = t.getColumnPosition(cellColumn + 1) - x; |
| 316 | } else { |
| 317 | columnWidth = getWidth() - y; |
| 318 | } |
| 319 | |
| 320 | if ((innerBorder != INNER_BORDERS_ROWS) || (shouldDrawInnerBorderAfterRow(cellRow))) { |
| 321 | g.drawLine(x, y + rowHeight, x + columnWidth, y + rowHeight); |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } else { |
| 327 | // this is much faster since we don't need to check spanning |
| 328 | for (int row = 1; row < rows; row++) { |
| 329 | int y = t.getRowPosition(row); |
| 330 | if ((innerBorder != INNER_BORDERS_ROWS) || (shouldDrawInnerBorderAfterRow(row - 1))) { |
| 331 | g.drawLine(0, y, actualWidth, y); |
| 332 | } |
| 333 | //g.drawLine(0+2, y+2, actualWidth-2, y+2); |
| 334 | |
| 335 | } |
no test coverage detected