use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class InlineCellEditEventHandler method handleLayerEvent.
public void handleLayerEvent(InlineCellEditEvent event) {
if (event.convertToLocal(gridLayer)) {
LayerCell cell = gridLayer.getCellByPosition(event.getColumnPosition(), event.getRowPosition());
InlineCellEditController.editCellInline(cell, event.getInitialValue(), event.getParent(), event.getConfigRegistry());
}
}
use of net.sourceforge.nattable.layer.cell.LayerCell 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;
}
use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class AbstractLayer method getBoundsByPosition.
public Rectangle getBoundsByPosition(int columnPosition, int rowPosition) {
LayerCell cell = getCellByPosition(columnPosition, rowPosition);
ILayer cellLayer = cell.getLayer();
int originColumnPosition = cell.getOriginColumnPosition();
int originRowPosition = cell.getOriginRowPosition();
int x = cellLayer.getStartXOfColumnPosition(originColumnPosition);
int y = cellLayer.getStartYOfRowPosition(originRowPosition);
int width = 0;
for (int i = 0; i < cell.getColumnSpan(); i++) {
width += cellLayer.getColumnWidthByPosition(originColumnPosition + i);
}
int height = 0;
for (int i = 0; i < cell.getRowSpan(); i++) {
height += cellLayer.getRowHeightByPosition(originRowPosition + i);
}
return new Rectangle(x, y, width, height);
}
use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class CellLayerPainter method paintLayer.
public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset, Rectangle pixelRectangle, IConfigRegistry configRegistry) {
if (pixelRectangle.width <= 0 || pixelRectangle.height <= 0) {
return;
}
Collection<LayerCell> spannedCells = new HashSet<LayerCell>();
Rectangle positionRectangle = getPositionRectangleFromPixelRectangle(natLayer, pixelRectangle);
for (int columnPosition = positionRectangle.x; columnPosition < positionRectangle.x + positionRectangle.width; columnPosition++) {
for (int rowPosition = positionRectangle.y; rowPosition < positionRectangle.y + positionRectangle.height; rowPosition++) {
LayerCell cell = natLayer.getCellByPosition(columnPosition, rowPosition);
if (cell != null) {
if (cell.isSpannedCell()) {
spannedCells.add(cell);
} else {
paintCell(cell, gc, configRegistry);
}
}
}
}
for (LayerCell cell : spannedCells) {
paintCell(cell, gc, configRegistry);
}
}
use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class CompositeLayer method getCellByPosition.
// Cell features
@Override
public LayerCell getCellByPosition(int compositeColumnPosition, int compositeRowPosition) {
ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, compositeRowPosition);
if (childLayerInfo == null) {
return null;
}
ILayer childLayer = childLayerInfo.getLayer();
int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset();
int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset();
final LayerCell cell = childLayer.getCellByPosition(childColumnPosition, childRowPosition);
if (cell != null) {
cell.updatePosition(this, underlyingToLocalColumnPosition(childLayer, cell.getOriginColumnPosition()), underlyingToLocalRowPosition(childLayer, cell.getOriginRowPosition()), underlyingToLocalColumnPosition(childLayer, cell.getColumnPosition()), underlyingToLocalRowPosition(childLayer, cell.getRowPosition()));
}
return cell;
}
Aggregations