Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to paint multiple images in a cell.
How to paint multiple images in a cell. [message #1679929] Mon, 16 March 2015 20:34 Go to next message
Nandita Uppalapati is currently offline Nandita UppalapatiFriend
Messages: 16
Registered: March 2013
Junior Member
I am struggling to get to paint multiple images in one cell. Some cells need one icon and some cells need two icons. So I set labels accordingly to the cells. And I set the Image Painters such that one painter paints the image to the left and another to the top.

But at a time only one image is being painted. The Label which NatTable finds first is the corresponding image that it is displaying. Is there a way to paint multiple images in the same cell?

	@Override
	public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, 
			int rowPosition) {
		if(dataProvider.hasImage(columnPosition, rowPosition)){
			configLabels.addLabel(NatTableLabelConstants.CELL_WITH_IMAGE);
		}
		
		List<String> labels = dataProvider.getLabels(columnPosition, rowPosition);
		
		if(labels!=null ){
			for(String label: labels){
				configLabels.addLabel(label);
			}
		}
}


ImagePainter imagePainter = new ImagePainter(mStyle.getRejectedCellImage(), true);
			CellPainterDecorator imageDecorator = new CellPainterDecorator(beveledDecorator, CellEdgeEnum.TOP, imagePainter);
			configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, imageDecorator, DisplayMode.NORMAL, OrdersNatTableLabelConstants.CELL_WITH_REJECTED_IMAGE);

ImagePainter imagePainter = new ImagePainter(style.getCellImage(), true);
			CellPainterDecorator imageDecorator = new CellPainterDecorator(beveledDecorator, CellEdgeEnum.LEFT, imagePainter);
			configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, imageDecorator, DisplayMode.NORMAL, NatTableLabelConstants.CELL_WITH_IMAGE);

natTable.addConfiguration(new NatTableConfiguration(mStyle));
Re: How to paint multiple images in a cell. [message #1681138 is a reply to message #1679929] Tue, 17 March 2015 07:26 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Quote:
But at a time only one image is being painted


This is because you configured two different painters. There is only one cell painter active at a time. If you want to show multiple painters at a time, you need to combine them via CellPainterDecorator.

That said, either you add a third label to indicate that both icons should be shown and register a CellPainterDecorator that decorates your first decorator, or you implement a custom painter that inspects the labels itself and delegates according to that.
Re: How to paint multiple images in a cell. [message #1682023 is a reply to message #1681138] Tue, 17 March 2015 15:09 Go to previous messageGo to next message
Nandita Uppalapati is currently offline Nandita UppalapatiFriend
Messages: 16
Registered: March 2013
Junior Member
I am now able to paint two images. I added all the labels and removed CELL_WITH_IMAGE label if there is a REJECTED_IMAGE label and did a CellPainterDecorator. I did one image on top and other on left. Is there is a way where I can do both images side by side and text like [image1][image2] [text] kind of in the same cell?
Re: How to paint multiple images in a cell. [message #1682043 is a reply to message #1682023] Tue, 17 March 2015 15:16 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
wrap you decorator with a decorator
Previous Topic:Unwanted behaviour: SelectionChanged on Mouseover
Next Topic:Export to Excel functionality
Goto Forum:
  


Current Time: Sat Mar 06 16:43:11 GMT 2021

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

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

Back to the top