KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > proxy > scriptaculous > Effect


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.directwebremoting.proxy.scriptaculous;
17
18 import java.util.Collection JavaDoc;
19
20 import org.directwebremoting.ScriptBuffer;
21 import org.directwebremoting.ScriptSession;
22 import org.directwebremoting.proxy.ScriptProxy;
23
24 /**
25  * A server side proxy the the Scriptaculous Effect class
26  * @author Joe Walker [joe at getahead dot ltd dot uk]
27  * @author Mitch Gorman
28  */

29 public class Effect extends ScriptProxy
30 {
31     /**
32      * Http thread constructor, that affects no browsers.
33      * Calls to {@link Effect#addScriptSession(ScriptSession)} or to
34      * {@link Effect#addScriptSessions(Collection)} will be needed
35      */

36     public Effect()
37     {
38         super();
39     }
40
41     /**
42      * Http thread constructor that alters a single browser
43      * @param scriptSession The browser to alter
44      */

45     public Effect(ScriptSession scriptSession)
46     {
47         super(scriptSession);
48     }
49
50     /**
51      * Http thread constructor that alters a number of browsers
52      * @param scriptSessions A collection of ScriptSessions that we should act on.
53      */

54     public Effect(Collection JavaDoc scriptSessions)
55     {
56         super(scriptSessions);
57     }
58
59     /**
60      * Call the script.aculo.us <code>Effect.fade()</code> function.
61      * @param elementId The element to effect
62      */

63     public void fade(String JavaDoc elementId)
64     {
65         callEffect(elementId, "Fade");
66     }
67
68     /**
69      * Call the script.aculo.us <code>Effect.appear()</code> function.
70      * @param elementId The element to effect
71      */

72     public void appear(String JavaDoc elementId)
73     {
74         callEffect(elementId, "Appear");
75     }
76
77     /**
78      * Call the script.aculo.us <code>Effect.puff()</code> function.
79      * @param elementId The element to effect
80      */

81     public void puff(String JavaDoc elementId)
82     {
83         callEffect(elementId, "Puff");
84     }
85
86     /**
87      * Call the script.aculo.us <code>Effect.blindUp()</code> function.
88      * @param elementId The element to effect
89      */

90     public void blindUp(String JavaDoc elementId)
91     {
92         callEffect(elementId, "BlindUp");
93     }
94
95     /**
96      * Call the script.aculo.us <code>Effect.blindDown()</code> function.
97      * @param elementId The element to effect
98      */

99     public void blindDown(String JavaDoc elementId)
100     {
101         callEffect(elementId, "BlindDown");
102     }
103
104     /**
105      * Call the script.aculo.us <code>Effect.switchOff()</code> function.
106      * @param elementId The element to effect
107      */

108     public void switchOff(String JavaDoc elementId)
109     {
110         callEffect(elementId, "SwitchOff");
111     }
112
113     /**
114      * Call the script.aculo.us <code>Effect.dropOut()</code> function.
115      * @param elementId The element to effect
116      */

117     public void dropOut(String JavaDoc elementId)
118     {
119         callEffect(elementId, "DropOut");
120     }
121
122     /**
123      * Call the script.aculo.us <code>Effect.shake()</code> function.
124      * @param elementId The element to effect
125      */

126     public void shake(String JavaDoc elementId)
127     {
128         callEffect(elementId, "Shake");
129     }
130
131     /**
132      * Call the script.aculo.us <code>Effect.slideDown()</code> function.
133      * @param elementId The element to effect
134      */

135     public void slideDown(String JavaDoc elementId)
136     {
137         callEffect(elementId, "SlideDown");
138     }
139
140     /**
141      * Call the script.aculo.us <code>Effect.slideUp()</code> function.
142      * @param elementId The element to effect
143      */

144     public void slideUp(String JavaDoc elementId)
145     {
146         callEffect(elementId, "SlideUp");
147     }
148
149     /**
150      * Call the script.aculo.us <code>Effect.squish()</code> function.
151      * @param elementId The element to effect
152      */

153     public void squish(String JavaDoc elementId)
154     {
155         callEffect(elementId, "Squish");
156     }
157
158     /**
159      * Call the script.aculo.us <code>Effect.grow()</code> function.
160      * @param elementId The element to effect
161      */

162     public void grow(String JavaDoc elementId)
163     {
164         callEffect(elementId, "Grow");
165     }
166
167     /**
168      * Call the script.aculo.us <code>Effect.shrink()</code> function.
169      * @param elementId The element to effect
170      */

171     public void shrink(String JavaDoc elementId)
172     {
173         callEffect(elementId, "Shrink");
174     }
175
176     /**
177      * Call the script.aculo.us <code>Effect.pulsate()</code> function.
178      * @param elementId The element to effect
179      */

180     public void pulsate(String JavaDoc elementId)
181     {
182         callEffect(elementId, "Pulsate");
183     }
184
185     /**
186      * Call the script.aculo.us <code>Effect.fold()</code> function.
187      * @param elementId The element to effect
188      */

189     public void fold(String JavaDoc elementId)
190     {
191         callEffect(elementId, "Fold");
192     }
193
194     /**
195      * Call the script.aculo.us <code>Effect.Highlight()</code> function.
196      * @param elementId The element to effect
197      */

198     public void highlight(String JavaDoc elementId)
199     {
200         callEffect(elementId, "Highlight");
201     }
202
203     /**
204      * Call the script.aculo.us <code>Effect.Highlight()</code> function.
205      * @param elementId The element to affect
206      * @param options A string containing options to pass to the fade effect, as specified at http://script.aculo.us/
207      */

208     public void highlight(String JavaDoc elementId, String JavaDoc options)
209     {
210         callEffect(elementId, "Highlight", options);
211     }
212
213     /**
214      * Call the script.aculo.us <code>Effect.Fade()</code> function.
215      * @param elementId The element to affect
216      * @param options A string containing options to pass to the fade effect, as specified at http://script.aculo.us/
217      */

218     public void fade(String JavaDoc elementId, String JavaDoc options)
219     {
220         callEffect(elementId, "Fade", options);
221     }
222
223     /**
224      * Call the script.aculo.us <code>Effect.Appear()</code> function.
225      * @param elementId The element to affect
226      * @param options A string containing options to pass to the appear effect, as specified at http://script.aculo.us/
227      */

228     public void appear(String JavaDoc elementId, String JavaDoc options)
229     {
230         callEffect(elementId, "Appear", options);
231     }
232
233     /**
234      * Call the script.aculo.us <code>Effect.Puff()</code> function.
235      * @param elementId The element to affect
236      * @param options A string containing options to pass to the puff effect, as specified at http://script.aculo.us/
237      */

238     public void puff(String JavaDoc elementId, String JavaDoc options)
239     {
240         callEffect(elementId, "Puff", options);
241     }
242
243     /**
244      * Call the script.aculo.us <code>Effect.BlindUp()</code> function.
245      * @param elementId The element to affect
246      * @param options A string containing options to pass to the blindup effect, as specified at http://script.aculo.us/
247      */

248     public void blindUp(String JavaDoc elementId, String JavaDoc options)
249     {
250         callEffect(elementId, "BlindUp", options);
251     }
252
253     /**
254      * Call the script.aculo.us <code>Effect.BlindDown()</code> function.
255      * @param elementId The element to affect
256      * @param options A string containing options to pass to the blinddown effect, as specified at http://script.aculo.us/
257      */

258     public void blindDown(String JavaDoc elementId, String JavaDoc options)
259     {
260         callEffect(elementId, "BlindDown", options);
261     }
262
263     /**
264      * Call the script.aculo.us <code>Effect.SwitchOff()</code> function.
265      * @param elementId The element to affect
266      * @param options A string containing options to pass to the switchf effect, as specified at http://script.aculo.us/
267      */

268     public void switchOff(String JavaDoc elementId, String JavaDoc options)
269     {
270         callEffect(elementId, "SwitchOff", options);
271     }
272
273     /**
274      * Call the script.aculo.us <code>Effect.DropOut()</code> function.
275      * @param elementId The element to affect
276      * @param options A string containing options to pass to the dropout effect, as specified at http://script.aculo.us/
277      */

278     public void dropOut(String JavaDoc elementId, String JavaDoc options)
279     {
280         callEffect(elementId, "DropOut", options);
281     }
282
283     /**
284      * Call the script.aculo.us <code>Effect.Shake()</code> function.
285      * @param elementId The element to affect
286      * @param options A string containing options to pass to the shake effect, as specified at http://script.aculo.us/
287      */

288     public void shake(String JavaDoc elementId, String JavaDoc options)
289     {
290         callEffect(elementId, "Shake", options);
291     }
292
293     /**
294      * Call the script.aculo.us <code>Effect.SlideDown()</code> function.
295      * @param elementId The element to affect
296      * @param options A string containing options to pass to the slidedown effect, as specified at http://script.aculo.us/
297      */

298     public void slideDown(String JavaDoc elementId, String JavaDoc options)
299     {
300         callEffect(elementId, "SlideDown", options);
301     }
302
303     /**
304      * Call the script.aculo.us <code>Effect.SlideUp()</code> function.
305      * @param elementId The element to affect
306      * @param options A string containing options to pass to the slideup effect, as specified at http://script.aculo.us/
307      */

308     public void slideUp(String JavaDoc elementId, String JavaDoc options)
309     {
310         callEffect(elementId, "SlideUp", options);
311     }
312
313     /**
314      * Call the script.aculo.us <code>Effect.Squish()</code> function.
315      * @param elementId The element to affect
316      * @param options A string containing options to pass to the squish effect, as specified at http://script.aculo.us/
317      */

318     public void squish(String JavaDoc elementId, String JavaDoc options)
319     {
320         callEffect(elementId, "Squish", options);
321     }
322
323     /**
324      * Call the script.aculo.us <code>Effect.Grow()</code> function.
325      * @param elementId The element to affect
326      * @param options A string containing options to pass to the grow effect, as specified at http://script.aculo.us/
327      */

328     public void grow(String JavaDoc elementId, String JavaDoc options)
329     {
330         callEffect(elementId, "Grow", options);
331     }
332
333     /**
334      * Call the script.aculo.us <code>Effect.Shrink()</code> function.
335      * @param elementId The element to affect
336      * @param options A string containing options to pass to the shrink effect, as specified at http://script.aculo.us/
337      */

338     public void shrink(String JavaDoc elementId, String JavaDoc options)
339     {
340         callEffect(elementId, "Shrink", options);
341     }
342
343     /**
344      * Call the script.aculo.us <code>Effect.Pulsate()</code> function.
345      * @param elementId The element to affect
346      * @param options A string containing options to pass to the pulsate effect, as specified at http://script.aculo.us/
347      */

348     public void pulsate(String JavaDoc elementId, String JavaDoc options)
349     {
350         callEffect(elementId, "Pulsate", options);
351     }
352
353     /**
354      * Call the script.aculo.us <code>Effect.Fold()</code> function.
355      * @param elementId The element to affect
356      * @param options A string containing options to pass to the fold effect, as specified at http://script.aculo.us/
357      */

358     public void fold(String JavaDoc elementId, String JavaDoc options)
359     {
360         callEffect(elementId, "Fold", options);
361     }
362
363     /**
364      * @param elementId The element to affect
365      * @param function The script.aculo.us effect to employ
366      */

367     private void callEffect(String JavaDoc elementId, String JavaDoc function)
368     {
369         callEffect(elementId, function, null);
370     }
371
372     /**
373      * @param elementId The element to affect
374      * @param function The script.aculo.us effect to employ
375      * @param options A string containing options to pass to the script.aculo.us effect, as specified at http://script.aculo.us/
376      */

377     private void callEffect(String JavaDoc elementId, String JavaDoc function, String JavaDoc options)
378     {
379         ScriptBuffer script = new ScriptBuffer();
380         script.appendScript("new Effect.").appendScript(function).appendScript("('").appendScript(elementId).appendScript("'");
381         if (options != null && options.length() > 0)
382         {
383             script.appendScript(", ").appendScript(options);
384         }
385         script.appendScript(");");
386         addScript(script);
387     }
388 }
389
Popular Tags