1 package org.simantics.browsing.ui.content;
3 import java.util.Collection;
5 public class CompositeImageDecorator implements ImageDecorator {
7 Collection<ImageDecorator> decorators;
9 public static final ImageDecorator ID = new ImageDecorator() {
11 public <Image> Image decorateImage(Image image, String column, int itemIndex) {
16 private CompositeImageDecorator(Collection<ImageDecorator> decorators) {
17 this.decorators = decorators;
20 public static ImageDecorator create(Collection<ImageDecorator> decorators) {
21 if(decorators.isEmpty())
23 else if(decorators.size() == 1)
24 return decorators.iterator().next();
26 return new CompositeImageDecorator(decorators);
30 public <Image> Image decorateImage(Image image, String column, int itemIndex) {
31 for(ImageDecorator decorator : decorators)
32 image = decorator.decorateImage(image, column, itemIndex);