1 package org.simantics.browsing.ui.content;
3 import java.util.Collection;
5 public class CompositeLabelDecorator implements LabelDecorator {
7 Collection<LabelDecorator> decorators;
9 public static final LabelDecorator ID = new LabelDecorator() {
12 public String decorateLabel(String label, String column, int itemIndex) {
17 public <Color> Color decorateForeground(Color color, String column,
23 public <Color> Color decorateBackground(Color color, String column,
29 public <Font> Font decorateFont(Font font, String column, int itemIndex) {
35 private CompositeLabelDecorator(Collection<LabelDecorator> decorators) {
36 this.decorators = decorators;
39 public static LabelDecorator create(Collection<LabelDecorator> decorators) {
40 if(decorators.isEmpty())
42 else if(decorators.size() == 1)
43 return decorators.iterator().next();
45 return new CompositeLabelDecorator(decorators);
49 public String decorateLabel(String label, String column, int itemIndex) {
50 for(LabelDecorator decorator : decorators) {
51 String dlabel = decorator.decorateLabel(label, column, itemIndex);
59 public <Color> Color decorateForeground(Color color, String column,
61 for(LabelDecorator decorator : decorators) {
62 Color dcolor = decorator.decorateForeground(color, column, itemIndex);
70 public <Color> Color decorateBackground(Color color, String column,
72 for(LabelDecorator decorator : decorators) {
73 Color dcolor = decorator.decorateBackground(color, column, itemIndex);
81 public <Font> Font decorateFont(Font font, String column, int itemIndex) {
82 for(LabelDecorator decorator : decorators) {
83 Font dfont = decorator.decorateFont(font, column, itemIndex);