Search in sources :

Example 1 with ICellPainter

use of net.sourceforge.nattable.painter.cell.ICellPainter in project translationstudio8 by heartsome.

the class MaxCellBoundsHelper method getPreferredColumnWidth.

/**
	 * Calculates the minimum width (in pixels) required to display the complete 
	 *    contents of the cells in a column. Takes into account the font settings 
	 *    and display type conversion. 
	 */
public static int getPreferredColumnWidth(ILayer layer, int columnPosition, IConfigRegistry configRegistry, GC gc) {
    ICellPainter painter;
    int maxWidth = 0;
    LayerCell cell;
    for (int rowPosition = 0; rowPosition < layer.getRowCount(); rowPosition++) {
        cell = layer.getCellByPosition(columnPosition, rowPosition);
        if (cell != null) {
            painter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
            if (painter != null) {
                int preferedWidth = painter.getPreferredWidth(cell, gc, configRegistry);
                maxWidth = (preferedWidth > maxWidth) ? preferedWidth : maxWidth;
            }
        }
    }
    return maxWidth;
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) ICellPainter(net.sourceforge.nattable.painter.cell.ICellPainter)

Example 2 with ICellPainter

use of net.sourceforge.nattable.painter.cell.ICellPainter in project translationstudio8 by heartsome.

the class CellLayerPainter method paintCell.

protected void paintCell(LayerCell cell, GC gc, IConfigRegistry configRegistry) {
    ICellPainter cellPainter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
    Rectangle adjustedCellBounds = adjustCellBounds(cell.getBounds());
    cellPainter.paintCell(cell, gc, adjustedCellBounds, configRegistry);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) ICellPainter(net.sourceforge.nattable.painter.cell.ICellPainter)

Example 3 with ICellPainter

use of net.sourceforge.nattable.painter.cell.ICellPainter in project translationstudio8 by heartsome.

the class MaxCellBoundsHelper method getPreferredRowHeight.

public static int getPreferredRowHeight(ILayer layer, int rowPosition, IConfigRegistry configRegistry, GC gc) {
    int maxHeight = 0;
    ICellPainter painter;
    LayerCell cell;
    for (int columnPosition = 0; columnPosition < layer.getColumnCount(); columnPosition++) {
        cell = layer.getCellByPosition(columnPosition, rowPosition);
        if (cell != null) {
            painter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
            if (painter != null) {
                int preferedHeight = painter.getPreferredHeight(cell, gc, configRegistry);
                maxHeight = (preferedHeight > maxHeight) ? preferedHeight : maxHeight;
            }
        }
    }
    return maxHeight;
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) ICellPainter(net.sourceforge.nattable.painter.cell.ICellPainter)

Example 4 with ICellPainter

use of net.sourceforge.nattable.painter.cell.ICellPainter in project translationstudio8 by heartsome.

the class AutoResizeCurrentRowsCommandHandler method getPreferredRowHeight.

private int getPreferredRowHeight(ILayer layer, int rowPosition, IConfigRegistry configRegistry, GC gc, int clientAreaHeight) {
    int maxHeight = 0;
    ICellPainter painter;
    LayerCell cell;
    for (int columnPosition = 0; columnPosition < layer.getColumnCount(); columnPosition++) {
        cell = layer.getCellByPosition(columnPosition, rowPosition);
        if (cell != null) {
            painter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
            if (painter != null) {
                int preferedHeight = painter.getPreferredHeight(cell, gc, configRegistry);
                maxHeight = (preferedHeight > maxHeight) ? preferedHeight : maxHeight;
            }
        }
    }
    if (maxHeight > clientAreaHeight) {
        return clientAreaHeight;
    }
    return maxHeight;
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) ICellPainter(net.sourceforge.nattable.painter.cell.ICellPainter)

Example 5 with ICellPainter

use of net.sourceforge.nattable.painter.cell.ICellPainter in project translationstudio8 by heartsome.

the class RowHeightCalculator method getPreferredRowHeight.

private int getPreferredRowHeight(int rowPosition, IConfigRegistry configRegistry, int clientAreaHeight) {
    int maxHeight = 0;
    ICellPainter painter;
    LayerCell cell;
    SelectionLayer layer = bodyLayer.getSelectionLayer();
    for (int columnPosition = 0; columnPosition < layer.getColumnCount(); columnPosition++) {
        cell = layer.getCellByPosition(columnPosition, rowPosition);
        if (cell != null) {
            painter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), bodyLayer.getConfigLabelsByPosition(columnPosition, rowPosition).getLabels());
            if (painter != null) {
                int preferedHeight = painter.getPreferredHeight(cell, null, configRegistry);
                maxHeight = (preferedHeight > maxHeight) ? preferedHeight : maxHeight;
            }
        }
    }
    if (maxHeight > clientAreaHeight) {
        return clientAreaHeight;
    }
    return maxHeight;
}
Also used : SelectionLayer(net.sourceforge.nattable.selection.SelectionLayer) LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) ICellPainter(net.sourceforge.nattable.painter.cell.ICellPainter)

Aggregations

ICellPainter (net.sourceforge.nattable.painter.cell.ICellPainter)6 LayerCell (net.sourceforge.nattable.layer.cell.LayerCell)4 DefaultComparator (net.sourceforge.nattable.config.DefaultComparator)1 BeveledBorderDecorator (net.sourceforge.nattable.painter.cell.decorator.BeveledBorderDecorator)1 SelectionLayer (net.sourceforge.nattable.selection.SelectionLayer)1 SortableHeaderTextPainter (net.sourceforge.nattable.sort.painter.SortableHeaderTextPainter)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1