Search in sources :

Example 6 with LayerCell

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());
    }
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell)

Example 7 with LayerCell

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;
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) ICellPainter(net.sourceforge.nattable.painter.cell.ICellPainter)

Example 8 with LayerCell

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);
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 9 with LayerCell

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);
    }
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) Rectangle(org.eclipse.swt.graphics.Rectangle) HashSet(java.util.HashSet)

Example 10 with LayerCell

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;
}
Also used : LayerCell(net.sourceforge.nattable.layer.cell.LayerCell)

Aggregations

LayerCell (net.sourceforge.nattable.layer.cell.LayerCell)24 Rectangle (org.eclipse.swt.graphics.Rectangle)8 ICellPainter (net.sourceforge.nattable.painter.cell.ICellPainter)4 PositionCoordinate (net.sourceforge.nattable.coordinate.PositionCoordinate)3 IDisplayConverter (net.sourceforge.nattable.data.convert.IDisplayConverter)3 IStyle (net.sourceforge.nattable.style.IStyle)3 IDataValidator (net.sourceforge.nattable.data.validate.IDataValidator)2 UpdateDataCommand (net.sourceforge.nattable.edit.command.UpdateDataCommand)2 ICellEditor (net.sourceforge.nattable.edit.editor.ICellEditor)2 CellStyleProxy (net.sourceforge.nattable.style.CellStyleProxy)2 Point (org.eclipse.swt.graphics.Point)2 NavException (com.ximpleware.NavException)1 XPathEvalException (com.ximpleware.XPathEvalException)1 XPathParseException (com.ximpleware.XPathParseException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 InnerTagBean (net.heartsome.cat.common.innertag.InnerTagBean)1 XliffInnerTagFactory (net.heartsome.cat.common.innertag.factory.XliffInnerTagFactory)1 NoteBean (net.heartsome.cat.ts.core.bean.NoteBean)1