~ubuntu-branches/debian/stretch/insubstantial/stretch

« back to all changes in this revision

Viewing changes to substance/src/main/java/org/pushingpixels/substance/api/ColorSchemeAssociationKind.java

  • Committer: Package Import Robot
  • Author(s): Felix Natter
  • Date: 2016-01-18 20:58:45 UTC
  • Revision ID: package-import@ubuntu.com-20160118205845-crbmrkda61qsi5qa
Tags: upstream-7.3+dfsg2
ImportĀ upstreamĀ versionĀ 7.3+dfsg2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2005-2010 Substance Kirill Grouchnikov. All Rights Reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without 
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 * 
 
7
 *  o Redistributions of source code must retain the above copyright notice, 
 
8
 *    this list of conditions and the following disclaimer. 
 
9
 *     
 
10
 *  o Redistributions in binary form must reproduce the above copyright notice, 
 
11
 *    this list of conditions and the following disclaimer in the documentation 
 
12
 *    and/or other materials provided with the distribution. 
 
13
 *     
 
14
 *  o Neither the name of Substance Kirill Grouchnikov nor the names of 
 
15
 *    its contributors may be used to endorse or promote products derived 
 
16
 *    from this software without specific prior written permission. 
 
17
 *     
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 
20
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 
21
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 
22
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 
23
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 
24
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 
25
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 
26
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 
27
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 
28
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
29
 */
 
30
package org.pushingpixels.substance.api;
 
31
 
 
32
import java.util.*;
 
33
 
 
34
import javax.swing.JCheckBox;
 
35
import javax.swing.JTabbedPane;
 
36
 
 
37
/**
 
38
 * Allows associating different color schemes to different visual parts of UI
 
39
 * components. For example, the {@link JCheckBox} has three different visual
 
40
 * areas:
 
41
 * <ul>
 
42
 * <li>Border - assciated with {@link #BORDER}</li>
 
43
 * <li>Fill - associated with {@link #FILL}</li>
 
44
 * <li>Check mark - associated with {@link #MARK}</li>
 
45
 * </ul>
 
46
 * 
 
47
 * Applications can create custom instances of this class to further refine the
 
48
 * control over the painting. In this case, the custom UI delegates must be
 
49
 * created to use these new association kinds.
 
50
 * 
 
51
 * @author Kirill Grouchnikov
 
52
 * @since version 5.1
 
53
 */
 
54
public class ColorSchemeAssociationKind {
 
55
        /**
 
56
         * All known association kind values.
 
57
         */
 
58
        private static Set<ColorSchemeAssociationKind> values = new HashSet<ColorSchemeAssociationKind>();
 
59
 
 
60
        /**
 
61
         * Name for this association kind.
 
62
         */
 
63
        private String name;
 
64
 
 
65
        /**
 
66
         * Fallback for this association kind. This is used when no color scheme is
 
67
         * associated with this kind. For example, {@link #TAB_BORDER} specifies
 
68
         * that its fallback is {@link #BORDER}. When the {@link JTabbedPane} UI
 
69
         * delegate is painting the tabs, it will try to use the color scheme
 
70
         * associated with {@link #TAB_BORDER}. If none was registered, it will fall
 
71
         * back to use the color scheme associated with {@link #BORDER}, and if that
 
72
         * is not registered as well, will use the color scheme associated with
 
73
         * {@link #FILL}.
 
74
         */
 
75
        private ColorSchemeAssociationKind fallback;
 
76
 
 
77
        /**
 
78
         * Creates a new association kind.
 
79
         * 
 
80
         * @param name
 
81
         *            Association kind name.
 
82
         * @param fallback
 
83
         *            Fallback association kind. This is used when no color scheme
 
84
         *            is associated with this kind. For example, {@link #TAB_BORDER}
 
85
         *            specifies that its fallback is {@link #BORDER}. When the
 
86
         *            {@link JTabbedPane} UI delegate is painting the tabs, it will
 
87
         *            try to use the color scheme associated with
 
88
         *            {@link #TAB_BORDER}. If none was registered, it will fall back
 
89
         *            to use the color scheme associated with {@link #BORDER}, and
 
90
         *            if that is not registered as well, will use the color scheme
 
91
         *            associated with {@link #FILL}.
 
92
         */
 
93
        public ColorSchemeAssociationKind(String name,
 
94
                        ColorSchemeAssociationKind fallback) {
 
95
                this.name = name;
 
96
                this.fallback = fallback;
 
97
                values.add(this);
 
98
        }
 
99
 
 
100
        @Override
 
101
        public String toString() {
 
102
                return this.name;
 
103
        }
 
104
 
 
105
        /**
 
106
         * The default visual area that is used for the inner part of most controls.
 
107
         */
 
108
        public static final ColorSchemeAssociationKind FILL = new ColorSchemeAssociationKind(
 
109
                        "fill", null);
 
110
 
 
111
        /**
 
112
         * Visual area of separators.
 
113
         */
 
114
        public static final ColorSchemeAssociationKind SEPARATOR = new ColorSchemeAssociationKind(
 
115
                        "separator", FILL);
 
116
 
 
117
        /**
 
118
         * Fill visual area of the tabs.
 
119
         */
 
120
        public static final ColorSchemeAssociationKind TAB = new ColorSchemeAssociationKind(
 
121
                        "tab", FILL);
 
122
 
 
123
        /**
 
124
         * Border visual area of non-tab controls.
 
125
         */
 
126
        public static final ColorSchemeAssociationKind BORDER = new ColorSchemeAssociationKind(
 
127
                        "border", FILL);
 
128
 
 
129
        /**
 
130
         * Visual area of marks. Used for painting check marks of checkboxes and
 
131
         * radio buttons, as well as arrow icons of combo boxes, spinners and more.
 
132
         */
 
133
        public static final ColorSchemeAssociationKind MARK = new ColorSchemeAssociationKind(
 
134
                        "mark", BORDER);
 
135
 
 
136
        /**
 
137
         * Border visual area of the tabs.
 
138
         */
 
139
        public static final ColorSchemeAssociationKind TAB_BORDER = new ColorSchemeAssociationKind(
 
140
                        "tabBorder", BORDER);
 
141
 
 
142
        /**
 
143
         * Highlight visual areas for lists, tables, trees and menus.
 
144
         */
 
145
        public static final ColorSchemeAssociationKind HIGHLIGHT = new ColorSchemeAssociationKind(
 
146
                        "highlight", FILL);
 
147
 
 
148
        /**
 
149
         * Highlight visual areas for text components.
 
150
         */
 
151
        public static final ColorSchemeAssociationKind TEXT_HIGHLIGHT = new ColorSchemeAssociationKind(
 
152
                        "textHighlight", HIGHLIGHT);
 
153
 
 
154
        /**
 
155
         * Border visual areas for highlighted regions of lists, tables, trees and
 
156
         * menus.
 
157
         */
 
158
        public static final ColorSchemeAssociationKind HIGHLIGHT_BORDER = new ColorSchemeAssociationKind(
 
159
                        "highlightBorder", BORDER);
 
160
 
 
161
        /**
 
162
         * Visual area of marks in highlighted regions of lists, tables, trees and
 
163
         * menus.
 
164
         */
 
165
        public static final ColorSchemeAssociationKind HIGHLIGHT_MARK = new ColorSchemeAssociationKind(
 
166
                        "highlightMark", MARK);
 
167
 
 
168
        /**
 
169
         * Returns all available association kinds.
 
170
         * 
 
171
         * @return All available association kinds.
 
172
         */
 
173
        public static Set<ColorSchemeAssociationKind> values() {
 
174
                return Collections.unmodifiableSet(values);
 
175
        }
 
176
 
 
177
        /**
 
178
         * Returns the fallback for this association kind.
 
179
         * 
 
180
         * @return The fallback for this association kind.
 
181
         */
 
182
        public ColorSchemeAssociationKind getFallback() {
 
183
                return fallback;
 
184
        }
 
185
}
 
 
b'\\ No newline at end of file'