View Javadoc

1   /*
2   @See License.txt@
3    */
4   package spellcast.gestures;
5   
6   /***
7    * The <code>GestureFactory</code> provides the Flyweight methods for creating
8    * <code>Gestures</code>.
9    *
10   * Do not use.  Replaced with Enumerated type Gesture.
11   *
12   * @author Barrie Treloar
13   * @version $Revision: 1.1 $
14   * @deprecated
15   */
16  public final class GestureFactory {
17      /*** The singleton instance. */
18      private static GestureFactory instance;
19  
20      /*** The emptyHand <code>Gesture</code>. */
21      private Gesture emptyHand;
22  
23      /*** The palm <code>Gesture</code>. */
24      private Gesture palm;
25  
26      /*** The digit <code>Gesture</code>. */
27      private Gesture digit;
28  
29      /*** The fingers <code>Gesture</code>. */
30      private Gesture fingers;
31  
32      /*** The wave <code>Gesture</code>. */
33      private Gesture wave;
34  
35      /*** The clap <code>Gesture</code>. */
36      private Gesture clap;
37  
38      /*** The snap <code>Gesture</code>. */
39      private Gesture snap;
40  
41      /*** The knife <code>Gesture</code>. */
42      private Gesture knife;
43  
44      /*** The anitspell display <code>Gesture</code>. */
45      private Gesture antispell;
46  
47      /*** The unclear display <code>Gesture</code>. */
48      private Gesture unclear;
49  
50      /*** The two handed palm <code>Gesture</code>. */
51      private Gesture twoHandedPalm;
52  
53      /***
54       * GestureFactory is a singleton.
55       */
56      private GestureFactory() {
57      }
58  
59      /***
60       * The instance of the <code>GestureFactory</code>.
61       *
62       * @return The instance of the <code>GestureFactory</code>.
63       */
64      public static GestureFactory instance() {
65          if (instance == null) {
66              instance = new GestureFactory();
67          }
68  
69          return instance;
70      }
71  
72      /***
73       * The Flyweight creation method for the EmptyHand <code>Gesture</code>.
74       *
75       * @return an EmptyHand <code>Gesture</code>.
76       */
77      public Gesture getEmptyHand() {
78          if (emptyHand == null) {
79              emptyHand = Gesture.EMPTY_HAND;
80          }
81  
82          return emptyHand;
83      }
84  
85      /***
86       * The Flyweight creation method for the Palm <code>Gesture</code>.
87       *
88       * @return a Palm <code>Gesture</code>.
89       */
90      public Gesture getPalm() {
91          if (palm == null) {
92              palm = Gesture.PALM;
93          }
94  
95          return palm;
96      }
97  
98      /***
99       * The Flyweight creation method for the Digit <code>Gesture</code>.
100      *
101      * @return a Digit <code>Gesture</code>.
102      */
103     public Gesture getDigit() {
104         if (digit == null) {
105             digit = Gesture.DIGIT;
106         }
107 
108         return digit;
109     }
110 
111     /***
112      * The Flyweight creation method for the Fingers <code>Gesture</code>.
113      *
114      * @return a Fingers <code>Gesture</code>.
115      */
116     public Gesture getFingers() {
117         if (fingers == null) {
118             fingers = Gesture.FINGERS;
119         }
120 
121         return fingers;
122     }
123 
124     /***
125      * The Flyweight creation method for the Wave <code>Gesture</code>.
126      *
127      * @return a Wave <code>Gesture</code>.
128      */
129     public Gesture getWave() {
130         if (wave == null) {
131             wave = Gesture.WAVE;
132         }
133 
134         return wave;
135     }
136 
137     /***
138      * The Flyweight creation method for the Clap <code>Gesture</code>.
139      *
140      * @return a Clap <code>Gesture</code>.
141      */
142     public Gesture getClap() {
143         if (clap == null) {
144             clap = Gesture.CLAP;
145         }
146 
147         return clap;
148     }
149 
150     /***
151      * The Flyweight creation method for the Snap <code>Gesture</code>.
152      *
153      * @return a Snap <code>Gesture</code>.
154      */
155     public Gesture getSnap() {
156         if (snap == null) {
157             snap = Gesture.SNAP;
158         }
159 
160         return snap;
161     }
162 
163     /***
164      * The Flyweight creation method for the Knife <code>Gesture</code>.
165      *
166      * @return a Knife<code>Gesture</code>.
167      */
168     public Gesture getKnife() {
169         if (knife == null) {
170             knife = Gesture.KNIFE;
171         }
172 
173         return knife;
174     }
175 
176     /***
177      * The Flyweight creation method for the Antispell display
178      * <code>Gesture</code>.
179      *
180      * @return an Antispell display <code>Gesture</code>.
181      */
182     public Gesture getAntispell() {
183         if (antispell == null) {
184             antispell = Gesture.ANTISPELL;
185         }
186 
187         return antispell;
188     }
189 
190     /***
191      * The Flyweight creation method for the Unclear display
192      * <code>Gesture</code>.
193      *
194      * @return an Unclear display <code>Gesture</code>.
195      */
196     public Gesture getUnclear() {
197         if (unclear == null) {
198             unclear = Gesture.UNCLEAR;
199         }
200 
201         return unclear;
202     }
203 
204     /***
205      * The Flyweight creation method for the two handed palm
206      * <code>Gesture</code>.
207      *
208      * @return a two handed Palm <code>Gesture</code>.
209      */
210     public Gesture getTwoHandedPalm() {
211         if (twoHandedPalm == null) {
212             twoHandedPalm = Gesture.TWO_HANDED_PALM;
213         }
214 
215         return twoHandedPalm;
216     }
217 }