Class ImagePainter
java.lang.Object
org.eclipse.nebula.widgets.nattable.painter.cell.AbstractCellPainter
org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter
org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter
- All Implemented Interfaces:
ICellPainter
- Direct Known Subclasses:
CheckBoxPainter
,ColumnGroupExpandCollapseImagePainter
,ColumnHeaderCheckBoxPainter
,ComboBoxFilterIconPainter
,FilterIconPainter
,RowGroupExpandCollapseImagePainter
,SortIconPainter
,TreeCheckBoxPainter
,TreeImagePainter
Paints an image. If no image is provided, it will attempt to look up an image
from the cell style.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
-
Constructor Summary
ConstructorDescriptionCreates anImagePainter
that retrieves the image to render from theIConfigRegistry
.ImagePainter
(boolean paintBg) Creates anImagePainter
that retrieves the image to render from theIConfigRegistry
.ImagePainter
(org.eclipse.swt.graphics.Image image) Creates anImagePainter
that renders the provided image.ImagePainter
(org.eclipse.swt.graphics.Image image, boolean paintBg) Creates anImagePainter
that renders the provided image. -
Method Summary
Modifier and TypeMethodDescriptiongetCellPainterAt
(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) protected org.eclipse.swt.graphics.Image
getImage
(ILayerCell cell, IConfigRegistry configRegistry) int
getPreferredHeight
(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred height of the cell when rendered by this painter.int
getPreferredWidth
(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred width of the cell when rendered by this painter.boolean
boolean
void
paintCell
(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) void
setCalculateByHeight
(boolean calculateByHeight) Configure whether theImagePainter
should calculate the cell dimensions by containing image height.void
setCalculateByWidth
(boolean calculateByWidth) Configure whether theImagePainter
should calculate the cell dimensions by containing image width.Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter
getBackgroundColour
Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
getWrappedPainter, getWrappedPainterBounds, setWrappedPainter
-
Field Details
-
calculateByWidth
protected boolean calculateByWidth -
calculateByHeight
protected boolean calculateByHeight
-
-
Constructor Details
-
ImagePainter
public ImagePainter()Creates anImagePainter
that retrieves the image to render from theIConfigRegistry
. -
ImagePainter
public ImagePainter(org.eclipse.swt.graphics.Image image) Creates anImagePainter
that renders the provided image.- Parameters:
image
- The image to render.
-
ImagePainter
public ImagePainter(boolean paintBg) Creates anImagePainter
that retrieves the image to render from theIConfigRegistry
.- Parameters:
paintBg
-true
if the cell background should be painted by this painter,false
if it should be skipped.- Since:
- 1.4
-
ImagePainter
public ImagePainter(org.eclipse.swt.graphics.Image image, boolean paintBg) Creates anImagePainter
that renders the provided image.- Parameters:
image
- The image to render.paintBg
-true
if the cell background should be painted by this painter,false
if it should be skipped.
-
-
Method Details
-
getPreferredWidth
public int getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Description copied from interface:ICellPainter
Get the preferred width of the cell when rendered by this painter. Used for auto-resize.- Specified by:
getPreferredWidth
in interfaceICellPainter
- Overrides:
getPreferredWidth
in classCellPainterWrapper
- Parameters:
cell
- The cell for which the preferred width is requested.gc
- The GC that is used for rendering.configRegistry
- The IConfigRegistry that contains the configuration used for rendering.- Returns:
- The preferred width of the given cell when rendered by this painter.
-
getPreferredHeight
public int getPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Description copied from interface:ICellPainter
Get the preferred height of the cell when rendered by this painter. Used for auto-resize.- Specified by:
getPreferredHeight
in interfaceICellPainter
- Overrides:
getPreferredHeight
in classCellPainterWrapper
- Parameters:
cell
- The cell for which the preferred height is requested.gc
- The GC that is used for rendering.configRegistry
- The IConfigRegistry that contains the configuration used for rendering.- Returns:
- The preferred height of the given cell when rendered by this painter.
-
getCellPainterAt
public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) - Specified by:
getCellPainterAt
in interfaceICellPainter
- Overrides:
getCellPainterAt
in classCellPainterWrapper
-
paintCell
public void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) - Specified by:
paintCell
in interfaceICellPainter
- Overrides:
paintCell
in classBackgroundPainter
-
getImage
- Parameters:
cell
- TheILayerCell
for which thisImagePainter
is called.configRegistry
- The currentIConfigRegistry
to retrieve the cell style information from.- Returns:
- The
Image
that should be painted by thisImagePainter
.
-
isCalculateByWidth
public boolean isCalculateByWidth()- Returns:
true
if thisImagePainter
is resizing the cell width to show the whole configured image,false
if the cell width is not touched by this painter.
-
setCalculateByWidth
public void setCalculateByWidth(boolean calculateByWidth) Configure whether theImagePainter
should calculate the cell dimensions by containing image width. This means the width of the cell is calculated by image width.- Parameters:
calculateByWidth
-true
to calculate and modify the cell dimension according to the image width,false
to not modifying the cell dimensions.
-
isCalculateByHeight
public boolean isCalculateByHeight()- Returns:
true
if thisImagePainter
is resizing the cell height to show the whole configured image,false
if the cell height is not touched by this painter.
-
setCalculateByHeight
public void setCalculateByHeight(boolean calculateByHeight) Configure whether theImagePainter
should calculate the cell dimensions by containing image height. This means the height of the cell is calculated by image height.- Parameters:
calculateByHeight
-true
to calculate and modify the cell dimension according to the image height,false
to not modifying the cell dimensions.
-