コード例 #1
0
 private void paintBorder(Graphics g, Rectangle cellRect, int row, int column) {
   if (grid.getSpanModel().isCellSpan(row, column)) {
     CellSpan span = grid.getSpanModel().getSpanOver(row, column);
     row = span.getRow();
     column = span.getColumn();
   }
   // Paint border
   javax.swing.border.Border border = grid.getStyleModel().getCellStyle(row, column).getBorder();
   Insets borderInsets = border.getBorderInsets(grid);
   Rectangle borderRect = new Rectangle(cellRect);
   int topOffset = (borderInsets.top >> 1);
   int leftOffset = (borderInsets.left >> 1);
   int bottomOffset = (borderInsets.bottom / 3) + topOffset;
   int rightOffset = (borderInsets.right / 3) + leftOffset;
   borderRect.x -= leftOffset;
   borderRect.y -= topOffset;
   borderRect.width += rightOffset;
   borderRect.height += bottomOffset;
   border.paintBorder(grid, g, borderRect.x, borderRect.y, borderRect.width, borderRect.height);
 }
コード例 #2
0
 /** Paint cell at (row, column) */
 protected void paintCell(Graphics g, Rectangle cellBounds, int row, int column) {
   if (grid.getEditingRow() == row && grid.getEditingColumn() == column) {
     return;
   }
   GridCellRenderer renderer = grid.getCellRenderer(row, column);
   Component rendererComp = grid.prepareRenderer(renderer, row, column);
   CellSpan span = grid.getSpanModel().getSpanOver(row, column);
   rendererPane.paintComponent(
       g,
       rendererComp,
       grid,
       cellBounds.x,
       cellBounds.y,
       cellBounds.width,
       cellBounds.height,
       true);
 }
コード例 #3
0
  /** special paint handler for merged cell regions */
  protected void paintSpans(Graphics g, int rowMin, int rowMax, int colMin, int colMax) {
    Rectangle clip = g.getClipBounds();
    Iterator cell = grid.getSpanModel().getSpanIterator();
    while (cell.hasNext()) {
      CellSpan span = (CellSpan) cell.next();
      Rectangle cellBounds = grid.getCellBounds(span.getRow(), span.getColumn());

      // Only paint cell if visible
      if (span.getLastRow() >= rowMin
          && span.getLastColumn() >= colMin
          && span.getFirstRow() <= rowMax
          && span.getFirstColumn() <= colMax) {
        paintCell(g, cellBounds, span.getRow(), span.getColumn());
        // Paint grid line around cell
        if (grid.getShowGrid()) {
          g.setColor(grid.getGridColor());
          g.drawRect(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height);
        }
      }
    }
  }