001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package jsx3.vector;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * Represents a vector fill, the color and gradient that fills a solid vector shape.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class Fill extends jsx3.html.Tag {
028: /**
029: * All reverse ajax proxies need context to work from
030: * @param scriptProxy The place we are writing scripts to
031: * @param context The script that got us to where we are now
032: */
033: public Fill(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: * The instance initializer.
040: * @param color the color value, as a hex String or 24-bit integer value, defaults to 0x000000
041: * @param alpha the opacity value, valid values are between 0 and 1, defaults to 1
042: */
043: public Fill(int color, float alpha) {
044: super ((Context) null, (String) null, (ScriptProxy) null);
045: ScriptBuffer script = new ScriptBuffer();
046: script.appendCall("new Fill", color, alpha);
047: setInitScript(script);
048: }
049:
050: /**
051: * The instance initializer.
052: * @param color the color value, as a hex String or 24-bit integer value, defaults to 0x000000
053: * @param alpha the opacity value, valid values are between 0 and 1, defaults to 1
054: */
055: public Fill(String color, float alpha) {
056: super ((Context) null, (String) null, (ScriptProxy) null);
057: ScriptBuffer script = new ScriptBuffer();
058: script.appendCall("new Fill", color, alpha);
059: setInitScript(script);
060: }
061:
062: /**
063: * Returns the color field, as previously set in the constructor or with setColor().
064: */
065: public void getColor() {
066: ScriptBuffer script = new ScriptBuffer();
067: script.appendCall(getContextPath() + "getColor");
068: getScriptProxy().addScript(script);
069: }
070:
071: /**
072: * Returns the color field, as a CSS hex string.
073: */
074: @SuppressWarnings("unchecked")
075: public void getColorHtml(
076: org.directwebremoting.proxy.Callback<String> callback) {
077: ScriptBuffer script = new ScriptBuffer();
078: String callbackPrefix = "";
079:
080: if (callback != null) {
081: callbackPrefix = "var reply = ";
082: }
083:
084: script.appendCall(callbackPrefix + getContextPath()
085: + "getColorHtml");
086:
087: if (callback != null) {
088: String key = org.directwebremoting.extend.CallbackHelper
089: .saveCallback(callback, String.class);
090: script
091: .appendCall("__System.activateCallback", key,
092: "reply");
093: }
094:
095: getScriptProxy().addScript(script);
096: }
097:
098: /**
099: * Sets the color field.
100: * @param color the new value for color
101: */
102: public void setColor(Integer color) {
103: ScriptBuffer script = new ScriptBuffer();
104: script.appendCall(getContextPath() + "setColor", color);
105: getScriptProxy().addScript(script);
106: }
107:
108: /**
109: * Sets the color field.
110: * @param color the new value for color
111: */
112: public void setColor(String color) {
113: ScriptBuffer script = new ScriptBuffer();
114: script.appendCall(getContextPath() + "setColor", color);
115: getScriptProxy().addScript(script);
116: }
117:
118: /**
119: * Returns the alpha field, as previously set in the constructor or with setAlpha().
120: * @param callback alpha
121: */
122: @SuppressWarnings("unchecked")
123: public void getAlpha(
124: org.directwebremoting.proxy.Callback<Float> callback) {
125: ScriptBuffer script = new ScriptBuffer();
126: String callbackPrefix = "";
127:
128: if (callback != null) {
129: callbackPrefix = "var reply = ";
130: }
131:
132: script.appendCall(callbackPrefix + getContextPath()
133: + "getAlpha");
134:
135: if (callback != null) {
136: String key = org.directwebremoting.extend.CallbackHelper
137: .saveCallback(callback, Float.class);
138: script
139: .appendCall("__System.activateCallback", key,
140: "reply");
141: }
142:
143: getScriptProxy().addScript(script);
144: }
145:
146: /**
147: * Sets the alpha field, valid values are between 0 (transparent) and 1 (opaque)..
148: * @param alpha the new value for alpha
149: */
150: public void setAlpha(float alpha) {
151: ScriptBuffer script = new ScriptBuffer();
152: script.appendCall(getContextPath() + "setAlpha", alpha);
153: getScriptProxy().addScript(script);
154: }
155:
156: /**
157: * Returns the type field, as set with setType().
158: * @param callback type
159: */
160: @SuppressWarnings("unchecked")
161: public void getType(
162: org.directwebremoting.proxy.Callback<String> callback) {
163: ScriptBuffer script = new ScriptBuffer();
164: String callbackPrefix = "";
165:
166: if (callback != null) {
167: callbackPrefix = "var reply = ";
168: }
169:
170: script
171: .appendCall(callbackPrefix + getContextPath()
172: + "getType");
173:
174: if (callback != null) {
175: String key = org.directwebremoting.extend.CallbackHelper
176: .saveCallback(callback, String.class);
177: script
178: .appendCall("__System.activateCallback", key,
179: "reply");
180: }
181:
182: getScriptProxy().addScript(script);
183: }
184:
185: /**
186: * Sets the type field, valid values are enumerated in the VML specification, though only 'solid', 'gradient', and 'gradientradial' are truly supported by this class.
187: * @param type the new value for type
188: */
189: public void setType(String type) {
190: ScriptBuffer script = new ScriptBuffer();
191: script.appendCall(getContextPath() + "setType", type);
192: getScriptProxy().addScript(script);
193: }
194:
195: /**
196: * Returns the color2 field, as set with setColor2().
197: */
198: public void getColor2() {
199: ScriptBuffer script = new ScriptBuffer();
200: script.appendCall(getContextPath() + "getColor2");
201: getScriptProxy().addScript(script);
202: }
203:
204: /**
205: * ? getColor2Html() {String} gets the color2 field, as a CSS hex string
206: */
207: public void getColor2Html() {
208: ScriptBuffer script = new ScriptBuffer();
209: script.appendCall(getContextPath() + "getColor2Html");
210: getScriptProxy().addScript(script);
211: }
212:
213: /**
214: * Sets the color2 field.
215: * @param color2 the new value for color2
216: */
217: public void setColor2(String color2) {
218: ScriptBuffer script = new ScriptBuffer();
219: script.appendCall(getContextPath() + "setColor2", color2);
220: getScriptProxy().addScript(script);
221: }
222:
223: /**
224: * Sets the color2 field.
225: * @param color2 the new value for color2
226: */
227: public void setColor2(Integer color2) {
228: ScriptBuffer script = new ScriptBuffer();
229: script.appendCall(getContextPath() + "setColor2", color2);
230: getScriptProxy().addScript(script);
231: }
232:
233: /**
234: * Returns the alpha2 field, as set with setAlpha2().
235: * @param callback alpha2
236: */
237: @SuppressWarnings("unchecked")
238: public void getAlpha2(
239: org.directwebremoting.proxy.Callback<Float> callback) {
240: ScriptBuffer script = new ScriptBuffer();
241: String callbackPrefix = "";
242:
243: if (callback != null) {
244: callbackPrefix = "var reply = ";
245: }
246:
247: script.appendCall(callbackPrefix + getContextPath()
248: + "getAlpha2");
249:
250: if (callback != null) {
251: String key = org.directwebremoting.extend.CallbackHelper
252: .saveCallback(callback, Float.class);
253: script
254: .appendCall("__System.activateCallback", key,
255: "reply");
256: }
257:
258: getScriptProxy().addScript(script);
259: }
260:
261: /**
262: * Sets the alpha2 field, valid values are between 0 (transparent) and 1 (opaque)..
263: * @param alpha2 the new value for alpha2
264: */
265: public void setAlpha2(float alpha2) {
266: ScriptBuffer script = new ScriptBuffer();
267: script.appendCall(getContextPath() + "setAlpha2", alpha2);
268: getScriptProxy().addScript(script);
269: }
270:
271: /**
272: * Returns the angle field (the angle along which the gradient goes), as set with setAngle().
273: * @param callback angle
274: */
275: @SuppressWarnings("unchecked")
276: public void getAngle(
277: org.directwebremoting.proxy.Callback<Integer> callback) {
278: ScriptBuffer script = new ScriptBuffer();
279: String callbackPrefix = "";
280:
281: if (callback != null) {
282: callbackPrefix = "var reply = ";
283: }
284:
285: script.appendCall(callbackPrefix + getContextPath()
286: + "getAngle");
287:
288: if (callback != null) {
289: String key = org.directwebremoting.extend.CallbackHelper
290: .saveCallback(callback, Integer.class);
291: script
292: .appendCall("__System.activateCallback", key,
293: "reply");
294: }
295:
296: getScriptProxy().addScript(script);
297: }
298:
299: /**
300: * Sets the angle field, valid values are between 0 and 360. 0 is the vector pointing rightward.
301: * @param angle the new value for angle
302: */
303: public void setAngle(int angle) {
304: ScriptBuffer script = new ScriptBuffer();
305: script.appendCall(getContextPath() + "setAngle", angle);
306: getScriptProxy().addScript(script);
307: }
308:
309: /**
310: * Returns the colors field, as set with setColors().
311: * @param callback colors
312: */
313: @SuppressWarnings("unchecked")
314: public void getColors(
315: org.directwebremoting.proxy.Callback<String> callback) {
316: ScriptBuffer script = new ScriptBuffer();
317: String callbackPrefix = "";
318:
319: if (callback != null) {
320: callbackPrefix = "var reply = ";
321: }
322:
323: script.appendCall(callbackPrefix + getContextPath()
324: + "getColors");
325:
326: if (callback != null) {
327: String key = org.directwebremoting.extend.CallbackHelper
328: .saveCallback(callback, String.class);
329: script
330: .appendCall("__System.activateCallback", key,
331: "reply");
332: }
333:
334: getScriptProxy().addScript(script);
335: }
336:
337: /**
338: * Sets the colors field, see the documentation for <fill> in the VML documentation.
339: * @param colors the new value for colors
340: */
341: public void setColors(String colors) {
342: ScriptBuffer script = new ScriptBuffer();
343: script.appendCall(getContextPath() + "setColors", colors);
344: getScriptProxy().addScript(script);
345: }
346:
347: /**
348: * Parses a vector fill from its string representation. The format is "color alpha".
349: * @param v the string representation of a fill.
350: * @return <code>null</code> if <code>v</code> is empty, <code>v</code> if <code>v</code>
351: is already a vector fill, or otherwise a new vector fill created by parsing the string according to the
352: format specified above.
353: */
354: @SuppressWarnings("unchecked")
355: public jsx3.vector.Fill valueOf(String v) {
356: String extension = "valueOf(\"" + v + "\").";
357: try {
358: java.lang.reflect.Constructor<jsx3.vector.Fill> ctor = jsx3.vector.Fill.class
359: .getConstructor(Context.class, String.class,
360: ScriptProxy.class);
361: return ctor.newInstance(this , extension, getScriptProxy());
362: } catch (Exception ex) {
363: throw new IllegalArgumentException("Unsupported type: "
364: + jsx3.vector.Fill.class.getName());
365: }
366: }
367:
368: /**
369: * Parses a vector fill from its string representation. The format is "color alpha".
370: * @param v the string representation of a fill.
371: * @return <code>null</code> if <code>v</code> is empty, <code>v</code> if <code>v</code>
372: is already a vector fill, or otherwise a new vector fill created by parsing the string according to the
373: format specified above.
374: */
375: @SuppressWarnings("unchecked")
376: public jsx3.vector.Fill valueOf(jsx3.vector.Fill v) {
377: String extension = "valueOf(\"" + v + "\").";
378: try {
379: java.lang.reflect.Constructor<jsx3.vector.Fill> ctor = jsx3.vector.Fill.class
380: .getConstructor(Context.class, String.class,
381: ScriptProxy.class);
382: return ctor.newInstance(this , extension, getScriptProxy());
383: } catch (Exception ex) {
384: throw new IllegalArgumentException("Unsupported type: "
385: + jsx3.vector.Fill.class.getName());
386: }
387: }
388:
389: }
|