117 * this odd arrangement:</p> 118 * <ul> 119 * <li>NimbusStyle calls State.isInState(c, s)</li> 120 * <li>State.isInState(c, s) simply delegates to State.isInState(c)</li> 121 * <li><em>EXCEPT</em>, StandardState overrides State.isInState(c, s) and 122 * returns directly from that method after checking its state, and 123 * does not call isInState(c) (since it is not needed for standard states).</li> 124 * </ul> 125 */ 126 boolean isInState(T c, int s) { 127 return isInState(c); 128 } 129 130 /** 131 * <p>Gets whether the specified JComponent is in the custom state represented 132 * by this class. <em>This is an extremely performance sensitive loop.</em> 133 * Please take proper precautions to ensure that it executes quickly.</p> 134 * 135 * <p>Nimbus uses this method to help determine what state a JComponent is 136 * in. For example, a custom State could exist for JProgressBar such that 137 * it would return <code>true</code> when the progress bar is indeterminate. 138 * Such an implementation of this method would simply be:</p> 139 * 140 * <pre><code> return c.isIndeterminate();</code></pre> 141 * 142 * @param c the JComponent to test. This will never be null. 143 * @return true if <code>c</code> is in the custom state represented by 144 * this <code>State</code> instance 145 */ 146 protected abstract boolean isInState(T c); 147 148 String getName() { return name; } 149 150 static boolean isStandardStateName(String name) { 151 return standardStates.containsKey(name); 152 } 153 154 static StandardState getStandardState(String name) { 155 return standardStates.get(name); 156 } 157 158 static final class StandardState extends State<JComponent> { 159 private int state; 160 161 private StandardState(int state) { 162 super(toString(state)); 163 this.state = state; 164 standardStates.put(getName(), this); | 117 * this odd arrangement:</p> 118 * <ul> 119 * <li>NimbusStyle calls State.isInState(c, s)</li> 120 * <li>State.isInState(c, s) simply delegates to State.isInState(c)</li> 121 * <li><em>EXCEPT</em>, StandardState overrides State.isInState(c, s) and 122 * returns directly from that method after checking its state, and 123 * does not call isInState(c) (since it is not needed for standard states).</li> 124 * </ul> 125 */ 126 boolean isInState(T c, int s) { 127 return isInState(c); 128 } 129 130 /** 131 * <p>Gets whether the specified JComponent is in the custom state represented 132 * by this class. <em>This is an extremely performance sensitive loop.</em> 133 * Please take proper precautions to ensure that it executes quickly.</p> 134 * 135 * <p>Nimbus uses this method to help determine what state a JComponent is 136 * in. For example, a custom State could exist for JProgressBar such that 137 * it would return {@code true} when the progress bar is indeterminate. 138 * Such an implementation of this method would simply be:</p> 139 * 140 * <pre>{@code return c.isIndeterminate();}</pre> 141 * 142 * @param c the JComponent to test. This will never be null. 143 * @return true if {@code c} is in the custom state represented by 144 * this {@code State} instance 145 */ 146 protected abstract boolean isInState(T c); 147 148 String getName() { return name; } 149 150 static boolean isStandardStateName(String name) { 151 return standardStates.containsKey(name); 152 } 153 154 static StandardState getStandardState(String name) { 155 return standardStates.get(name); 156 } 157 158 static final class StandardState extends State<JComponent> { 159 private int state; 160 161 private StandardState(int state) { 162 super(toString(state)); 163 this.state = state; 164 standardStates.put(getName(), this); |