Java Code Examples for javax.swing.table.TableColumnModel#getColumnMargin()

The following examples show how to use javax.swing.table.TableColumnModel#getColumnMargin() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BookmarksView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void updateTableColumnSizes() {
    ETable table = tableView.getTable();
    Font font = tableView.getFont();
    FontMetrics fm = tableView.getFontMetrics(font);
    int maxCharWidth = fm.charWidth('A');
    int editingBorder = 4;
    TableColumnModel columnModel = table.getColumnModel();

    TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(8 * maxCharWidth + editingBorder); // 8 chars for name

    TableColumn keyColumn = columnModel.getColumn(1);
    // Single char for key (but 3 chars to prevent "..." in column header)
    keyColumn.setPreferredWidth(3 * maxCharWidth + editingBorder);
    keyColumn.setMinWidth(keyColumn.getPreferredWidth());

    TableColumn locationColumn = columnModel.getColumn(2);
    Insets insets = tableView.getBorder().getBorderInsets(tableView);
    int remainingWidth = tableView.getParent().getWidth() - insets.left - insets.right;
    remainingWidth -= 2 * columnModel.getColumnMargin();
    remainingWidth -= nameColumn.getPreferredWidth();
    remainingWidth -= keyColumn.getPreferredWidth();
    locationColumn.setPreferredWidth(remainingWidth); // remaining space for location
}
 
Example 2
Source File: GroupableTableHeaderUI.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
private Dimension createHeaderSize(long width) {
  TableColumnModel columnModel = header.getColumnModel();
  width += columnModel.getColumnMargin() * columnModel.getColumnCount();
  if (width > Integer.MAX_VALUE) {
    width = Integer.MAX_VALUE;
  }
  return new Dimension((int) width, getHeaderHeight());
}
 
Example 3
Source File: GroupableTableHeaderUI.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private Dimension createHeaderSize(long width) {
  TableColumnModel columnModel = header.getColumnModel();
  width += columnModel.getColumnMargin() * columnModel.getColumnCount();
  if (width > Integer.MAX_VALUE) {
    width = Integer.MAX_VALUE;
  }
  return new Dimension((int) width, getHeaderHeight());
}
 
Example 4
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  super.getTableCellRendererComponent(table, value, isSelected, false, row, column);

  TableColumnModel cm = table.getColumnModel();
  // TEST: this.setBorder(BorderFactory.createMatteBorder(0, 16, 0, 16, Color.RED));
  Insets i = this.getInsets();
  CELL_RECT.x = i.left;
  CELL_RECT.y = i.top;
  CELL_RECT.width = cm.getColumn(column).getWidth() - cm.getColumnMargin() - i.right - CELL_RECT.x;
  CELL_RECT.height = table.getRowHeight(row) - table.getRowMargin() - i.bottom - CELL_RECT.y;
  ICON_RECT.setBounds(0, 0, 0, 0); // .x = ICON_RECT.y = ICON_RECT.width = ICON_RECT.height = 0;
  TEXT_RECT.setBounds(0, 0, 0, 0); // .x = TEXT_RECT.y = TEXT_RECT.width = TEXT_RECT.height = 0;

  String str = SwingUtilities.layoutCompoundLabel(
      this,
      this.getFontMetrics(this.getFont()),
      Objects.toString(value, ""), // this.getText(),
      this.getIcon(),
      this.getVerticalAlignment(),
      this.getHorizontalAlignment(),
      this.getVerticalTextPosition(),
      this.getHorizontalTextPosition(),
      CELL_RECT,
      ICON_RECT, // icon
      TEXT_RECT, // text
      this.getIconTextGap());

  if (isRolloverCell(table, row, column)) {
    setText("<html><u><font color='blue'>" + str);
  } else {
    setText(str);
  }
  return this;
}
 
Example 5
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  super.getTableCellRendererComponent(table, value, isSelected, false, row, column);

  TableColumnModel cm = table.getColumnModel();
  Insets i = this.getInsets();
  CELL_RECT.x = i.left;
  CELL_RECT.y = i.top;
  CELL_RECT.width = cm.getColumn(column).getWidth() - cm.getColumnMargin() - i.right - CELL_RECT.x;
  CELL_RECT.height = table.getRowHeight(row) - table.getRowMargin() - i.bottom - CELL_RECT.y;
  ICON_RECT.setBounds(0, 0, 0, 0);
  TEXT_RECT.setBounds(0, 0, 0, 0);

  String str = SwingUtilities.layoutCompoundLabel(
      this,
      this.getFontMetrics(this.getFont()),
      Objects.toString(value, ""), // this.getText(),
      this.getIcon(),
      this.getVerticalAlignment(),
      this.getHorizontalAlignment(),
      this.getVerticalTextPosition(),
      this.getHorizontalTextPosition(),
      CELL_RECT,
      ICON_RECT, // icon
      TEXT_RECT, // text
      this.getIconTextGap());

  if (isRolloverCell(table, row, column)) {
    setText("<html><u><font color='blue'>" + str);
  } else if (hasFocus) {
    setText("<html><font color='blue'>" + str);
  } else {
    setText(str);
  }
  return this;
}
 
Example 6
Source File: GroupableTableHeaderUI.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Calculate and return the dimension of the header.
 *
 * @param width Starting width to be used.
 * @return Dimension of the header
 */
private Dimension createHeaderSize(long width) {
    TableColumnModel columnModel = header.getColumnModel();
    width += columnModel.getColumnMargin() * columnModel.getColumnCount();
    if (width > Integer.MAX_VALUE) {
        width = Integer.MAX_VALUE;
    }
    return new Dimension((int) width, getHeaderHeight());
}
 
Example 7
Source File: SynthTableUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 8
Source File: SynthTableUI.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 9
Source File: SynthTableUI.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 10
Source File: SynthTableUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 11
Source File: SynthTableUI.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 12
Source File: SynthTableUI.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 13
Source File: SeaGlassTableUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
 * Paint cells.
 *
 * @param context DOCUMENT ME!
 * @param g       DOCUMENT ME!
 * @param rMin    DOCUMENT ME!
 * @param rMax    DOCUMENT ME!
 * @param cMin    DOCUMENT ME!
 * @param cMax    DOCUMENT ME!
 */
private void paintCells(SeaGlassContext context, Graphics g, int rMin, int rMax, int cMin, int cMax) {
    JTableHeader header        = table.getTableHeader();
    TableColumn  draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm           = table.getColumnModel();
    int              columnMargin = cm.getColumnMargin();

    Rectangle   cellRect;
    TableColumn aColumn;
    int         columnWidth;

    if (table.getComponentOrientation().isLeftToRight()) {
        for (int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for (int column = cMin; column <= cMax; column++) {
                aColumn        = cm.getColumn(column);
                columnWidth    = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }

                cellRect.x += columnWidth;
            }
        }
    } else {
        for (int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn  = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth    = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }

            for (int column = cMin + 1; column <= cMax; column++) {
                aColumn        =  cm.getColumn(column);
                columnWidth    =  aColumn.getWidth();
                cellRect.width =  columnWidth - columnMargin;
                cellRect.x     -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 14
Source File: DarkTableUIBridge.java    From darklaf with MIT License 4 votes vote down vote up
@Override
protected void paintCells(final Graphics g, final int rMin, final int rMax, final int cMin, final int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for (int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for (int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for (int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(g, cellRect, row, cMin);
            }
            for (int column = cMin + 1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(g, rMin, rMax, cMin, cMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 15
Source File: TaskListTableUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
    * (copy & paste from BasicTableUI)
    */
   private void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax) {
JTableHeader header = table.getTableHeader();
TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

TableColumnModel cm = table.getColumnModel();
int columnMargin = cm.getColumnMargin();

       Rectangle cellRect;
TableColumn aColumn;
int columnWidth;
if (table.getComponentOrientation().isLeftToRight()) {
    for(int row = rMin; row <= rMax; row++) {
	cellRect = table.getCellRect(row, cMin, false);
               if( isFoldingRow( row ) ) {
                   //paint the cell across the whole table
                   cellRect.x = 0;
                   cellRect.width = table.getColumnModel().getTotalColumnWidth()-columnMargin;
                   paintCell( g, cellRect, row, 0 );
               } else {
                   for(int column = cMin; column <= cMax; column++) {
                       aColumn = cm.getColumn(column);
                       columnWidth = aColumn.getWidth();
                       cellRect.width = columnWidth - columnMargin;
                       if (aColumn != draggedColumn) {
                           paintCell(g, cellRect, row, column);
                       }
                       cellRect.x += columnWidth;
                   }
               }
    }
} else {
    for(int row = rMin; row <= rMax; row++) {
               cellRect = table.getCellRect(row, cMin, false);
               if( isFoldingRow( row ) ) {
                   //paint the cell across the whole table
                   cellRect.x = 0;
                   cellRect.width = table.getColumnModel().getTotalColumnWidth()-columnMargin;
                   paintCell( g, cellRect, row, 0 );
               } else {
                   aColumn = cm.getColumn(cMin);
                   if (aColumn != draggedColumn) {
                       columnWidth = aColumn.getWidth();
                       cellRect.width = columnWidth - columnMargin;
                       paintCell(g, cellRect, row, cMin);
                   }
                   for(int column = cMin+1; column <= cMax; column++) {
                       aColumn = cm.getColumn(column);
                       columnWidth = aColumn.getWidth();
                       cellRect.width = columnWidth - columnMargin;
                       cellRect.x -= columnWidth;
                       if (aColumn != draggedColumn) {
                           paintCell(g, cellRect, row, column);
                       }
                   }
               }
    }
}

       // Paint the dragged column if we are dragging.
       if (draggedColumn != null) {
    paintDraggedArea(g, rMin, rMax, draggedColumn, header.getDraggedDistance());
}

// Remove any renderers that may be left in the rendererPane.
rendererPane.removeAll();
   }
 
Example 16
Source File: SynthTableUI.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 17
Source File: SynthTableUI.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 18
Source File: SynthTableUI.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 19
Source File: SynthTableUI.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
Example 20
Source File: SynthTableUI.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}