| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| IconState |
|
| 1.0;1 |
| 1 | /* | |
| 2 | ||
| 3 | dsh-iconbundle Bundles of variants for icon images. | |
| 4 | Copyright (c) 2003-2013 held jointly by the individual authors. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or modify it | |
| 7 | under the terms of the GNU Lesser General Public License as published | |
| 8 | by the Free Software Foundation; either version 3 of the License, or (at | |
| 9 | your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or | |
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
| 14 | License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public License | |
| 17 | along with this library; if not, write to the Free Software Foundation, | |
| 18 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | > http://www.fsf.org/licensing/licenses/lgpl.html | |
| 21 | > http://www.opensource.org/licenses/lgpl-license.php | |
| 22 | ||
| 23 | */ | |
| 24 | package org.dishevelled.iconbundle; | |
| 25 | ||
| 26 | import java.util.List; | |
| 27 | import java.util.Arrays; | |
| 28 | import java.util.Collections; | |
| 29 | ||
| 30 | import java.io.Serializable; | |
| 31 | ||
| 32 | /** | |
| 33 | * Typesafe enumeration of icon states. | |
| 34 | * | |
| 35 | * @author Michael Heuer | |
| 36 | */ | |
| 37 | public final class IconState | |
| 38 | implements Serializable | |
| 39 | { | |
| 40 | /** State name. */ | |
| 41 | private String name; | |
| 42 | ||
| 43 | ||
| 44 | /** | |
| 45 | * Create a new IconState with the specified name. | |
| 46 | * | |
| 47 | * @param name state name | |
| 48 | */ | |
| 49 | private IconState(final String name) | |
| 50 | 7 | { |
| 51 | 7 | this.name = name; |
| 52 | 7 | } |
| 53 | ||
| 54 | ||
| 55 | /** | |
| 56 | * Return the state name. | |
| 57 | * | |
| 58 | * @return the state name | |
| 59 | */ | |
| 60 | public String toString() | |
| 61 | { | |
| 62 | 48 | return name; |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Return true if this icon state is <code>IconState.NORMAL</code>. | |
| 67 | * | |
| 68 | * @return true if this icon state is <code>IconState.NORMAL</code> | |
| 69 | */ | |
| 70 | public boolean isNormal() | |
| 71 | { | |
| 72 | 6 | return (this == NORMAL); |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Return true if this icon state is <code>IconState.ACTIVE</code>. | |
| 77 | * | |
| 78 | * @return true if this icon state is <code>IconState.ACTIVE</code> | |
| 79 | */ | |
| 80 | public boolean isActive() | |
| 81 | { | |
| 82 | 6 | return (this == ACTIVE); |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * Return true if this icon state is <code>IconState.MOUSEOVER</code>. | |
| 87 | * | |
| 88 | * @return true if this icon state is <code>IconState.MOUSEOVER</code> | |
| 89 | */ | |
| 90 | public boolean isMouseover() | |
| 91 | { | |
| 92 | 6 | return (this == MOUSEOVER); |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * Return true if this icon state is <code>IconState.SELECTED</code>. | |
| 97 | * | |
| 98 | * @return true if this icon state is <code>IconState.SELECTED</code> | |
| 99 | */ | |
| 100 | public boolean isSelected() | |
| 101 | { | |
| 102 | 6 | return (this == SELECTED); |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * Return true if this icon state is <code>IconState.SELECTED_MOUSEOVER</code>. | |
| 107 | * | |
| 108 | * @return true if this icon state is <code>IconState.SELECTED_MOUSEOVER</code> | |
| 109 | */ | |
| 110 | public boolean isSelectedMouseover() | |
| 111 | { | |
| 112 | 0 | return (this == SELECTED_MOUSEOVER); |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * Return true if this icon state is <code>IconState.DRAGGING</code>. | |
| 117 | * | |
| 118 | * @return true if this icon state is <code>IconState.DRAGGING</code> | |
| 119 | */ | |
| 120 | public boolean isDragging() | |
| 121 | { | |
| 122 | 6 | return (this == DRAGGING); |
| 123 | } | |
| 124 | ||
| 125 | /** | |
| 126 | * Return true if this icon state is <code>IconState.DISABLED</code>. | |
| 127 | * | |
| 128 | * @return true if this icon state is <code>IconState.DISABLED</code> | |
| 129 | */ | |
| 130 | public boolean isDisabled() | |
| 131 | { | |
| 132 | 6 | return (this == DISABLED); |
| 133 | } | |
| 134 | ||
| 135 | ||
| 136 | /** Normal icon state. */ | |
| 137 | 1 | public static final IconState NORMAL = new IconState("normal"); |
| 138 | ||
| 139 | /** Active icon state. */ | |
| 140 | 1 | public static final IconState ACTIVE = new IconState("active"); |
| 141 | ||
| 142 | /** Mouseover icon state. */ | |
| 143 | 1 | public static final IconState MOUSEOVER = new IconState("mouseover"); |
| 144 | ||
| 145 | /** Selected icon state. */ | |
| 146 | 1 | public static final IconState SELECTED = new IconState("selected"); |
| 147 | ||
| 148 | /** Selected mouseover icon state. */ | |
| 149 | 1 | public static final IconState SELECTED_MOUSEOVER = new IconState("selected-mouseover"); |
| 150 | ||
| 151 | /** Dragging icon state. */ | |
| 152 | 1 | public static final IconState DRAGGING = new IconState("dragging"); |
| 153 | ||
| 154 | /** Disabled icon state. */ | |
| 155 | 1 | public static final IconState DISABLED = new IconState("disabled"); |
| 156 | ||
| 157 | /** | |
| 158 | * Private array of enumeration values. | |
| 159 | */ | |
| 160 | 1 | private static final IconState[] VALUES_ARRAY = { |
| 161 | NORMAL, | |
| 162 | ACTIVE, | |
| 163 | MOUSEOVER, | |
| 164 | SELECTED, | |
| 165 | SELECTED_MOUSEOVER, | |
| 166 | DRAGGING, | |
| 167 | DISABLED | |
| 168 | }; | |
| 169 | ||
| 170 | /** | |
| 171 | * Public list of enumeration values. | |
| 172 | */ | |
| 173 | 1 | public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); |
| 174 | } |