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
public class SelectionLayerPainter extends GridLineCellLayerPainter
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
Constructors Constructor Description SelectionLayerPainter()
Create 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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 BorderStyle
getBorderStyle(IConfigRegistry configRegistry)
Get the border style that should be used to render the border for cells that are currently selected.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.void
paintLayer(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, getGridColor
-
Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter
getPositionRectangleFromPixelRectangle, getStartXOfColumnPosition, getStartYOfRowPosition, isClipLeft, isClipTop, paintCell
-
-
-
-
Constructor Detail
-
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 totrue
the left cell will be clipped, if set tofalse
the right cell will be clipped. The default value isfalse
.clipTop
- Configure the rendering behaviour when cells overlap. If set totrue
the top cell will be clipped, if set tofalse
the 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 totrue
the left cell will be clipped, if set tofalse
the right cell will be clipped. The default value isfalse
.clipTop
- Configure the rendering behaviour when cells overlap. If set totrue
the top cell will be clipped, if set tofalse
the bottom cell will be clipped. The default value isfalse
.
-
-
Method Detail
-
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:
paintLayer
in interfaceILayerPainter
- Overrides:
paintLayer
in 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
-IConfigRegistry
in 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.BorderCell
s around which the border should be painted ornull
if 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 thecellBounds
are placed on this limit.yOffset
- the starting y coordinate of the area we can draw on. The fix will not be applied if thecellBounds
are 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:
true
if the cell is part of the current layer.- Since:
- 1.5
-
getBorderStyle
protected BorderStyle getBorderStyle(IConfigRegistry configRegistry)
Get the border style that should be used to render the border for cells that are currently selected. Checks theIConfigRegistry
for a registeredIStyle
for theSelectionConfigAttributes.SELECTION_GRID_LINE_STYLE
label or theSelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE
label. If none is registered, a default line style will be returned.- Parameters:
configRegistry
- TheIConfigRegistry
to retrieve the style information from.- Returns:
- The border style that should be used
- Since:
- 1.5
-
-