2
* Copyright (c) 2005-2010 Substance Kirill Grouchnikov. All Rights Reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* o Redistributions of source code must retain the above copyright notice,
8
* this list of conditions and the following disclaimer.
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.
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.
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.
30
package org.pushingpixels.substance.api;
32
import javax.swing.JProgressBar;
33
import javax.swing.JRootPane;
34
import javax.swing.text.JTextComponent;
37
* Defies a single facet of core and custom {@link ComponentState}s. See
38
* Javadocs of the {@link ComponentState} class for more information on state
42
* This class is experimental API and is likely to change in the next few
46
public final class ComponentStateFacet {
52
* Facet that describes the enabled bit.
54
public static final ComponentStateFacet ENABLE = new ComponentStateFacet(
58
* Facet that describes the rollover bit.
60
public static final ComponentStateFacet ROLLOVER = new ComponentStateFacet(
64
* Facet that describes the selection bit.
66
public static final ComponentStateFacet SELECTION = new ComponentStateFacet(
70
* Facet that describes the press bit.
72
public static final ComponentStateFacet PRESS = new ComponentStateFacet(
76
* Facet that describes the arm bit. This is relevant for menu items.
78
public static final ComponentStateFacet ARM = new ComponentStateFacet(
82
* Facet that describes the default bit. This is relevant for buttons which
83
* can be set as default with the
84
* {@link JRootPane#setDefaultButton(javax.swing.JButton)} API.
86
public static final ComponentStateFacet DEFAULT = new ComponentStateFacet(
90
* Facet that describes the determinate bit. This is relevant for
91
* {@link JProgressBar} control and its
92
* {@link JProgressBar#setIndeterminate(boolean)} API.
94
public static final ComponentStateFacet DETERMINATE = new ComponentStateFacet(
98
* Facet that describes the editable bit. This is relevant for
99
* {@link JTextComponent} derived controls and its
100
* {@link JTextComponent#setEditable(boolean)} API.
102
public static final ComponentStateFacet EDITABLE = new ComponentStateFacet(
106
* Creates a new facet.
111
* Facet value. This is used in the matching algorithm described
112
* in the javadocs of {@link ComponentState}. The larger the
113
* value, the more importance is given to the specific facet.
115
public ComponentStateFacet(String name, int value) {
118
throw new IllegalArgumentException(
119
"Facet value must be non-negative");
125
public String toString() {
126
return this.name + ":" + this.value;