]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/content/LabelDecorator.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui / src / org / simantics / browsing / ui / content / LabelDecorator.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.browsing.ui.content;
13
14 /**
15  * An interface for decorating aesthetic properties of an UI item, including the
16  * label text, font, background color and foreground color.
17  * 
18  * @author Tuukka Lehtonen
19  */
20 public interface LabelDecorator {
21
22     /**
23      * @param label the label before decoration
24      * @param column the name of the UI column which the label is for
25      * @param itemIndex the index of this label within its parenting
26      *        INodeContext
27      * @return the decorated label or <code>null</code> to denote
28      *         <em>no decoration</em>
29      */
30     String decorateLabel(String label, String column, int itemIndex);
31
32     <Color> Color decorateForeground(Color color, String column, int itemIndex);
33
34     <Color> Color decorateBackground(Color color, String column, int itemIndex);
35
36     /**
37      * @param font <code>null</code> if no default font is set ??
38      * @param column the name of the UI column which the label is for
39      * @param itemIndex the index of this label within its parenting
40      *        INodeContext
41      * @return the decorated font instance or <code>null</code> to indicate
42      *         "no decoration"
43      */
44     <Font> Font decorateFont(Font font, String column, int itemIndex);
45
46
47     /**
48      * Stub for simpler implementation of a LabelDecorator.
49      */
50     public static class Stub implements LabelDecorator {
51         @Override
52         public <Color> Color decorateBackground(Color color, String column, int itemIndex) {
53             return null;
54         }
55
56         @Override
57         public <Font> Font decorateFont(Font font, String column, int itemIndex) {
58             return null;
59         }
60
61         @Override
62         public <Color> Color decorateForeground(Color color, String column, int itemIndex) {
63             return null;
64         }
65
66         @Override
67         public String decorateLabel(String label, String column, int itemIndex) {
68             return null;
69         }
70     }
71
72 }