下面列出了javax.swing.table.TableColumn#getWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Adjust the column widths of a table based on the table contents.
*
* @param table adjusted table
*/
private void adjustColumnWidths(JTable table) {
TableColumnModel model = table.getColumnModel();
for (int column = 0; column < table.getColumnCount(); column++) {
TableColumn tc = model.getColumn(column);
int width = tc.getWidth();
for (int row = 0; row < table.getRowCount(); row++) {
Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column);
width = Math.max(width, comp.getPreferredSize().width);
}
tc.setPreferredWidth(width);
}
}
public void copyValues(TableColumn base) {
modelIndex = base.getModelIndex();
identifier = base.getIdentifier();
width = base.getWidth();
minWidth = base.getMinWidth();
setPreferredWidth(base.getPreferredWidth());
maxWidth = base.getMaxWidth();
headerRenderer = base.getHeaderRenderer();
headerValue = base.getHeaderValue();
cellRenderer = base.getCellRenderer();
cellEditor = base.getCellEditor();
isResizable = base.getResizable();
}
TableColumn createTableColumn(int columnIndex) {
return new TableColumn(columnIndex) {
public void setWidth(int width) {
if (getMaxWidth() == 0 && getWidth() == 0) {
TableColumn c = getPreviousVisibleColumn(this);
if (refWidth == -1) refWidth = c.getWidth();
c.setWidth(refWidth + width);
} else {
super.setWidth(width);
}
}
};
}
protected void drawVerticalLines(Graphics g, final int rowCount, final int height) {
g.setColor(ResultSetJXTable.GRID_COLOR);
TableColumnModel colModel = getColumnModel();
int x = 0;
for (int i = 0; i < colModel.getColumnCount(); ++i) {
TableColumn column = colModel.getColumn(i);
x += column.getWidth();
g.drawLine(x - 1, rowCount * rowHeight, x - 1, height);
}
}
public static void fitTableToLastColumn(JTable tab) {
TableColumnModel model = tab.getColumnModel();
TableColumn lastCol = model.getColumn(model.getColumnCount() - 1);
int delta = tab.getSize().width;
for(int i = 0; i < model.getColumnCount(); i++) {
delta -= model.getColumn(i).getWidth();
}
int newWidth = lastCol.getWidth() + delta;
lastCol.setWidth(newWidth);
}
@Override
public void paint(Graphics g2, JComponent c) {
final Graphics2D g = (Graphics2D)g2;
final GraphicsConfig config = new GraphicsConfig(g);
final Color bg = c.getBackground();
g.setPaint(new GradientPaint(0, 0, ColorUtil.shift(bg, 1.4), 0, c.getHeight(), ColorUtil.shift(bg, 0.9)));
final int h = c.getHeight();
final int w = c.getWidth();
g.fillRect(0,0, w, h);
g.setPaint(ColorUtil.shift(bg, 0.75));
g.drawLine(0, h-1, w, h-1);
g.drawLine(w-1, 0, w-1, h-1);
final Enumeration<TableColumn> columns = ((JTableHeader)c).getColumnModel().getColumns();
final Color lineColor = ColorUtil.shift(bg, 0.7);
final Color shadow = Gray._255.withAlpha(30);
int offset = 0;
while (columns.hasMoreElements()) {
final TableColumn column = columns.nextElement();
if (columns.hasMoreElements() && column.getWidth() > 0) {
offset += column.getWidth();
g.setColor(lineColor);
g.drawLine(offset-1, 1, offset-1, h-3);
g.setColor(shadow);
g.drawLine(offset, 1, offset, h-3);
}
}
config.restore();
super.paint(g, c);
}
@Override
public boolean saveSettings(Element element) {
element.addAttribute("horizontalScroll", String.valueOf(table.isHorizontalScrollEnabled()));
saveFontPreferences(element);
Element columnsElem = element.element("columns");
if (columnsElem != null) {
element.remove(columnsElem);
}
columnsElem = element.addElement("columns");
final List<TableColumn> visibleTableColumns = table.getColumns();
final List<Table.Column> visibleColumns = new ArrayList<>();
for (TableColumn tableColumn : visibleTableColumns) {
visibleColumns.add((Table.Column) tableColumn.getIdentifier());
}
List<TableColumn> columns = table.getColumns(true);
Collections.sort(
columns,
new Comparator<TableColumn>() {
@SuppressWarnings("SuspiciousMethodCalls")
@Override
public int compare(TableColumn col1, TableColumn col2) {
if (col1 instanceof TableColumnExt && !((TableColumnExt) col1).isVisible()) {
return 1;
}
if (col2 instanceof TableColumnExt && !((TableColumnExt) col2).isVisible()) {
return -1;
}
int i1 = visibleColumns.indexOf(col1.getIdentifier());
int i2 = visibleColumns.indexOf(col2.getIdentifier());
return Integer.compare(i1, i2);
}
}
);
for (TableColumn column : columns) {
Element colElem = columnsElem.addElement("column");
colElem.addAttribute("id", column.getIdentifier().toString());
int width = column.getWidth();
colElem.addAttribute("width", String.valueOf(width));
if (column instanceof TableColumnExt) {
Boolean visible = ((TableColumnExt) column).isVisible();
colElem.addAttribute("visible", visible.toString());
}
}
if (table.getRowSorter() != null) {
TableColumn sortedColumn = table.getSortedColumn();
List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys();
if (sortedColumn != null && !sortKeys.isEmpty()) {
columnsElem.addAttribute("sortColumn", String.valueOf(sortedColumn.getIdentifier()));
columnsElem.addAttribute("sortOrder", sortKeys.get(0).getSortOrder().toString());
}
}
return true;
}
/**
* 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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
@Override
public Component getTableCellRendererComponent(final JTable table,
final Object value,
final boolean isSelected,
final boolean hasFocus,
final int row,
final int column) {
try {
if (tableComponent == null) {
tableComponent = (JLabel) super.getTableCellRendererComponent(table,
value,
isSelected,
hasFocus,
row,
column);
tableComponent.setText("");
tableComponent.setVerticalAlignment(SwingConstants.CENTER);
tableComponent.setHorizontalAlignment(SwingConstants.CENTER);
}
setBackground(table, isSelected);
if (value == null) {
tableComponent.setIcon(null);
tableComponent.setText("");
return tableComponent;
}
if (value instanceof ProductEntry) {
final BufferedImage image = getImage((ProductEntry) value);
if (image == null) {
tableComponent.setIcon(null);
tableComponent.setText("Not available!");
} else {
final TableColumn tableColumn = table.getColumnModel().getColumn(column);
int cellWidth = tableColumn.getWidth();
int cellHeight = tableColumn.getWidth();
if (image.getHeight() > image.getWidth())
cellWidth = -1;
else
cellHeight = -1;
tableComponent.setIcon(
new ImageIcon(image.getScaledInstance(cellWidth, cellHeight, BufferedImage.SCALE_FAST)));
tableComponent.setText("");
setTableRowHeight(table, row);
}
} else {
tableComponent.setIcon(null);
}
} catch (Throwable e) {
SystemUtils.LOG.severe("QuicklookRenderer: " + e.getMessage());
}
return tableComponent;
}
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();
}
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();
}
public void doLayout() {
ProfilerColumnModel cModel = _getColumnModel();
JTableHeader header = getTableHeader();
TableColumn res = header == null ? null : header.getResizingColumn();
if (res != null) {
// Resizing column
int delta = getWidth() - cModel.getTotalColumnWidth();
TableColumn next = cModel.getNextVisibleColumn(res);
if (res == next) {
res.setWidth(res.getWidth() + delta);
} else {
next.setWidth(next.getWidth() + delta);
}
} else {
// Resizing table
int toResizeIndex = cModel.getFitWidthColumn();
if (toResizeIndex == -1) {
super.doLayout();
} else {
Enumeration<TableColumn> columns = cModel.getColumns();
TableColumn toResizeColumn = null;
int columnsWidth = 0;
while (columns.hasMoreElements()) {
TableColumn column = columns.nextElement();
if (column.getModelIndex() == toResizeIndex) {
if (!cModel.isColumnVisible(column)) {
super.doLayout();
return;
}
toResizeColumn = column;
} else {
columnsWidth += column.getWidth();
}
}
if (toResizeColumn != null) toResizeColumn.setWidth(getWidth() - columnsWidth);
// instead of super.doLayout()
layout();
}
}
}
/**
* (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();
}
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();
}
public void showTooltip(int row) {
TableColumn rootColumn = myTable.getColumnModel().getColumn(GraphTableModel.ROOT_COLUMN);
Point point = new Point(rootColumn.getWidth() + myCommitRenderer.getTooltipXCoordinate(row),
row * myTable.getRowHeight() + myTable.getRowHeight() / 2);
showTooltip(row, GraphTableModel.COMMIT_COLUMN, point, true);
}