Skip to main content



      Home
Home » Eclipse Projects » NatTable » Auto row height for images
Auto row height for images [message #1688846] Sat, 21 March 2015 19:19 Go to next message
Eclipse UserFriend
Hi all,
I've a column which displays an image depending on data value (i.e., the
data from model object is a path which points to an image). I've created
a CellImagePainter which overrides the getImage method:

public class CellImagePainter extends ImagePainter {

@Override
protected Image getImage(ILayerCell cell, IConfigRegistry
configRegistry) {
Image retval = null;
Object dataValue = cell.getDataValue();
if (dataValue instanceof Image) {
retval = (Image)dataValue;
}
return retval;
}

This works as expected, but the image is higher than the default height
on rows and therefore it's cut. How can I achieve that the row is
automatically resized according to the height of the image? If I use
this construct (taken from Examples):

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
new PaddingDecorator(
new CellPainterDecorator(
new AutomaticRowHeightTextPainter(2), CellEdgeEnum.LEFT, new
CellImagePainter())), DisplayMode.NORMAL, PICTURE_CELL_LABEL);

the cell is painted a little larger (but not enough) with the text
representation of the image (i.e., "{Image 5654601516}"). This is not
very beautiful...

TIA,
Ralf.
Re: Auto row height for images [message #1688947 is a reply to message #1688846] Sun, 22 March 2015 03:34 Go to previous messageGo to next message
Eclipse UserFriend
Well, if your images are higher than the default row height, why don't you increase the default row height? I assume all your images are higher than the default 20 pixels.

Otherwise you need to implement a logic in your image painter that supports automatic row resizing if the image is bigger than the current row height. This is what the AutomaticRowHeightTextPainter is doing for text.
Re: Auto row height for images [message #1688952 is a reply to message #1688947] Sun, 22 March 2015 03:45 Go to previous messageGo to next message
Eclipse UserFriend
Oh, I forgot that I implemented that feature already in ImagePainter for 1.2.0

You just need set the calculateByHeight flag on ImagePainter to true, so it automatically resizes the row height.
Re: Auto row height for images [message #1689036 is a reply to message #1688952] Sun, 22 March 2015 09:37 Go to previous message
Eclipse UserFriend
Am 22.03.2015 um 08:45 schrieb Dirk Fauth:
> Oh, I forgot that I implemented that feature already in ImagePainter for
> 1.2.0
>
> You just need set the calculateByHeight flag on ImagePainter to true, so
> it automatically resizes the row height.

Hi Dirk,
thanks for your fast answer. It works now as expected! NatTable rocks!!!

Regards,
Ralf.
Previous Topic:How to implement Lazy loading of tree nodes in nattable tree?
Next Topic:Re-ordering of rows doesn't update row header position
Goto Forum:
  


Current Time: Tue Jun 17 08:07:32 EDT 2025

Powered by FUDForum. Page generated in 0.28057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top