View Javadoc

1   /*
2    @See License.txt@
3    */
4   package spellcast.gestures;
5   
6   /***
7    * A Spellcast <code>Gesture</code>.
8    * <p>
9    * Spellcast defines eight valid gestures; emptyHand, palm, digit, fingers,
10   * wave, clap, snap, and knife.
11   * </p>
12   * <p>
13   * It also uses two display gestures: antispell and unclear.
14   * </p>
15   * <p>
16   * <code>Gesture</code>s can also be two handed.
17   * </p>
18   *
19   * @author Barrie Treloar
20   * @version $Revision: 1.1 $
21   */
22  public enum Gesture {
23      EMPTY_HAND("empty hand"), PALM("palm"), DIGIT("digit"), FINGERS("fingers"), WAVE(
24              "wave"), CLAP("clap", true), SNAP("snap"), KNIFE("knife"), ANTISPELL(
25              "antispell"), UNCLEAR("unclear"), TWO_HANDED_PALM(
26              "two handed palm", true), ONE_HANDED_CLAP("one handed clap");
27  
28      /*** The name of this <code>Gesture</code>. */
29      private String name;
30  
31      /*** Indicates if the <code>Gesture</code> is two handed. */
32      private boolean isTwoHanded;
33  
34      /***
35       * Indicates if the <code>Gesture</code> is unclear and should be
36       * obscured.
37       */
38      private boolean isUnclear;
39  
40      /***
41       * Equivalent to <code>Gesture(name, false)</code>.
42       *
43       * @param theName
44       *            the name of the <code>Gesture</code>.
45       * @see Gesture(String, boolean)
46       */
47      Gesture(final String theName) {
48          this(theName, false);
49      }
50  
51      /***
52       * Equivalent to <code>Gesture(name, false, false)</code>.
53       *
54       * @param theName
55       *            the name of the <code>Gesture</code>.
56       * @param isGestureTwoHanded
57       *            indicates if this <code>Gesture</code> is two handed.
58       * @see Gesture(String, boolean, boolean)
59       */
60      Gesture(final String theName, final boolean isGestureTwoHanded) {
61          this(theName, isGestureTwoHanded, false);
62      }
63  
64      /***
65       * Create the <code>Gesture</code>.
66       *
67       * @param theName
68       *            the name of the <code>Gesture</code>.
69       * @param isGestureTwoHanded
70       *            indicates if this <code>Gesture</code> is two handed.
71       * @param isGestureUnclear
72       *            indicates if this <code>Gesture</code> is unclear.
73       */
74      Gesture(final String theName, final boolean isGestureTwoHanded,
75              boolean isGestureUnclear) {
76          setName(theName);
77          setTwoHanded(isGestureTwoHanded);
78          setUnclear(isGestureUnclear);
79      }
80  
81      /***
82       * Return the name of this gesture.
83       *
84       * @return the name of this gesture.
85       */
86      public final String getName() {
87          return name;
88      }
89  
90      /***
91       * Indicates whether this <code>Gesture</code> is two handed or one
92       * handed. True is two handed, false otherwise.
93       *
94       * @return true for a two handed <code>Gesture</code>, false for a one
95       *         handed <code>Gesture</code>.
96       */
97      public final boolean isTwoHanded() {
98          return isTwoHanded;
99      }
100 
101     /***
102      * Indicates whether the <code>Gesture</code> is unclear. An unclear
103      * <code>Gesture</code> will not be visible to the <code>Being</code>.
104      *
105      * @return value true if the <code>Gesture</code> is unclear, false
106      *         otherwise.
107      */
108     public final boolean isUnclear() {
109         return isUnclear;
110     }
111 
112     /***
113      * Sets whether this <code>Gesture</code> is unclear.
114      *
115      * @param isGestureUnclear
116      *            whether this <code>Gesture</code> is unclear.
117      */
118     private final void setUnclear(final boolean isGestureUnclear) {
119         isUnclear = isGestureUnclear;
120     }
121 
122     /***
123      * Set the name for this <code>gesture</code>.
124      *
125      * @param theName
126      *            the name of this <code>Gesture</code>.
127      */
128     private void setName(final String theName) {
129         name = theName;
130     }
131 
132     /***
133      * Sets whether this <code>Gesture</code> is two handed.
134      *
135      * @param isGestureTwoHanded
136      *            whether the <code>Gesture</code> is two handed.
137      */
138     private void setTwoHanded(final boolean isGestureTwoHanded) {
139         isTwoHanded = isGestureTwoHanded;
140     }
141 }