Class SelectionLayerPainter
java.lang.Object
org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter
org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter
org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter
- All Implemented Interfaces:
ILayerPainter
- Direct Known Subclasses:
CopySelectionLayerPainter,FillHandleLayerPainter
Specialised GridLineCellLayerPainter that renders an additional border around
selected cells. By default the additional selection anchor border style is
black dotted one pixel sized line. This style can be configured via
ConfigRegistry.
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter
gridLineWidth, renderGridLines -
Constructor Summary
ConstructorsConstructorDescriptionCreate a SelectionLayerPainter that renders gray grid lines and uses the default clipping behaviour.SelectionLayerPainter(boolean clipLeft, boolean clipTop) Create a SelectionLayerPainter that renders gray grid lines and uses the specified clipping behaviour.SelectionLayerPainter(org.eclipse.swt.graphics.Color gridColor) Create a SelectionLayerPainter that renders grid lines in the specified color and uses the default clipping behaviour.SelectionLayerPainter(org.eclipse.swt.graphics.Color gridColor, boolean clipLeft, boolean clipTop) Create a SelectionLayerPainter that renders grid lines in the specified color and uses the specified clipping behaviour. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.swt.graphics.RectanglefixBoundsInGridLines(org.eclipse.swt.graphics.Rectangle cellBounds, int xOffset, int yOffset) Returns a rectangle that will cover the left and top grid lines, if they are present.protected BorderPainter.BorderCell[][]getBorderCells(ILayer natLayer, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle positionRectangle, Function<ILayerCell, Boolean> function) Calculate the cells around which borders should be painted.protected BorderStylegetBorderStyle(IConfigRegistry configRegistry) Get the border style that should be used to render the border for cells that are currently selected.protected booleanisInCurrentLayer(int ix, int iy, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle cellBounds, BorderPainter.BorderCell[][] borderCells) Tries to detect if the cell is part of the current layer.voidpaintLayer(ILayer natLayer, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle pixelRectangle, IConfigRegistry configRegistry) Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter
adjustCellBounds, drawGridLines, getGridColorMethods inherited from class org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter
getPositionRectangleFromPixelRectangle, getStartXOfColumnPosition, getStartYOfRowPosition, isClipLeft, isClipTop, paintCell
-
Constructor Details
-
SelectionLayerPainter
public SelectionLayerPainter(org.eclipse.swt.graphics.Color gridColor) Create a SelectionLayerPainter that renders grid lines in the specified color and uses the default clipping behaviour.- Parameters:
gridColor- The color that should be used to render the grid lines.
-
SelectionLayerPainter
public SelectionLayerPainter()Create a SelectionLayerPainter that renders gray grid lines and uses the default clipping behaviour. -
SelectionLayerPainter
public SelectionLayerPainter(org.eclipse.swt.graphics.Color gridColor, boolean clipLeft, boolean clipTop) Create a SelectionLayerPainter that renders grid lines in the specified color and uses the specified clipping behaviour.- Parameters:
gridColor- The color that should be used to render the grid lines.clipLeft- Configure the rendering behaviour when cells overlap. If set totruethe left cell will be clipped, if set tofalsethe right cell will be clipped. The default value isfalse.clipTop- Configure the rendering behaviour when cells overlap. If set totruethe top cell will be clipped, if set tofalsethe bottom cell will be clipped. The default value isfalse.
-
SelectionLayerPainter
public SelectionLayerPainter(boolean clipLeft, boolean clipTop) Create a SelectionLayerPainter that renders gray grid lines and uses the specified clipping behaviour.- Parameters:
clipLeft- Configure the rendering behaviour when cells overlap. If set totruethe left cell will be clipped, if set tofalsethe right cell will be clipped. The default value isfalse.clipTop- Configure the rendering behaviour when cells overlap. If set totruethe top cell will be clipped, if set tofalsethe bottom cell will be clipped. The default value isfalse.
-
-
Method Details
-
paintLayer
public void paintLayer(ILayer natLayer, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle pixelRectangle, IConfigRegistry configRegistry) - Specified by:
paintLayerin interfaceILayerPainter- Overrides:
paintLayerin classGridLineCellLayerPainter- Parameters:
natLayer- The layer to paint.gc- GC used for paintingxOffset- x offset of the layer from the origin of the tableyOffset- y offset of the layer from the origin of the tablepixelRectangle- area the layer can paint inconfigRegistry-IConfigRegistryin use by NatTable. Useful for looking up associated painters.
-
getBorderCells
protected BorderPainter.BorderCell[][] getBorderCells(ILayer natLayer, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle positionRectangle, Function<ILayerCell, Boolean> function) Calculate the cells around which borders should be painted.- Parameters:
natLayer- The layer that is painted.xOffset- of the layer from the origin of the tableyOffset- of the layer from the origin of the tablepositionRectangle- The calculated position rectangle for the pixel rectangle that should be painted.function- The function that is used to determine if a border should be applied to a cell or not.- Returns:
- The
BorderPainter.BorderCells around which the border should be painted ornullif no border rendering is necessary. - Since:
- 2.0
-
fixBoundsInGridLines
protected org.eclipse.swt.graphics.Rectangle fixBoundsInGridLines(org.eclipse.swt.graphics.Rectangle cellBounds, int xOffset, int yOffset) Returns a rectangle that will cover the left and top grid lines, if they are present.- Parameters:
cellBounds- the rectangle that needs to be consideredxOffset- the starting x coordinate of the area we can draw on. The fix will not be applied if thecellBoundsare placed on this limit.yOffset- the starting y coordinate of the area we can draw on. The fix will not be applied if thecellBoundsare placed on this limit.- Returns:
- Updated rectangle.
- Since:
- 1.5
-
isInCurrentLayer
protected boolean isInCurrentLayer(int ix, int iy, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle cellBounds, BorderPainter.BorderCell[][] borderCells) Tries to detect if the cell is part of the current layer. It does so using xOffset/yOffset (which are not affected by single cell updates) and detecting overlapping of cells, which should not be possible in the same layer. It's not perfect, there might be false positives.- Parameters:
ix- column positioniy- row positionxOffset- column offsetyOffset- row offsetcellBounds- cell boundsborderCells- available border cells- Returns:
trueif the cell is part of the current layer.- Since:
- 1.5
-
getBorderStyle
Get the border style that should be used to render the border for cells that are currently selected. Checks theIConfigRegistryfor a registeredIStylefor theSelectionConfigAttributes.SELECTION_GRID_LINE_STYLElabel or theSelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLElabel. If none is registered, a default line style will be returned.- Parameters:
configRegistry- TheIConfigRegistryto retrieve the style information from.- Returns:
- The border style that should be used
- Since:
- 1.5
-