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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionCreates anImagePainterthat retrieves the image to render from theIConfigRegistry.ImagePainter(boolean paintBg) Creates anImagePainterthat retrieves the image to render from theIConfigRegistry.ImagePainter(org.eclipse.swt.graphics.Image image) Creates anImagePainterthat renders the provided image.ImagePainter(org.eclipse.swt.graphics.Image image, boolean paintBg) Creates anImagePainterthat 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.ImagegetImage(ILayerCell cell, IConfigRegistry configRegistry) intgetPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred height of the cell when rendered by this painter.intgetPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred width of the cell when rendered by this painter.booleanbooleanvoidpaintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) voidsetCalculateByHeight(boolean calculateByHeight) Configure whether theImagePaintershould calculate the cell dimensions by containing image height.voidsetCalculateByWidth(boolean calculateByWidth) Configure whether theImagePaintershould calculate the cell dimensions by containing image width.Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter
getBackgroundColourMethods 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 anImagePainterthat retrieves the image to render from theIConfigRegistry. -
ImagePainter
public ImagePainter(org.eclipse.swt.graphics.Image image) Creates anImagePainterthat renders the provided image.- Parameters:
image- The image to render.
-
ImagePainter
public ImagePainter(boolean paintBg) Creates anImagePainterthat retrieves the image to render from theIConfigRegistry.- Parameters:
paintBg-trueif the cell background should be painted by this painter,falseif it should be skipped.- Since:
- 1.4
-
ImagePainter
public ImagePainter(org.eclipse.swt.graphics.Image image, boolean paintBg) Creates anImagePainterthat renders the provided image.- Parameters:
image- The image to render.paintBg-trueif the cell background should be painted by this painter,falseif it should be skipped.
-
-
Method Details
-
getPreferredWidth
public int getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Description copied from interface:ICellPainterGet the preferred width of the cell when rendered by this painter. Used for auto-resize.- Specified by:
getPreferredWidthin interfaceICellPainter- Overrides:
getPreferredWidthin 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:ICellPainterGet the preferred height of the cell when rendered by this painter. Used for auto-resize.- Specified by:
getPreferredHeightin interfaceICellPainter- Overrides:
getPreferredHeightin 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:
getCellPainterAtin interfaceICellPainter- Overrides:
getCellPainterAtin classCellPainterWrapper
-
paintCell
public void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) - Specified by:
paintCellin interfaceICellPainter- Overrides:
paintCellin classBackgroundPainter
-
getImage
- Parameters:
cell- TheILayerCellfor which thisImagePainteris called.configRegistry- The currentIConfigRegistryto retrieve the cell style information from.- Returns:
- The
Imagethat should be painted by thisImagePainter.
-
isCalculateByWidth
public boolean isCalculateByWidth()- Returns:
trueif thisImagePainteris resizing the cell width to show the whole configured image,falseif the cell width is not touched by this painter.
-
setCalculateByWidth
public void setCalculateByWidth(boolean calculateByWidth) Configure whether theImagePaintershould calculate the cell dimensions by containing image width. This means the width of the cell is calculated by image width.- Parameters:
calculateByWidth-trueto calculate and modify the cell dimension according to the image width,falseto not modifying the cell dimensions.
-
isCalculateByHeight
public boolean isCalculateByHeight()- Returns:
trueif thisImagePainteris resizing the cell height to show the whole configured image,falseif the cell height is not touched by this painter.
-
setCalculateByHeight
public void setCalculateByHeight(boolean calculateByHeight) Configure whether theImagePaintershould calculate the cell dimensions by containing image height. This means the height of the cell is calculated by image height.- Parameters:
calculateByHeight-trueto calculate and modify the cell dimension according to the image height,falseto not modifying the cell dimensions.
-